chats kept
This commit is contained in:
@@ -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<InvoiceItemType, 'invoice'> & {
|
||||
invoice: Pick<InvoiceType, 'id' | 'invoiceNumber' | 'user'>;
|
||||
invoice: Pick<InvoiceType, 'id' | 'invoiceNumber' | 'user' | 'requestId'>;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
@@ -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 = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{invoiceItemId && (
|
||||
<div>
|
||||
<div
|
||||
className={`flex items-center gap-2 ${
|
||||
!hasLinkedRequest && !isInvoiceItemLoading
|
||||
? 'pointer-events-none opacity-50'
|
||||
: ''
|
||||
}`}
|
||||
>
|
||||
<Checkbox
|
||||
id="keepRequestChats"
|
||||
checked={formik.values.keepRequestChats}
|
||||
onCheckedChange={(checked) =>
|
||||
formik.setFieldValue('keepRequestChats', !!checked)
|
||||
}
|
||||
/>
|
||||
<label
|
||||
htmlFor="keepRequestChats"
|
||||
className="cursor-pointer select-none text-[13px]"
|
||||
>
|
||||
انتقال چتهای درخواست به سفارش
|
||||
</label>
|
||||
</div>
|
||||
{!hasLinkedRequest && !isInvoiceItemLoading && (
|
||||
<p className="mt-2 text-xs text-[#888888]">
|
||||
این پیشفاکتور به درخواستی متصل نیست.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<UploadBox
|
||||
label="پیوستها"
|
||||
|
||||
@@ -259,6 +259,7 @@ export type ConvertToOrderItemType = {
|
||||
description?: string;
|
||||
attachments: string[];
|
||||
designerId: string;
|
||||
keepRequestChats: boolean;
|
||||
};
|
||||
|
||||
export type OrderPrintFieldType = {
|
||||
|
||||
@@ -99,17 +99,6 @@ const RequestList: FC = () => {
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'invoices',
|
||||
title: 'فاکتورها',
|
||||
render: (item) => {
|
||||
return (
|
||||
<div className=' '>
|
||||
{item.invoices.length}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
title: '',
|
||||
|
||||
@@ -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<RequestType[]>;
|
||||
|
||||
Reference in New Issue
Block a user