fix create order query
This commit is contained in:
parent
a7f00a3811
commit
085263654f
@ -4,7 +4,7 @@ import { useOrderCreate } from '@/hooks/api/orders';
|
||||
import { useOrderStore } from '@/stores/order';
|
||||
import { Button } from '@repo/ui/components/ui/button';
|
||||
import { LoadingSpinner } from '@repo/ui/components/ui/spinner';
|
||||
import { formatDate, formatTime } from '@repo/utils/datetime-format';
|
||||
import { formatTime } from '@repo/utils/datetime-format';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export function SubmitButton() {
|
||||
@ -19,7 +19,6 @@ export function SubmitButton() {
|
||||
createOrder({
|
||||
input: {
|
||||
client: clientId,
|
||||
date: formatDate(date).db(),
|
||||
services: [serviceId],
|
||||
slot: slotId,
|
||||
time_start: formatTime(time).db(),
|
||||
|
||||
@ -15,8 +15,16 @@ export const useOrderCreate = () => {
|
||||
return useMutation({
|
||||
mutationFn: createOrder,
|
||||
mutationKey: ['order', 'create'],
|
||||
onSuccess: () => {
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['orders'] });
|
||||
|
||||
const documentId = data?.createOrder?.documentId;
|
||||
|
||||
if (documentId)
|
||||
queryClient.prefetchQuery({
|
||||
queryFn: () => getOrder({ documentId }),
|
||||
queryKey: ['order', documentId],
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@ -75,10 +75,9 @@ export class OrdersService extends BaseService {
|
||||
const mutationResult = await mutate({
|
||||
mutation: GQL.CreateOrderDocument,
|
||||
variables: {
|
||||
...variables,
|
||||
input: {
|
||||
client: variables.input.client,
|
||||
services: variables.input.services,
|
||||
slot: variables.input.slot,
|
||||
...variables.input,
|
||||
time_end: formatTime(endTime).db(),
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user