feat:update-project
This commit is contained in:
@@ -41,6 +41,7 @@ import * as Popover from "@radix-ui/react-popover";
|
||||
import clsx from "clsx";
|
||||
import TabNavLink from "@/components/customs/custom-tabs";
|
||||
import { removeVietnameseTones } from "@/common/funcs/optionConvert";
|
||||
import useSpecialtyTabs from "@/hooks/useSpecialtyTabs";
|
||||
|
||||
const MainPageConsultation = () => {
|
||||
const router = useRouter();
|
||||
@@ -98,6 +99,10 @@ const MainPageConsultation = () => {
|
||||
},
|
||||
});
|
||||
|
||||
const { tabs: specialtyTabs } = useSpecialtyTabs(
|
||||
consultationQuery.data?.items ?? [],
|
||||
);
|
||||
|
||||
const specialtyQuery = useQuery({
|
||||
queryKey: [QUERY_KEY.list_specialty_lookup],
|
||||
queryFn: async () => {
|
||||
@@ -183,30 +188,30 @@ const MainPageConsultation = () => {
|
||||
|
||||
const consultation = consultationQuery.data;
|
||||
|
||||
const specialtyTabs = useMemo(() => {
|
||||
const specialtyMap = new Map();
|
||||
// const specialtyTabs = useMemo(() => {
|
||||
// const specialtyMap = new Map();
|
||||
|
||||
consultation?.items?.forEach((consultationItem) => {
|
||||
consultationItem.specialtyClinics?.forEach((specialty) => {
|
||||
if (!specialtyMap.has(specialty.specialtyId)) {
|
||||
specialtyMap.set(specialty.specialtyId, {
|
||||
pathname: "/consultation",
|
||||
query: specialty.specialtyId,
|
||||
title: specialty.specialtyName,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
// consultation?.items?.forEach((consultationItem) => {
|
||||
// consultationItem.specialtyClinics?.forEach((specialty) => {
|
||||
// if (!specialtyMap.has(specialty.specialtyId)) {
|
||||
// specialtyMap.set(specialty.specialtyId, {
|
||||
// pathname: "/consultation",
|
||||
// query: specialty.specialtyId,
|
||||
// title: specialty.specialtyName,
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
return [
|
||||
{
|
||||
pathname: "/consultation",
|
||||
query: "all",
|
||||
title: "Tất cả",
|
||||
},
|
||||
...Array.from(specialtyMap.values()),
|
||||
];
|
||||
}, [consultation?.items]);
|
||||
// return [
|
||||
// {
|
||||
// pathname: "/consultation",
|
||||
// query: "all",
|
||||
// title: "Tất cả",
|
||||
// },
|
||||
// ...Array.from(specialtyMap.values()),
|
||||
// ];
|
||||
// }, [consultation?.items]);
|
||||
|
||||
const handleOpenCancel = (item: ConsultationItem) => {
|
||||
setSelectedConsultationId(item.id);
|
||||
@@ -381,7 +386,6 @@ const MainPageConsultation = () => {
|
||||
column={[
|
||||
{
|
||||
title: "TÊN BỆNH NHÂN",
|
||||
|
||||
render: (item: ConsultationItem) => (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
@@ -393,9 +397,8 @@ const MainPageConsultation = () => {
|
||||
{item.patientName}
|
||||
</Link>
|
||||
</TooltipTrigger>
|
||||
|
||||
<TooltipContent>
|
||||
<p className="p-2 bg-gray-400 border rounded-full">
|
||||
<p className="rounded-full border bg-gray-400 p-2">
|
||||
Chi tiết bệnh nhân
|
||||
</p>
|
||||
</TooltipContent>
|
||||
@@ -427,7 +430,6 @@ const MainPageConsultation = () => {
|
||||
{item.sessionCode}
|
||||
</Link>
|
||||
</TooltipTrigger>
|
||||
|
||||
<TooltipContent>
|
||||
<p className="rounded-full border bg-gray-400 p-2">
|
||||
Chi tiết phiên khám
|
||||
@@ -450,41 +452,72 @@ const MainPageConsultation = () => {
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
// 🔴 ẨN "DẤU HIỆU" khi KHÔNG PHẢI Tab All (!isAllTab)
|
||||
isAllTab && {
|
||||
title: "DẤU HIỆU",
|
||||
|
||||
render: (item: ConsultationItem) => (
|
||||
<span>{item.symptomsText || "---"}</span>
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
title: "CHUẨN ĐOÁN",
|
||||
|
||||
render: (item: ConsultationItem) => (
|
||||
<span>{item.diagnosis || "---"}</span>
|
||||
),
|
||||
title: "CHẨN ĐOÁN",
|
||||
render: (item: ConsultationItem) => {
|
||||
if (!isAllTab) {
|
||||
const specialty = item.specialtyClinics.find(
|
||||
(x) => x.specialtyId === _type,
|
||||
);
|
||||
return <span>{specialty?.diagnosis || "---"}</span>;
|
||||
}
|
||||
return <span>{item.diagnosis || "---"}</span>;
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
title: "KẾ HOẠCH ĐIỀU TRỊ",
|
||||
// 🔴 ẨN "DẤU HIỆU" khi KHÔNG PHẢI Tab All (!isAllTab)
|
||||
// !isAllTab && {
|
||||
// title: "BÁC SĨ KHÁM",
|
||||
// render: (item: ConsultationItem) => {
|
||||
// const doctorNames = item.doctors?.join(", ");
|
||||
|
||||
// return <span>{doctorNames || "---"}</span>;
|
||||
// },
|
||||
// },
|
||||
|
||||
// 🔴 ẨN "KẾ HOẠCH ĐIỀU TRỊ" khi KHÔNG PHẢI Tab All (!isAllTab)
|
||||
isAllTab && {
|
||||
title: "KẾ HOẠCH ĐIỀU TRỊ",
|
||||
render: (item: ConsultationItem) => (
|
||||
<span>{item.treatmentPlan || "---"}</span>
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
title: "GHI CHÚ BÁC SĨ",
|
||||
|
||||
render: (item: ConsultationItem) => (
|
||||
<span>{item.doctorNotes || "---"}</span>
|
||||
),
|
||||
title: isAllTab ? "GHI CHÚ BÁC SĨ" : "GHI CHÚ KHÁM",
|
||||
render: (item: ConsultationItem) => {
|
||||
if (!isAllTab) {
|
||||
const specialty = item.specialtyClinics.find(
|
||||
(x) => x.specialtyId === _type,
|
||||
);
|
||||
return <span>{specialty?.specialtyNotes || "---"}</span>;
|
||||
}
|
||||
return <span>{item.doctorNotes || "---"}</span>;
|
||||
},
|
||||
},
|
||||
|
||||
// 🔴 ẨN "THỦ THUẬT" khi LÀ Tab All (isAllTab)
|
||||
!isAllTab && {
|
||||
title: "THỦ THUẬT",
|
||||
render: (item: ConsultationItem) => {
|
||||
const specialty = item.specialtyClinics.find(
|
||||
(x) => x.specialtyId === _type,
|
||||
);
|
||||
return <span>{specialty?.procedureNotes || "---"}</span>;
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
title: "TRẠNG THÁI",
|
||||
render: (item: ConsultationItem) => {
|
||||
// ===== TAB CHUYÊN KHOA =====
|
||||
if (!isAllTab) {
|
||||
const specialty = item.specialtyClinics.find(
|
||||
(x) => x.specialtyId === _type,
|
||||
@@ -517,7 +550,6 @@ const MainPageConsultation = () => {
|
||||
);
|
||||
}
|
||||
|
||||
// ===== TAB TẤT CẢ =====
|
||||
return (
|
||||
<StateActive
|
||||
stateActive={item.status}
|
||||
@@ -563,19 +595,15 @@ const MainPageConsultation = () => {
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
fixedRight: true,
|
||||
|
||||
title: "ACTION",
|
||||
|
||||
render: (item: ConsultationItem) => {
|
||||
const isCancelled = item.status === TYPE_STATUS.Cancelled;
|
||||
|
||||
const isCompleted = item.status === TYPE_STATUS.Completed;
|
||||
|
||||
const isDisabled = isCancelled || isCompleted;
|
||||
|
||||
// ===== TAB CHUYÊN KHOA =====
|
||||
if (!isAllTab) {
|
||||
const specialty = item.specialtyClinics.find(
|
||||
(x) => x.specialtyId === _type,
|
||||
@@ -599,14 +627,7 @@ const MainPageConsultation = () => {
|
||||
);
|
||||
}
|
||||
|
||||
// ===== TAB TẤT CẢ =====
|
||||
return (
|
||||
/*
|
||||
Chỉnh sửa tại đây:
|
||||
- flex-col: xếp dọc trên màn mobile
|
||||
- sm:flex-row: quay lại xếp ngang trên tablet / desktop (>= 640px)
|
||||
- w-full sm:w-auto: mở rộng full chiều rộng ô khi ở màn mobile cho cân đối
|
||||
*/
|
||||
<div className="flex flex-col sm:flex-row items-center justify-center gap-2 w-full sm:w-auto">
|
||||
<Popover.Root>
|
||||
<Popover.Trigger asChild>
|
||||
@@ -628,27 +649,14 @@ const MainPageConsultation = () => {
|
||||
side="bottom"
|
||||
align="end"
|
||||
sideOffset={8}
|
||||
className="
|
||||
z-50
|
||||
min-w-[300px]
|
||||
rounded-xl
|
||||
border
|
||||
bg-white
|
||||
p-2
|
||||
shadow-xl
|
||||
"
|
||||
className="z-50 min-w-[300px] rounded-xl border bg-white p-2 shadow-xl"
|
||||
>
|
||||
<div className="space-y-1">
|
||||
{item.specialtyClinics.map((specialty) => (
|
||||
<Link
|
||||
key={specialty.id}
|
||||
href={`/consultation/update-specialty?_id=${item.id}&specialtyClinicId=${specialty.id}`}
|
||||
className="
|
||||
flex items-center gap-2
|
||||
rounded-lg px-3 py-2
|
||||
text-sm
|
||||
hover:bg-blue-50
|
||||
"
|
||||
className="flex items-center gap-2 rounded-lg px-3 py-2 text-sm hover:bg-blue-50"
|
||||
>
|
||||
<Pencil size={15} />
|
||||
<span>{specialty.specialtyName}</span>
|
||||
@@ -682,7 +690,7 @@ const MainPageConsultation = () => {
|
||||
);
|
||||
},
|
||||
},
|
||||
]}
|
||||
].filter(Boolean)} // 💡 Lọc bỏ các giá trị false để ẩn cột
|
||||
/>
|
||||
</DataWrapper>
|
||||
<Pagination
|
||||
|
||||
Reference in New Issue
Block a user