mirror of
				https://github.com/Instadapp/assembly.git
				synced 2024-07-29 22:37:06 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			41 lines
		
	
	
		
			897 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			897 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { computed, ref } from "@nuxtjs/composition-api";
 | |
| import NetworksMismatchDialog from "~/components/modal/NetworksMismatchDialog.vue";
 | |
| 
 | |
| const modal = ref(null);
 | |
| const props = ref({});
 | |
| 
 | |
| export function useModal() {
 | |
|   function showNetworksMismatchDialog() {
 | |
|     modal.value = NetworksMismatchDialog;
 | |
|   }
 | |
| 
 | |
|   function close() {
 | |
|     //@ts-ignore
 | |
|     if (props.value?.persistent) return;
 | |
|     modal.value = null;
 | |
|     props.value = null;
 | |
|   }
 | |
| 
 | |
|   function closePersistent() {
 | |
|     modal.value = null;
 | |
|     props.value = null;
 | |
|   }
 | |
| 
 | |
|   const isShown = computed(() => !!modal.value);
 | |
| 
 | |
|   function showComponent(component, componentProps = {}) {
 | |
|     modal.value = component;
 | |
|     props.value = componentProps;
 | |
|   }
 | |
|   
 | |
|   return {
 | |
|     showNetworksMismatchDialog,
 | |
|     close,
 | |
|     closePersistent,
 | |
|     isShown,
 | |
|     modal: computed(() => modal.value),
 | |
|     props: computed(() => props.value),
 | |
|     showComponent
 | |
|   };
 | |
| }
 | 
