From e656ad2e614ecb1cbf740ccedf985c3ee7eb16dd Mon Sep 17 00:00:00 2001 From: Samandar Turgunboyev Date: Mon, 8 Dec 2025 22:40:08 +0500 Subject: [PATCH] added pil name --- .../ui/SpecificationDetail .tsx | 84 +++++++++++-------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/src/features/specifications/ui/SpecificationDetail .tsx b/src/features/specifications/ui/SpecificationDetail .tsx index 396858e..a3df610 100644 --- a/src/features/specifications/ui/SpecificationDetail .tsx +++ b/src/features/specifications/ui/SpecificationDetail .tsx @@ -1,5 +1,6 @@ "use client"; +import { pill_api } from "@/features/pill/lib/api"; import type { OrderListDataRes } from "@/features/specifications/lib/data"; import formatPrice from "@/shared/lib/formatPrice"; import { Button } from "@/shared/ui/button"; @@ -9,6 +10,7 @@ import { DialogHeader, DialogTitle, } from "@/shared/ui/dialog"; +import { useQuery } from "@tanstack/react-query"; import { HardDriveDownloadIcon } from "lucide-react"; import type { Dispatch, SetStateAction } from "react"; @@ -23,6 +25,13 @@ export const SpecificationDetail = ({ open, setOpen, }: Props) => { + const { data } = useQuery({ + queryKey: ["pill_list"], + queryFn: () => pill_api.list({ limit: 999, offset: 1 }), + select(data) { + return data.data.data; + }, + }); const downloadFile = async (fileUrl: string, fileName: string) => { try { const response = await fetch(fileUrl, { @@ -107,45 +116,50 @@ export const SpecificationDetail = ({
- {specification.order_items.map((med, index) => ( -
-
-
-
- - #{index + 1} - -

- {med.product} + {specification.order_items.map((med, index) => { + const pill_name = data?.results.find( + (e) => e.id === med.product, + ); + return ( +

+
+
+
+ + #{index + 1} + +

+ {pill_name?.name} +

+
+
+ + Miqdor: {med.quantity} ta + + × + + Narx:{" "} + + {formatPrice( + Number(med.total_price) / med.quantity, + )} + + +
+
+
+

Jami

+

+ {formatPrice(med.total_price)}

-
- - Miqdor: {med.quantity} ta - - × - - Narx:{" "} - - {formatPrice( - Number(med.total_price) / med.quantity, - )} - - -
-
-
-

Jami

-

- {formatPrice(med.total_price)} -

-
- ))} + ); + })}