From d8d5bd95cbc24962bd007c5891096c20283df409 Mon Sep 17 00:00:00 2001 From: vsvishalsharma Date: Sat, 4 Jan 2025 12:28:46 +0530 Subject: [PATCH 1/8] Add the In Progress Filter to Pathology Dashboard --- .../pathology/PathologyDashboard.js | 60 +++++++++++-------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/frontend/src/components/pathology/PathologyDashboard.js b/frontend/src/components/pathology/PathologyDashboard.js index 11489b31ef..51a680b6dd 100644 --- a/frontend/src/components/pathology/PathologyDashboard.js +++ b/frontend/src/components/pathology/PathologyDashboard.js @@ -49,11 +49,12 @@ function PathologyDashboard() { searchTerm: "", myCases: false, statuses: [ - { - id: "GROSSING", - value: "Grossing", - }, - ], + {id: 'GROSSING'}, + {id: 'CUTTING'}, + {id: 'PROCESSING'}, + {id: 'SLICING'}, + {id: 'STAINING'} + ] }); const [counts, setCounts] = useState({ inProgress: 0, @@ -155,11 +156,21 @@ function PathologyDashboard() { const setStatusFilter = (event) => { if (event.target.value === "All") { setFilters({ ...filters, statuses: statuses }); + } else if (event.target.value === "IN_PROGRESS") { + setFilters({ + ...filters, + statuses: [ + {id: 'GROSSING'}, + {id: 'CUTTING'}, + {id: 'PROCESSING'}, + {id: 'SLICING'}, + {id: 'STAINING'} + ] + }); } else { setFilters({ ...filters, statuses: [{ id: event.target.value }] }); } }; - const filtersToParameters = () => { return ( "statuses=" + @@ -252,16 +263,12 @@ function PathologyDashboard() { useEffect(() => { componentMounted.current = true; + const inProgressStatuses = ['GROSSING', 'CUTTING', 'PROCESSING', 'SLICING', 'STAINING'].map(id => ({id})); setFilters({ ...filters, - statuses: [ - { - id: "GROSSING", - value: "Grossing", - }, - ], + statuses: inProgressStatuses }); - + return () => { componentMounted.current = false; }; @@ -334,24 +341,29 @@ function PathologyDashboard() { id="statusFilter" name="statusFilter" labelText={intl.formatMessage({ id: "label.filters.status" })} - defaultValue="placeholder" value={ - filters.statuses.length > 1 ? "All" : filters.statuses[0].id + filters.statuses.length === 5 && + filters.statuses.every(status => + ['GROSSING', 'CUTTING', 'PROCESSING', 'SLICING', 'STAINING'].includes(status.id) + ) + ? "IN_PROGRESS" + : filters.statuses.length > 1 + ? "All" + : filters.statuses[0].id } onChange={setStatusFilter} noLabel > - {statuses.map((status, index) => { - return ( - - ); - })} + + {statuses.map((status, index) => ( + + ))} From 056fb24ecf38f169f03726995886be1e5f76e76c Mon Sep 17 00:00:00 2001 From: vsvishalsharma Date: Sat, 4 Jan 2025 12:45:41 +0530 Subject: [PATCH 2/8] Ran format command --- .../pathology/PathologyDashboard.js | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/frontend/src/components/pathology/PathologyDashboard.js b/frontend/src/components/pathology/PathologyDashboard.js index 51a680b6dd..0e7e01f5f1 100644 --- a/frontend/src/components/pathology/PathologyDashboard.js +++ b/frontend/src/components/pathology/PathologyDashboard.js @@ -49,12 +49,12 @@ function PathologyDashboard() { searchTerm: "", myCases: false, statuses: [ - {id: 'GROSSING'}, - {id: 'CUTTING'}, - {id: 'PROCESSING'}, - {id: 'SLICING'}, - {id: 'STAINING'} - ] + { id: "GROSSING" }, + { id: "CUTTING" }, + { id: "PROCESSING" }, + { id: "SLICING" }, + { id: "STAINING" }, + ], }); const [counts, setCounts] = useState({ inProgress: 0, @@ -160,12 +160,12 @@ function PathologyDashboard() { setFilters({ ...filters, statuses: [ - {id: 'GROSSING'}, - {id: 'CUTTING'}, - {id: 'PROCESSING'}, - {id: 'SLICING'}, - {id: 'STAINING'} - ] + { id: "GROSSING" }, + { id: "CUTTING" }, + { id: "PROCESSING" }, + { id: "SLICING" }, + { id: "STAINING" }, + ], }); } else { setFilters({ ...filters, statuses: [{ id: event.target.value }] }); @@ -263,12 +263,18 @@ function PathologyDashboard() { useEffect(() => { componentMounted.current = true; - const inProgressStatuses = ['GROSSING', 'CUTTING', 'PROCESSING', 'SLICING', 'STAINING'].map(id => ({id})); + const inProgressStatuses = [ + "GROSSING", + "CUTTING", + "PROCESSING", + "SLICING", + "STAINING", + ].map((id) => ({ id })); setFilters({ ...filters, - statuses: inProgressStatuses + statuses: inProgressStatuses, }); - + return () => { componentMounted.current = false; }; @@ -343,13 +349,19 @@ function PathologyDashboard() { labelText={intl.formatMessage({ id: "label.filters.status" })} value={ filters.statuses.length === 5 && - filters.statuses.every(status => - ['GROSSING', 'CUTTING', 'PROCESSING', 'SLICING', 'STAINING'].includes(status.id) + filters.statuses.every((status) => + [ + "GROSSING", + "CUTTING", + "PROCESSING", + "SLICING", + "STAINING", + ].includes(status.id), ) ? "IN_PROGRESS" - : filters.statuses.length > 1 - ? "All" - : filters.statuses[0].id + : filters.statuses.length > 1 + ? "All" + : filters.statuses[0].id } onChange={setStatusFilter} noLabel From 7754a9fbc0caf9d903b430ccf727c339b2de7a3d Mon Sep 17 00:00:00 2001 From: vsvishalsharma Date: Mon, 6 Jan 2025 14:01:32 +0530 Subject: [PATCH 3/8] added filter to cytology --- .../components/cytology/CytologyDashBoard.js | 60 ++++++++++++------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/frontend/src/components/cytology/CytologyDashBoard.js b/frontend/src/components/cytology/CytologyDashBoard.js index 38d87f4fa9..6f7b2526fe 100644 --- a/frontend/src/components/cytology/CytologyDashBoard.js +++ b/frontend/src/components/cytology/CytologyDashBoard.js @@ -44,10 +44,9 @@ function CytologyDashboard() { searchTerm: "", myCases: false, statuses: [ - { - id: "PREPARING_SLIDES", - value: "Preparing slides", - }, + { id: "PREPARING_SLIDES" }, + { id: "SCREENING" }, + { id: "QUALITY_CONTROL" }, ], }); const [counts, setCounts] = useState({ @@ -151,11 +150,19 @@ function CytologyDashboard() { const setStatusFilter = (event) => { if (event.target.value === "All") { setFilters({ ...filters, statuses: statuses }); + } else if (event.target.value === "IN_PROGRESS") { + setFilters({ + ...filters, + statuses: [ + { id: "PREPARING_SLIDES" }, + { id: "SCREENING" }, + { id: "QUALITY_CONTROL" }, + ], + }); } else { setFilters({ ...filters, statuses: [{ id: event.target.value }] }); } }; - const filtersToParameters = () => { return ( "statuses=" + @@ -244,14 +251,14 @@ function CytologyDashboard() { useEffect(() => { componentMounted.current = true; + const inProgressStatuses = [ + { id: "PREPARING_SLIDES" }, + { id: "SCREENING" }, + { id: "QUALITY_CONTROL" }, + ]; setFilters({ ...filters, - statuses: [ - { - id: "PREPARING_SLIDES", - value: "Preparing slides", - }, - ], + statuses: inProgressStatuses, }); return () => { @@ -330,7 +337,18 @@ function CytologyDashboard() { name="statusFilter" labelText={intl.formatMessage({ id: "label.filters.status" })} value={ - filters.statuses.length > 1 ? "All" : filters.statuses[0].id + filters.statuses.length === 3 && + filters.statuses.every((status) => + [ + "PREPARING_SLIDES", + "SCREENING", + "QUALITY_CONTROL", + ].includes(status.id), + ) + ? "IN_PROGRESS" + : filters.statuses.length > 1 + ? "All" + : filters.statuses[0].id } onChange={setStatusFilter} noLabel @@ -344,15 +362,15 @@ function CytologyDashboard() { text={intl.formatMessage({ id: "all.label" })} value="All" /> - {statuses.map((status, index) => { - return ( - - ); - })} + + {/* Hardcoded "In Progress" */} + {statuses.map((status, index) => ( + + ))} From e340544042bf891ff1223cd27be725fd6864e8eb Mon Sep 17 00:00:00 2001 From: vsvishalsharma Date: Tue, 7 Jan 2025 15:45:13 +0530 Subject: [PATCH 4/8] update the statuses to be include in In progress --- .../pathology/PathologyDashboard.js | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/pathology/PathologyDashboard.js b/frontend/src/components/pathology/PathologyDashboard.js index 0e7e01f5f1..c2e81fe131 100644 --- a/frontend/src/components/pathology/PathologyDashboard.js +++ b/frontend/src/components/pathology/PathologyDashboard.js @@ -49,11 +49,13 @@ function PathologyDashboard() { searchTerm: "", myCases: false, statuses: [ - { id: "GROSSING" }, - { id: "CUTTING" }, - { id: "PROCESSING" }, - { id: "SLICING" }, - { id: "STAINING" }, + { id: "GROSSING", value: "Grossing" }, + { id: "CUTTING", value: "Cutting" }, + { id: "PROCESSING", value: "Processing" }, + { id: "SLICING", value: "Slicing for Slides" }, + { id: "STAINING", value: "Staining" }, + { id: "READY_PATHOLOGIST", value: "Ready for Pathologist" }, + { id: "ADDITIONAL_REQUEST", value: "Additional Pathologist Request" }, ], }); const [counts, setCounts] = useState({ @@ -165,6 +167,8 @@ function PathologyDashboard() { { id: "PROCESSING" }, { id: "SLICING" }, { id: "STAINING" }, + { id: "READY_PATHOLOGIST" }, + { id: "ADDITIONAL_REQUEST" }, ], }); } else { @@ -269,6 +273,8 @@ function PathologyDashboard() { "PROCESSING", "SLICING", "STAINING", + "READY_PATHOLOGIST", + "ADDITIONAL_REQUEST", ].map((id) => ({ id })); setFilters({ ...filters, @@ -348,7 +354,7 @@ function PathologyDashboard() { name="statusFilter" labelText={intl.formatMessage({ id: "label.filters.status" })} value={ - filters.statuses.length === 5 && + filters.statuses.length === 7 && // Updated from 5 to 7 filters.statuses.every((status) => [ "GROSSING", @@ -356,6 +362,8 @@ function PathologyDashboard() { "PROCESSING", "SLICING", "STAINING", + "READY_PATHOLOGIST", + "ADDITIONAL_REQUEST", ].includes(status.id), ) ? "IN_PROGRESS" From 6a005a25db7a3d9733c0e6dcc67d1355d3e54b27 Mon Sep 17 00:00:00 2001 From: vsvishalsharma Date: Thu, 16 Jan 2025 17:43:40 +0530 Subject: [PATCH 5/8] Corrected the Statuses in Cytology --- frontend/src/components/cytology/CytologyDashBoard.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/cytology/CytologyDashBoard.js b/frontend/src/components/cytology/CytologyDashBoard.js index 6f7b2526fe..1a675c5c0c 100644 --- a/frontend/src/components/cytology/CytologyDashBoard.js +++ b/frontend/src/components/cytology/CytologyDashBoard.js @@ -46,7 +46,7 @@ function CytologyDashboard() { statuses: [ { id: "PREPARING_SLIDES" }, { id: "SCREENING" }, - { id: "QUALITY_CONTROL" }, + { id: "READY_FOR_CYTOPATHOLOGIST" }, ], }); const [counts, setCounts] = useState({ @@ -61,6 +61,7 @@ function CytologyDashboard() { const setStatusList = (statusList) => { if (componentMounted.current) { + console.log('All available statuses:', statusList); setStatuses(statusList); } }; @@ -156,7 +157,7 @@ function CytologyDashboard() { statuses: [ { id: "PREPARING_SLIDES" }, { id: "SCREENING" }, - { id: "QUALITY_CONTROL" }, + { id: "READY_FOR_CYTOPATHOLOGIST" }, ], }); } else { @@ -254,7 +255,7 @@ function CytologyDashboard() { const inProgressStatuses = [ { id: "PREPARING_SLIDES" }, { id: "SCREENING" }, - { id: "QUALITY_CONTROL" }, + { id: "READY_FOR_CYTOPATHOLOGIST" }, ]; setFilters({ ...filters, @@ -342,7 +343,7 @@ function CytologyDashboard() { [ "PREPARING_SLIDES", "SCREENING", - "QUALITY_CONTROL", + "READY_FOR_CYTOPATHOLOGIST" , ].includes(status.id), ) ? "IN_PROGRESS" From 35528614704ddade38bda65bc0312d5527a6f1fd Mon Sep 17 00:00:00 2001 From: vsvishalsharma Date: Thu, 16 Jan 2025 18:45:27 +0530 Subject: [PATCH 6/8] Ran format command --- frontend/src/components/cytology/CytologyDashBoard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/cytology/CytologyDashBoard.js b/frontend/src/components/cytology/CytologyDashBoard.js index 1a675c5c0c..5d498063b7 100644 --- a/frontend/src/components/cytology/CytologyDashBoard.js +++ b/frontend/src/components/cytology/CytologyDashBoard.js @@ -61,7 +61,7 @@ function CytologyDashboard() { const setStatusList = (statusList) => { if (componentMounted.current) { - console.log('All available statuses:', statusList); + console.log("All available statuses:", statusList); setStatuses(statusList); } }; @@ -343,7 +343,7 @@ function CytologyDashboard() { [ "PREPARING_SLIDES", "SCREENING", - "READY_FOR_CYTOPATHOLOGIST" , + "READY_FOR_CYTOPATHOLOGIST", ].includes(status.id), ) ? "IN_PROGRESS" From dbacaa12c3f943aa4c44dd4cbe567e367d3973e3 Mon Sep 17 00:00:00 2001 From: vsvishalsharma Date: Fri, 17 Jan 2025 13:13:29 +0530 Subject: [PATCH 7/8] Remove the hardcoded statuses --- .../components/cytology/CytologyDashBoard.js | 97 +++++++---------- .../pathology/PathologyDashboard.js | 100 +++++++----------- 2 files changed, 81 insertions(+), 116 deletions(-) diff --git a/frontend/src/components/cytology/CytologyDashBoard.js b/frontend/src/components/cytology/CytologyDashBoard.js index 5d498063b7..d6190609e8 100644 --- a/frontend/src/components/cytology/CytologyDashBoard.js +++ b/frontend/src/components/cytology/CytologyDashBoard.js @@ -43,12 +43,10 @@ function CytologyDashboard() { const [filters, setFilters] = useState({ searchTerm: "", myCases: false, - statuses: [ - { id: "PREPARING_SLIDES" }, - { id: "SCREENING" }, - { id: "READY_FOR_CYTOPATHOLOGIST" }, - ], + statuses: [{ id: "PREPARING_SLIDES" }], }); + const [inProgressStatuses, setInProgressStatuses] = useState([]); + const [counts, setCounts] = useState({ inProgress: 0, awaitingReview: 0, @@ -61,11 +59,24 @@ function CytologyDashboard() { const setStatusList = (statusList) => { if (componentMounted.current) { - console.log("All available statuses:", statusList); setStatuses(statusList); + + // Create in-progress statuses by filtering out COMPLETED + const filteredStatuses = statusList + .filter((status) => status.id !== "COMPLETED") + .map((status) => status.id); + setInProgressStatuses(filteredStatuses); + + // Set initial filter to in-progress + const inProgressStatusObjects = filteredStatuses.map((statusId) => ({ + id: statusId, + })); + setFilters((prev) => ({ + ...prev, + statuses: inProgressStatusObjects, + })); } }; - const assignCurrentUserAsTechnician = (event, pathologySampleId) => { postToOpenElisServerFullResponse( "/rest/cytology/assignTechnician?cytologySampleId=" + pathologySampleId, @@ -152,18 +163,30 @@ function CytologyDashboard() { if (event.target.value === "All") { setFilters({ ...filters, statuses: statuses }); } else if (event.target.value === "IN_PROGRESS") { - setFilters({ - ...filters, - statuses: [ - { id: "PREPARING_SLIDES" }, - { id: "SCREENING" }, - { id: "READY_FOR_CYTOPATHOLOGIST" }, - ], - }); + const inProgressStatusObjects = inProgressStatuses.map((statusId) => ({ + id: statusId, + })); + setFilters({ ...filters, statuses: inProgressStatusObjects }); } else { setFilters({ ...filters, statuses: [{ id: event.target.value }] }); } }; + + const getSelectedValue = () => { + const selectedValue = + filters.statuses.length === inProgressStatuses.length && + filters.statuses.every((status) => inProgressStatuses.includes(status.id)) + ? "IN_PROGRESS" + : filters.statuses.length > 1 + ? "All" + : filters.statuses[0].id; + + //console.log("Current selected value:", selectedValue); + //console.log("Current filters.statuses:", filters.statuses); + //console.log("Current inProgressStatuses:", inProgressStatuses); + + return selectedValue; + }; const filtersToParameters = () => { return ( "statuses=" + @@ -250,23 +273,6 @@ function CytologyDashboard() { }, ]; - useEffect(() => { - componentMounted.current = true; - const inProgressStatuses = [ - { id: "PREPARING_SLIDES" }, - { id: "SCREENING" }, - { id: "READY_FOR_CYTOPATHOLOGIST" }, - ]; - setFilters({ - ...filters, - statuses: inProgressStatuses, - }); - - return () => { - componentMounted.current = false; - }; - }, [statuses]); - useEffect(() => { componentMounted.current = true; refreshItems(); @@ -337,34 +343,13 @@ function CytologyDashboard() { id="statusFilter" name="statusFilter" labelText={intl.formatMessage({ id: "label.filters.status" })} - value={ - filters.statuses.length === 3 && - filters.statuses.every((status) => - [ - "PREPARING_SLIDES", - "SCREENING", - "READY_FOR_CYTOPATHOLOGIST", - ].includes(status.id), - ) - ? "IN_PROGRESS" - : filters.statuses.length > 1 - ? "All" - : filters.statuses[0].id - } + value={getSelectedValue()} onChange={setStatusFilter} noLabel > - - + + - {/* Hardcoded "In Progress" */} {statuses.map((status, index) => ( { if (componentMounted.current) { setStatuses(statusList); + + // Create in-progress statuses by filtering out COMPLETED + const filteredStatuses = statusList + .filter((status) => status.id !== "COMPLETED") + .map((status) => status.id); + setInProgressStatuses(filteredStatuses); + + // Set initial filter to in-progress + const inProgressStatusObjects = filteredStatuses.map((statusId) => ({ + id: statusId, + })); + setFilters((prev) => ({ + ...prev, + statuses: inProgressStatusObjects, + })); } }; @@ -159,22 +169,30 @@ function PathologyDashboard() { if (event.target.value === "All") { setFilters({ ...filters, statuses: statuses }); } else if (event.target.value === "IN_PROGRESS") { - setFilters({ - ...filters, - statuses: [ - { id: "GROSSING" }, - { id: "CUTTING" }, - { id: "PROCESSING" }, - { id: "SLICING" }, - { id: "STAINING" }, - { id: "READY_PATHOLOGIST" }, - { id: "ADDITIONAL_REQUEST" }, - ], - }); + const inProgressStatusObjects = inProgressStatuses.map((statusId) => ({ + id: statusId, + })); + setFilters({ ...filters, statuses: inProgressStatusObjects }); } else { setFilters({ ...filters, statuses: [{ id: event.target.value }] }); } }; + const getSelectedValue = () => { + const selectedValue = + filters.statuses.length === inProgressStatuses.length && + filters.statuses.every((status) => inProgressStatuses.includes(status.id)) + ? "IN_PROGRESS" + : filters.statuses.length > 1 + ? "All" + : filters.statuses[0].id; + + //console.log("Current selected value:", selectedValue); + //console.log("Current filters.statuses:", filters.statuses); + //console.log("Current inProgressStatuses:", inProgressStatuses); + + return selectedValue; + }; + const filtersToParameters = () => { return ( "statuses=" + @@ -265,27 +283,6 @@ function PathologyDashboard() { }, ]; - useEffect(() => { - componentMounted.current = true; - const inProgressStatuses = [ - "GROSSING", - "CUTTING", - "PROCESSING", - "SLICING", - "STAINING", - "READY_PATHOLOGIST", - "ADDITIONAL_REQUEST", - ].map((id) => ({ id })); - setFilters({ - ...filters, - statuses: inProgressStatuses, - }); - - return () => { - componentMounted.current = false; - }; - }, [statuses]); - useEffect(() => { componentMounted.current = true; refreshItems(); @@ -353,24 +350,7 @@ function PathologyDashboard() { id="statusFilter" name="statusFilter" labelText={intl.formatMessage({ id: "label.filters.status" })} - value={ - filters.statuses.length === 7 && // Updated from 5 to 7 - filters.statuses.every((status) => - [ - "GROSSING", - "CUTTING", - "PROCESSING", - "SLICING", - "STAINING", - "READY_PATHOLOGIST", - "ADDITIONAL_REQUEST", - ].includes(status.id), - ) - ? "IN_PROGRESS" - : filters.statuses.length > 1 - ? "All" - : filters.statuses[0].id - } + value={getSelectedValue()} onChange={setStatusFilter} noLabel > From f58443f6d4d66b6cf808f30aa785e8f64cdba778 Mon Sep 17 00:00:00 2001 From: vsvishalsharma Date: Fri, 17 Jan 2025 14:19:39 +0530 Subject: [PATCH 8/8] Implement Changes --- .../components/cytology/CytologyDashBoard.js | 39 ++++++++++--------- .../pathology/PathologyDashboard.js | 38 +++++++++--------- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/frontend/src/components/cytology/CytologyDashBoard.js b/frontend/src/components/cytology/CytologyDashBoard.js index d6190609e8..00d0097908 100644 --- a/frontend/src/components/cytology/CytologyDashBoard.js +++ b/frontend/src/components/cytology/CytologyDashBoard.js @@ -43,7 +43,7 @@ function CytologyDashboard() { const [filters, setFilters] = useState({ searchTerm: "", myCases: false, - statuses: [{ id: "PREPARING_SLIDES" }], + statuses: [{}], }); const [inProgressStatuses, setInProgressStatuses] = useState([]); @@ -56,27 +56,34 @@ function CytologyDashboard() { const [page, setPage] = useState(1); const [pageSize, setPageSize] = useState(100); const intl = useIntl(); - + const [inProgressStatusObjects, setInProgressStatusObjects] = useState( + inProgressStatuses.map((statusId) => ({ id: statusId })), + ); const setStatusList = (statusList) => { if (componentMounted.current) { + // Set all statuses setStatuses(statusList); - // Create in-progress statuses by filtering out COMPLETED + // Filter out COMPLETED statuses and update the in-progress statuses state const filteredStatuses = statusList .filter((status) => status.id !== "COMPLETED") .map((status) => status.id); + setInProgressStatuses(filteredStatuses); - // Set initial filter to in-progress - const inProgressStatusObjects = filteredStatuses.map((statusId) => ({ - id: statusId, - })); + // Update the inProgressStatusObjects state + setInProgressStatusObjects( + filteredStatuses.map((statusId) => ({ id: statusId })), + ); + + // Set filters using the updated state setFilters((prev) => ({ ...prev, - statuses: inProgressStatusObjects, + statuses: filteredStatuses.map((statusId) => ({ id: statusId })), })); } }; + const assignCurrentUserAsTechnician = (event, pathologySampleId) => { postToOpenElisServerFullResponse( "/rest/cytology/assignTechnician?cytologySampleId=" + pathologySampleId, @@ -160,15 +167,14 @@ function CytologyDashboard() { }; const setStatusFilter = (event) => { - if (event.target.value === "All") { + const { value } = event.target; + + if (value === "All") { setFilters({ ...filters, statuses: statuses }); - } else if (event.target.value === "IN_PROGRESS") { - const inProgressStatusObjects = inProgressStatuses.map((statusId) => ({ - id: statusId, - })); + } else if (value === "IN_PROGRESS") { setFilters({ ...filters, statuses: inProgressStatusObjects }); } else { - setFilters({ ...filters, statuses: [{ id: event.target.value }] }); + setFilters({ ...filters, statuses: [{ id: value }] }); } }; @@ -181,12 +187,9 @@ function CytologyDashboard() { ? "All" : filters.statuses[0].id; - //console.log("Current selected value:", selectedValue); - //console.log("Current filters.statuses:", filters.statuses); - //console.log("Current inProgressStatuses:", inProgressStatuses); - return selectedValue; }; + const filtersToParameters = () => { return ( "statuses=" + diff --git a/frontend/src/components/pathology/PathologyDashboard.js b/frontend/src/components/pathology/PathologyDashboard.js index 4c59976059..c811999f5a 100644 --- a/frontend/src/components/pathology/PathologyDashboard.js +++ b/frontend/src/components/pathology/PathologyDashboard.js @@ -48,7 +48,7 @@ function PathologyDashboard() { const [filters, setFilters] = useState({ searchTerm: "", myCases: false, - statuses: [{ id: "GROSSING" }], + statuses: [{}], }); const [inProgressStatuses, setInProgressStatuses] = useState([]); @@ -60,24 +60,30 @@ function PathologyDashboard() { complete: 0, }); const [loading, setLoading] = useState(true); - + const [inProgressStatusObjects, setInProgressStatusObjects] = useState( + inProgressStatuses.map((statusId) => ({ id: statusId })), + ); const setStatusList = (statusList) => { if (componentMounted.current) { + // Set all statuses setStatuses(statusList); - // Create in-progress statuses by filtering out COMPLETED + // Filter out COMPLETED statuses and update the in-progress statuses state const filteredStatuses = statusList .filter((status) => status.id !== "COMPLETED") .map((status) => status.id); + setInProgressStatuses(filteredStatuses); - // Set initial filter to in-progress - const inProgressStatusObjects = filteredStatuses.map((statusId) => ({ - id: statusId, - })); + // Update the inProgressStatusObjects state + setInProgressStatusObjects( + filteredStatuses.map((statusId) => ({ id: statusId })), + ); + + // Set filters using the updated state setFilters((prev) => ({ ...prev, - statuses: inProgressStatusObjects, + statuses: filteredStatuses.map((statusId) => ({ id: statusId })), })); } }; @@ -166,17 +172,17 @@ function PathologyDashboard() { }; const setStatusFilter = (event) => { - if (event.target.value === "All") { + const { value } = event.target; + + if (value === "All") { setFilters({ ...filters, statuses: statuses }); - } else if (event.target.value === "IN_PROGRESS") { - const inProgressStatusObjects = inProgressStatuses.map((statusId) => ({ - id: statusId, - })); + } else if (value === "IN_PROGRESS") { setFilters({ ...filters, statuses: inProgressStatusObjects }); } else { - setFilters({ ...filters, statuses: [{ id: event.target.value }] }); + setFilters({ ...filters, statuses: [{ id: value }] }); } }; + const getSelectedValue = () => { const selectedValue = filters.statuses.length === inProgressStatuses.length && @@ -186,10 +192,6 @@ function PathologyDashboard() { ? "All" : filters.statuses[0].id; - //console.log("Current selected value:", selectedValue); - //console.log("Current filters.statuses:", filters.statuses); - //console.log("Current inProgressStatuses:", inProgressStatuses); - return selectedValue; };