diff --git a/src/pages/invoice/types/Types.ts b/src/pages/invoice/types/Types.ts index a62609b..1f1d49b 100644 --- a/src/pages/invoice/types/Types.ts +++ b/src/pages/invoice/types/Types.ts @@ -58,15 +58,6 @@ export type InvoiceUserType = { phone: string; }; -export type InvoiceRequestType = { - id: string; - createdAt: string; - deletedAt: string | null; - user: string; - requestNumber: number; - status: string; -}; - export type InvoiceProductType = { id: string; createdAt: string; @@ -98,7 +89,7 @@ export type InvoiceItemType = { }; export type InvoiceItemDetailType = Omit & { - invoice: Pick; + invoice: Pick; }; export type InvoiceType = { @@ -106,7 +97,7 @@ export type InvoiceType = { createdAt: string; deletedAt: string | null; user: InvoiceUserType; - request: InvoiceRequestType; + requestId?: string | null; invoiceNumber: number; discount: number; subTotal: number; diff --git a/src/pages/order/ConvertToOrders.tsx b/src/pages/order/ConvertToOrders.tsx index 0766d91..d42ef9a 100644 --- a/src/pages/order/ConvertToOrders.tsx +++ b/src/pages/order/ConvertToOrders.tsx @@ -19,6 +19,7 @@ import { extractErrorMessage } from '@/config/func' import { useGetAdmins } from '../admin/hooks/useAdminData' import { useGetInvoiceItem } from '@/pages/invoice/hooks/useInvoiceData' import { formatItemDiscountDisplay } from '@/pages/invoice/utils/invoiceItem' +import { Checkbox } from '@/components/ui/checkbox' const formatAmount = (amount: number) => Number(amount).toLocaleString('fa-IR') + ' ریال' @@ -32,7 +33,8 @@ const getInitialValues = (invoiceItemId: string | null): ConvertToOrderItemType title: '', description: '', attachments: [], - designerId: '' + designerId: '', + keepRequestChats: true, }) const getValidationSchema = (invoiceItemId: string | null) => @@ -60,6 +62,7 @@ const ConvertToOrders: FC = () => { const { data: admins } = useGetAdmins(1, 50) const { data: invoiceItemData, isLoading: isInvoiceItemLoading } = useGetInvoiceItem(invoiceItemId) const invoiceItem = invoiceItemData?.data + const hasLinkedRequest = Boolean(invoiceItem?.invoice?.requestId) const { mutate: converToOrder, isPending } = useConverToOrder() @@ -87,6 +90,7 @@ const ConvertToOrders: FC = () => { estimatedDays: Number(values.estimatedDays), description: values.description || undefined, attachments, + keepRequestChats: hasLinkedRequest ? values.keepRequestChats : false, } converToOrder(payload, { @@ -297,6 +301,37 @@ const ConvertToOrders: FC = () => { /> + {invoiceItemId && ( +
+
+ + formik.setFieldValue('keepRequestChats', !!checked) + } + /> + +
+ {!hasLinkedRequest && !isInvoiceItemLoading && ( +

+ این پیش‌فاکتور به درخواستی متصل نیست. +

+ )} +
+ )} +
{ ) } }, - { - key: 'invoices', - title: 'فاکتورها', - render: (item) => { - return ( -
- {item.invoices.length} -
- ) - } - }, { key: 'actions', title: '', diff --git a/src/pages/requests/types/Types.ts b/src/pages/requests/types/Types.ts index 3fe8a53..674f5bd 100644 --- a/src/pages/requests/types/Types.ts +++ b/src/pages/requests/types/Types.ts @@ -1,4 +1,3 @@ -import type { InvoiceType } from "@/pages/invoice/types/Types"; import type { UserType } from "@/pages/order/types/Types"; import type { ProductType } from "@/pages/product/types/Types"; import type { BaseResponse } from "@/shared/types/Types"; @@ -31,7 +30,6 @@ export type RequestType = { user: UserType; requestNumber: number; items: RequestItemType[]; - invoices: InvoiceType[] }; export type RequestResponseType = BaseResponse;