chats kept
This commit is contained in:
@@ -58,15 +58,6 @@ export type InvoiceUserType = {
|
|||||||
phone: string;
|
phone: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type InvoiceRequestType = {
|
|
||||||
id: string;
|
|
||||||
createdAt: string;
|
|
||||||
deletedAt: string | null;
|
|
||||||
user: string;
|
|
||||||
requestNumber: number;
|
|
||||||
status: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type InvoiceProductType = {
|
export type InvoiceProductType = {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
@@ -98,7 +89,7 @@ export type InvoiceItemType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type InvoiceItemDetailType = Omit<InvoiceItemType, 'invoice'> & {
|
export type InvoiceItemDetailType = Omit<InvoiceItemType, 'invoice'> & {
|
||||||
invoice: Pick<InvoiceType, 'id' | 'invoiceNumber' | 'user'>;
|
invoice: Pick<InvoiceType, 'id' | 'invoiceNumber' | 'user' | 'requestId'>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type InvoiceType = {
|
export type InvoiceType = {
|
||||||
@@ -106,7 +97,7 @@ export type InvoiceType = {
|
|||||||
createdAt: string;
|
createdAt: string;
|
||||||
deletedAt: string | null;
|
deletedAt: string | null;
|
||||||
user: InvoiceUserType;
|
user: InvoiceUserType;
|
||||||
request: InvoiceRequestType;
|
requestId?: string | null;
|
||||||
invoiceNumber: number;
|
invoiceNumber: number;
|
||||||
discount: number;
|
discount: number;
|
||||||
subTotal: number;
|
subTotal: number;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { extractErrorMessage } from '@/config/func'
|
|||||||
import { useGetAdmins } from '../admin/hooks/useAdminData'
|
import { useGetAdmins } from '../admin/hooks/useAdminData'
|
||||||
import { useGetInvoiceItem } from '@/pages/invoice/hooks/useInvoiceData'
|
import { useGetInvoiceItem } from '@/pages/invoice/hooks/useInvoiceData'
|
||||||
import { formatItemDiscountDisplay } from '@/pages/invoice/utils/invoiceItem'
|
import { formatItemDiscountDisplay } from '@/pages/invoice/utils/invoiceItem'
|
||||||
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
|
|
||||||
const formatAmount = (amount: number) =>
|
const formatAmount = (amount: number) =>
|
||||||
Number(amount).toLocaleString('fa-IR') + ' ریال'
|
Number(amount).toLocaleString('fa-IR') + ' ریال'
|
||||||
@@ -32,7 +33,8 @@ const getInitialValues = (invoiceItemId: string | null): ConvertToOrderItemType
|
|||||||
title: '',
|
title: '',
|
||||||
description: '',
|
description: '',
|
||||||
attachments: [],
|
attachments: [],
|
||||||
designerId: ''
|
designerId: '',
|
||||||
|
keepRequestChats: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const getValidationSchema = (invoiceItemId: string | null) =>
|
const getValidationSchema = (invoiceItemId: string | null) =>
|
||||||
@@ -60,6 +62,7 @@ const ConvertToOrders: FC = () => {
|
|||||||
const { data: admins } = useGetAdmins(1, 50)
|
const { data: admins } = useGetAdmins(1, 50)
|
||||||
const { data: invoiceItemData, isLoading: isInvoiceItemLoading } = useGetInvoiceItem(invoiceItemId)
|
const { data: invoiceItemData, isLoading: isInvoiceItemLoading } = useGetInvoiceItem(invoiceItemId)
|
||||||
const invoiceItem = invoiceItemData?.data
|
const invoiceItem = invoiceItemData?.data
|
||||||
|
const hasLinkedRequest = Boolean(invoiceItem?.invoice?.requestId)
|
||||||
|
|
||||||
const { mutate: converToOrder, isPending } = useConverToOrder()
|
const { mutate: converToOrder, isPending } = useConverToOrder()
|
||||||
|
|
||||||
@@ -87,6 +90,7 @@ const ConvertToOrders: FC = () => {
|
|||||||
estimatedDays: Number(values.estimatedDays),
|
estimatedDays: Number(values.estimatedDays),
|
||||||
description: values.description || undefined,
|
description: values.description || undefined,
|
||||||
attachments,
|
attachments,
|
||||||
|
keepRequestChats: hasLinkedRequest ? values.keepRequestChats : false,
|
||||||
}
|
}
|
||||||
|
|
||||||
converToOrder(payload, {
|
converToOrder(payload, {
|
||||||
@@ -297,6 +301,37 @@ const ConvertToOrders: FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</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>
|
<div>
|
||||||
<UploadBox
|
<UploadBox
|
||||||
label="پیوستها"
|
label="پیوستها"
|
||||||
|
|||||||
@@ -259,6 +259,7 @@ export type ConvertToOrderItemType = {
|
|||||||
description?: string;
|
description?: string;
|
||||||
attachments: string[];
|
attachments: string[];
|
||||||
designerId: string;
|
designerId: string;
|
||||||
|
keepRequestChats: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type OrderPrintFieldType = {
|
export type OrderPrintFieldType = {
|
||||||
|
|||||||
@@ -99,17 +99,6 @@ const RequestList: FC = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'invoices',
|
|
||||||
title: 'فاکتورها',
|
|
||||||
render: (item) => {
|
|
||||||
return (
|
|
||||||
<div className=' '>
|
|
||||||
{item.invoices.length}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'actions',
|
key: 'actions',
|
||||||
title: '',
|
title: '',
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import type { InvoiceType } from "@/pages/invoice/types/Types";
|
|
||||||
import type { UserType } from "@/pages/order/types/Types";
|
import type { UserType } from "@/pages/order/types/Types";
|
||||||
import type { ProductType } from "@/pages/product/types/Types";
|
import type { ProductType } from "@/pages/product/types/Types";
|
||||||
import type { BaseResponse } from "@/shared/types/Types";
|
import type { BaseResponse } from "@/shared/types/Types";
|
||||||
@@ -31,7 +30,6 @@ export type RequestType = {
|
|||||||
user: UserType;
|
user: UserType;
|
||||||
requestNumber: number;
|
requestNumber: number;
|
||||||
items: RequestItemType[];
|
items: RequestItemType[];
|
||||||
invoices: InvoiceType[]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type RequestResponseType = BaseResponse<RequestType[]>;
|
export type RequestResponseType = BaseResponse<RequestType[]>;
|
||||||
|
|||||||
Reference in New Issue
Block a user