1- import { defineMutation , useMutation , useQueryCache } from "@pinia/colada" ;
2- import { uploadMyImage } from "@/api/me.ts" ;
3- import type { CreateContactData } from "@/dto/contacts.ts" ;
4- import { updateContact } from "@/api/contacts.ts" ;
5- import { ref } from "vue" ;
1+ import { defineMutation , useMutation , useQueryCache } from "@pinia/colada" ;
2+ import { uploadMyImage } from "@/api/me.ts" ;
3+ import type { CreateContactData } from "@/dto/contacts.ts" ;
4+ import { updateContact } from "@/api/contacts.ts" ;
5+ import { ref } from "vue" ;
66
77export const useUploadImageMutation = defineMutation ( ( ) => {
8- const file = ref < File > ( ) ;
9- const queryCache = useQueryCache ( ) ;
8+ const file = ref < File > ( ) ;
9+ const queryCache = useQueryCache ( ) ;
1010
11- const { mutate, ...mutation } = useMutation ( {
12- mutation : ( ) => uploadMyImage ( file . value ! ) ,
13- onSettled : ( ) => {
14- queryCache . invalidateQueries ( { key : [ "me" ] } ) ;
15- } ,
16- } ) ;
11+ const { mutate, ...mutation } = useMutation ( {
12+ mutation : ( ) => uploadMyImage ( file . value ! ) ,
13+ onSettled : ( ) => {
14+ queryCache . invalidateQueries ( { key : [ "me" ] } ) ;
15+ } ,
16+ } ) ;
1717
18- return {
19- mutate,
20- ...mutation ,
21- file,
22- } ;
18+ return {
19+ mutate,
20+ ...mutation ,
21+ file,
22+ } ;
2323} ) ;
2424
2525export const useUpdateContactMutation = defineMutation ( ( ) => {
26- const contactId = ref < string > ( ) ;
27- const data = ref < CreateContactData > ( ) ;
28- const queryCache = useQueryCache ( ) ;
26+ const contactId = ref < string > ( ) ;
27+ const data = ref < CreateContactData > ( ) ;
28+ const queryCache = useQueryCache ( ) ;
2929
30- const { mutate, ...mutation } = useMutation ( {
31- mutation : ( ) => updateContact ( contactId . value ! , data . value ! ) ,
32- onSettled : ( ) => {
33- queryCache . invalidateQueries ( { key : [ "me" ] } ) ;
34- } ,
35- } ) ;
30+ const { mutate, ...mutation } = useMutation ( {
31+ mutation : ( ) => updateContact ( contactId . value ! , data . value ! ) ,
32+ onSettled : ( ) => {
33+ queryCache . invalidateQueries ( { key : [ "me" ] } ) ;
34+ } ,
35+ } ) ;
3636
37- return {
38- mutate,
39- ...mutation ,
40- contactId,
41- data,
42- } ;
43- } ) ;
37+ return {
38+ mutate,
39+ ...mutation ,
40+ contactId,
41+ data,
42+ } ;
43+ } ) ;
0 commit comments