From bad85246466890e208417bfdc6584b136420f28f Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Tue, 18 Jun 2024 20:11:25 +0530 Subject: [PATCH 1/2] Changed Doctors Log to progress notes (#8039) * Changed Doctors Log to progress notes * Update src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx --------- Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> --- .../Consultations/DailyRounds/LogUpdateCardAttribute.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx b/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx index 4e5b7408266..5d407a09fea 100644 --- a/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx +++ b/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx @@ -69,7 +69,9 @@ const LogUpdateCardAttribute = ({ {(attributeValue as string) === "VENTILATOR" ? "CRITICAL CARE" - : (attributeValue as string)} + : (attributeValue as string) === "DOCTORS_LOG" + ? "PROGRESS NOTE" + : (attributeValue as string)} ); From 6e7679e24322056ab56339dedbb9a4afba79d9aa Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Tue, 18 Jun 2024 21:43:46 +0530 Subject: [PATCH 2/2] Fixes pagination for shifting board (#8041) * fix pagination * minor change --- src/Components/Shifting/ShiftingBoard.tsx | 71 +++++++++-------------- 1 file changed, 26 insertions(+), 45 deletions(-) diff --git a/src/Components/Shifting/ShiftingBoard.tsx b/src/Components/Shifting/ShiftingBoard.tsx index 3203b5027f5..84a4ac419d3 100644 --- a/src/Components/Shifting/ShiftingBoard.tsx +++ b/src/Components/Shifting/ShiftingBoard.tsx @@ -39,17 +39,6 @@ interface boardProps { containerHeight: number; } -const reduceLoading = (action: string, current: any) => { - switch (action) { - case "MORE": - return { ...current, more: true }; - case "BOARD": - return { ...current, board: true }; - case "COMPLETE": - return { board: false, more: false }; - } -}; - const ShiftCard = ({ shift, filter }: any) => { const { wartime_shifting } = useConfig(); const [modalFor, setModalFor] = useState({ @@ -268,7 +257,8 @@ export default function ShiftingBoard({ }: boardProps) { const containerRef = useRef(null); const [offset, setOffSet] = useState(0); - const [isLoading, setIsLoading] = useState({ board: "BOARD", more: false }); + const [pages, setPages] = useState[]>([]); + const [isLoading, setIsLoading] = useState(true); const [{ isOver }, drop] = useDrop(() => ({ accept: "shift-card", drop: (item: any) => { @@ -278,23 +268,24 @@ export default function ShiftingBoard({ }, collect: (monitor) => ({ isOver: !!monitor.isOver() }), })); - const [data, setData] = useState>(); - useQuery(routes.listShiftRequests, { + const query = useQuery(routes.listShiftRequests, { query: formatFilter({ ...filterProp, status: board, }), onResponse: ({ res, data: listShiftData }) => { + setIsLoading(false); if (res?.ok && listShiftData) { - setData(listShiftData); + setPages((prev) => [...prev, listShiftData]); } - setIsLoading((loading) => reduceLoading("COMPLETE", loading)); }, }); useEffect(() => { - setIsLoading((loading) => reduceLoading("BOARD", loading)); + setPages([]); + setIsLoading(true); + query.refetch(); }, [ filterProp.facility, filterProp.origin_facility, @@ -316,7 +307,7 @@ export default function ShiftingBoard({ ]); const handlePagination = async () => { - setIsLoading((loading) => reduceLoading("MORE", loading)); + setIsLoading(true); setOffSet(offset + 14); const { res, data: newPageData } = await request(routes.listShiftRequests, { query: formatFilter({ @@ -326,18 +317,15 @@ export default function ShiftingBoard({ }), }); if (res?.ok && newPageData) { - setData((prev) => - prev - ? { ...prev, results: [...prev.results, ...newPageData.results] } - : newPageData, - ); + setPages((prev) => [...prev, newPageData]); } - setIsLoading((loading) => reduceLoading("COMPLETE", loading)); + setIsLoading(false); }; const { t } = useTranslation(); const patientFilter = (filter: string) => { - return data?.results + return pages + .flatMap((p) => p.results) .filter(({ status }) => status === filter) .map((shift: any) => ( @@ -350,7 +338,7 @@ export default function ShiftingBoard({ const { height } = container.getBoundingClientRect(); containerHeight < height && setContainerHeight(height); } - }, [containerRef.current, data?.results.length]); + }, [containerRef.current, pages.flatMap((p) => p.results).length]); return (
- {data?.count || "0"} + {pages[0] ? pages[0].count : "..."}
- {isLoading.board ? ( + {pages[0]?.count > 0 + ? patientFilter(board) + : !isLoading && ( +

{t("no_patients_to_show")}

+ )} + {isLoading ? (
@@ -395,25 +388,13 @@ export default function ShiftingBoard({
- ) : data?.count ?? 0 > 0 ? ( - patientFilter(board) ) : ( -

{t("no_patients_to_show")}

+ pages.at(-1)?.next && ( + handlePagination()} className="m-2 block"> + Load More + + ) )} - {!isLoading.board && - (data?.count ?? 0) < (data?.results.length || 0) && - (isLoading.more ? ( -
- {t("loading")} -
- ) : ( - - ))}
);