update purchase order
This commit is contained in:
@@ -26,7 +26,7 @@ export const usePurchaseOrdersMutation = () => {
|
||||
return response.data
|
||||
},
|
||||
onSuccess: () => {
|
||||
toast.success('Purchase Order created successfully!')
|
||||
toast.success('Purchase Order Payment successfully!')
|
||||
queryClient.invalidateQueries({ queryKey: ['purchase-orders'] })
|
||||
},
|
||||
onError: (error: any) => {
|
||||
@@ -34,5 +34,19 @@ export const usePurchaseOrdersMutation = () => {
|
||||
}
|
||||
})
|
||||
|
||||
return { createPurchaseOrder, sendPaymentPurchaseOrder }
|
||||
const updateStatus = useMutation({
|
||||
mutationFn: async ({ id, payload }: { id: string; payload: 'approved' | 'rejected' }) => {
|
||||
const response = await api.put(`/purchase-orders/${id}`, { status: payload })
|
||||
return response.data
|
||||
},
|
||||
onSuccess: () => {
|
||||
toast.success('Purchase Order Status successfully!')
|
||||
queryClient.invalidateQueries({ queryKey: ['purchase-orders'] })
|
||||
},
|
||||
onError: (error: any) => {
|
||||
toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed')
|
||||
}
|
||||
})
|
||||
|
||||
return { createPurchaseOrder, sendPaymentPurchaseOrder, updateStatus }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user