Migrate to Vue 3 and Vite

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-07-12 10:55:28 +02:00
parent 8f4099ee33
commit ee20e03cc2
464 changed files with 31515 additions and 32758 deletions

View File

@@ -0,0 +1,51 @@
import { DELETE_EVENT, FETCH_EVENT, FETCH_EVENT_BASIC } from "@/graphql/event";
import { IEvent } from "@/types/event.model";
import { useMutation, useQuery } from "@vue/apollo-composable";
import { computed } from "vue";
export function useFetchEvent(uuid?: string) {
const {
result: fetchEventResult,
loading,
error,
onError,
onResult,
} = useQuery<{ event: IEvent }>(
FETCH_EVENT,
{
uuid,
},
() => ({
enabled: uuid !== undefined,
})
);
const event = computed(() => fetchEventResult.value?.event);
return { event, loading, error, onError, onResult };
}
export function useFetchEventBasic(uuid: string) {
const {
result: fetchEventResult,
loading,
error,
onResult,
onError,
} = useQuery<{ event: IEvent }>(FETCH_EVENT_BASIC, {
uuid,
});
const event = computed(() => fetchEventResult.value?.event);
return { event, loading, error, onResult, onError };
}
export function useDeleteEvent() {
return useMutation<{ id: string }, { eventId: string }>(DELETE_EVENT, () => ({
update(cache, { data }) {
cache.evict({ id: `Event:${data?.id}` });
cache.gc();
},
}));
}