update purchase order

This commit is contained in:
efrilm
2025-09-25 16:20:13 +07:00
parent dc32c8553b
commit d317e8d06f
4 changed files with 370 additions and 169 deletions
+16 -2
View File
@@ -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 }
}