form of converet

This commit is contained in:
hamid zarghami
2026-02-21 16:42:23 +03:30
parent f2ebdc9836
commit 502e8c538f
6 changed files with 205 additions and 7 deletions
+7 -7
View File
@@ -132,13 +132,13 @@ const UpdateInvoice: FC = () => {
const mappedItems: CreatePreInvoiceItemType[] =
invoice.items?.length > 0
? invoice.items.map((i) => ({
id: i.id,
productId: i.product?.id ?? "",
quantity: i.quantity ?? 1,
unitPrice: i.unitPrice ?? 0,
discount: i.discount ?? 0,
description: i.description ?? "",
}))
id: i.id,
productId: i.product?.id ?? "",
quantity: i.quantity ?? 1,
unitPrice: i.unitPrice ?? 0,
discount: i.discount ?? 0,
description: i.description ?? "",
}))
: [createEmptyItem()];
setItems(mappedItems);
@@ -3,6 +3,8 @@ import Input from "@/components/Input";
import ProductsSelect from "@/pages/order/components/ProductsSelect";
import type { CreatePreInvoiceItemType } from "../types/Types";
import { Add, Trash } from "iconsax-react";
import { Link } from "react-router-dom";
import { Paths } from "@/config/Paths";
type Props = {
item: CreatePreInvoiceItemType;
index: number;
@@ -10,6 +12,7 @@ type Props = {
onAdd: () => void;
onRemove: () => void;
canRemove: boolean;
onConvertToOrder?: () => void;
error?: Partial<Record<keyof CreatePreInvoiceItemType, string>>;
};
@@ -20,6 +23,7 @@ const InvoiceItemRow: FC<Props> = ({
onAdd,
onRemove,
canRemove,
onConvertToOrder,
error,
}) => {
const total = (item.quantity || 0) * (item.unitPrice || 0) - (item.discount || 0);
@@ -30,6 +34,7 @@ const InvoiceItemRow: FC<Props> = ({
return (
<div className="flex flex-wrap items-end gap-4 mt-6">
<div className="min-w-[140px] flex-1">
<ProductsSelect
value={item.productId}
@@ -117,6 +122,17 @@ const InvoiceItemRow: FC<Props> = ({
<Trash size={18} color="#dc2626" />
</button>
)}
{item.id && (
<Link to={Paths.convertToOrder + '/' + item.id}>
<button
type="button"
onClick={onConvertToOrder}
className="h-10 px-4 rounded-xl border border-primary text-primary text-sm hover:bg-primary/5 transition-colors flex-shrink-0"
>
تبدیل به سفارش
</button>
</Link>
)}
</div>
</div>
);