update order page
This commit is contained in:
@@ -92,7 +92,6 @@ const DetailPerfomaInvoice: FC = () => {
|
||||
const lineTotal = item.total ?? 0;
|
||||
const convertToOrderUrl = `${Paths.convertToOrder}?${new URLSearchParams({
|
||||
invoiceItemId: item.id,
|
||||
productId: item.product?.id ?? '',
|
||||
}).toString()}`;
|
||||
return (
|
||||
<tr key={item.id} className="border-b border-border/50">
|
||||
|
||||
@@ -28,6 +28,14 @@ export const useGetInvoiceDetail = (id: string | undefined) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetInvoiceItem = (id: string | null) => {
|
||||
return useQuery({
|
||||
queryKey: ["invoice-item", id],
|
||||
queryFn: () => api.getInvoiceItemById(id!),
|
||||
enabled: !!id,
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateInvoice = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import axios from "@/config/axios";
|
||||
import type {
|
||||
CreatePreInvoiceType,
|
||||
GetInvoiceResponseType,
|
||||
InvoiceItemDetailType,
|
||||
InvoiceType,
|
||||
UpdatePreInvoiceType,
|
||||
} from "../types/Types";
|
||||
@@ -23,6 +24,13 @@ export const getInvoiceById = async (id: string) => {
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getInvoiceItemById = async (id: string) => {
|
||||
const { data } = await axios.get<{ data: InvoiceItemDetailType }>(
|
||||
`/admin/invoice/item/${id}`,
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const updateInvoice = async (id: string, params: UpdatePreInvoiceType) => {
|
||||
const { data } = await axios.patch(`/admin/invoice/${id}`, params);
|
||||
return data;
|
||||
|
||||
@@ -97,6 +97,10 @@ export type InvoiceItemType = {
|
||||
confirmedAt: string | null;
|
||||
};
|
||||
|
||||
export type InvoiceItemDetailType = Omit<InvoiceItemType, 'invoice'> & {
|
||||
invoice: Pick<InvoiceType, 'id' | 'invoiceNumber' | 'user'>;
|
||||
};
|
||||
|
||||
export type InvoiceType = {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
|
||||
Reference in New Issue
Block a user