Changeset 299af01 for src/sections/user/customer-quick-edit-form.tsx
- Timestamp:
- 02/26/25 14:27:26 (6 weeks ago)
- Branches:
- main
- Children:
- 3c5302a
- Parents:
- 057453c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sections/user/customer-quick-edit-form.tsx
r057453c r299af01 14 14 import DialogContent from '@mui/material/DialogContent'; 15 15 // types 16 import { Customer, customerSchema } from 'src/schemas';16 import { Customer, updateCustomerSchema } from 'src/schemas'; 17 17 // assets 18 18 import { countries } from 'src/assets/data'; … … 21 21 import { useSnackbar } from 'src/components/snackbar'; 22 22 import FormProvider, { RHFSelect, RHFTextField, RHFAutocomplete } from 'src/components/hook-form'; 23 import { doc, setDoc } from 'firebase/firestore'; 24 import { db } from 'src/lib/firebase'; 25 import { mutate } from 'swr'; 26 import { collections } from 'src/lib/firestore'; 23 import { updateCustomer } from 'src/api/customer'; 27 24 28 25 // ---------------------------------------------------------------------- … … 58 55 }, 59 56 vatNumber: currentCustomer?.vatNumber || '', 60 companyId: currentCustomer?.companyId || '',61 57 companyNumber: currentCustomer?.companyNumber || '', 62 58 id: currentCustomer?.id || '', … … 68 64 69 65 const methods = useForm({ 70 resolver: zodResolver( customerSchema),66 resolver: zodResolver(updateCustomerSchema), 71 67 defaultValues, 72 68 }); … … 80 76 const onSubmit = handleSubmit(async (data) => { 81 77 try { 78 console.log('currentCustomer', currentCustomer); 82 79 if (!currentCustomer) return; 83 // await new Promise((resolve) => setTimeout(resolve, 500)); 84 85 const docRef = doc(db, 'customers', currentCustomer.id!); 86 await setDoc(docRef, data, { merge: true }); 87 mutate(collections.customer); 80 console.log('data', data); 81 await updateCustomer(currentCustomer.id!, data); 88 82 89 83 reset(); … … 93 87 } catch (error) { 94 88 console.error(error); 89 enqueueSnackbar('Update failed!', { variant: 'error' }); 95 90 } 96 91 });
Note:
See TracChangeset
for help on using the changeset viewer.