Skip to content

Commit a4ff996

Browse files
authored
Merge pull request #170 from don-aot/origin/CONDITIONS-task#167
CR-167:Remove Consolidated Conditions toggle from the document screen
2 parents f4305af + 109fb21 commit a4ff996

File tree

2 files changed

+5
-43
lines changed
  • condition-web/src
    • components/Documents
    • routes/_authenticated/_dashboard/documents/project/$projectId/document-category/$categoryId

2 files changed

+5
-43
lines changed

condition-web/src/components/Documents/index.tsx

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { useState, useEffect } from "react";
2-
import { useNavigate } from "@tanstack/react-router";
32
import { BCDesignTokens } from "epic.theme";
43
import { AllDocumentModel, DocumentStatus } from "@/models/Document";
5-
import { Box, styled, Stack, FormControlLabel, Typography, Switch, Grid } from "@mui/material";
4+
import { Box, styled, Stack, Typography, Grid } from "@mui/material";
65
import { ContentBoxSkeleton } from "../Shared/ContentBox/ContentBoxSkeleton";
76
import { ContentBox } from "../Shared/ContentBox";
87
import DocumentTable from "./DocumentTable";
@@ -22,28 +21,13 @@ type DocumentsParam = {
2221
documents?: AllDocumentModel[];
2322
projectName: string;
2423
projectId: string;
25-
categoryId: number;
2624
documentLabel: string;
2725
};
2826

29-
export const Documents = ({ projectName, projectId, categoryId, documentLabel, documents }: DocumentsParam) => {
30-
const navigate = useNavigate();
31-
const [isToggled, setIsToggled] = useState(false);
32-
const [isToggleEnabled, setIsToggleEnabled] = useState<boolean | null>(false);
27+
export const Documents = ({ projectName, projectId, documentLabel, documents }: DocumentsParam) => {
3328
const [isAllApproved, setIsAllApproved] = useState<boolean | null>(false);
3429

35-
const handleToggle = (event: React.ChangeEvent<HTMLInputElement>) => {
36-
const checked = event.target.checked;
37-
setIsToggled(checked);
38-
if (checked) {
39-
navigate({
40-
to: `/projects/${projectId}/document-category/${categoryId}/consolidated-conditions`,
41-
});
42-
}
43-
};
44-
4530
useEffect(() => {
46-
// Check if all amendments have status as true
4731
if (documents && documents.length > 0) {
4832
const hasNullStatus = documents.some((document) => document.status === null);
4933
if (hasNullStatus) {
@@ -52,18 +36,11 @@ export const Documents = ({ projectName, projectId, categoryId, documentLabel, d
5236
const allApproved = documents.every((document) => document.status === true);
5337
setIsAllApproved(allApproved);
5438
}
55-
56-
// Check if any document has is_latest_amendment_added as true
57-
const hasLatestAmendment = documents.some(doc => doc.is_latest_amendment_added === true);
58-
const anyLatestAmendmentAdded = hasNullStatus ? false : hasLatestAmendment;
59-
60-
setIsToggleEnabled(anyLatestAmendmentAdded);
6139
}
6240
}, [documents]);
6341

6442
return (
6543
<Stack spacing={2} direction={"column"} sx={{ width: '100%' }}>
66-
{/* Showing results message */}
6744
<ContentBox
6845
mainLabel={
6946
<Box component="span">
@@ -90,15 +67,14 @@ export const Documents = ({ projectName, projectId, categoryId, documentLabel, d
9067
}}
9168
>
9269
<Grid container direction="row" paddingBottom={3}>
93-
<Grid item xs={6}>
70+
<Grid item xs={12}>
9471
<Box
9572
sx={{
9673
px: 2.5,
97-
display: "flex", // Align items in a row
98-
alignItems: "center", // Vertically center the elements
74+
display: "flex",
75+
alignItems: "center",
9976
}}
10077
>
101-
{/* Document Name and Icon */}
10278
<Box sx={{ display: "flex", alignItems: "center" }}>
10379
{documentLabel}
10480
<LayersOutlinedIcon fontSize="small" sx={{ ml: 1, mr: 1 }} />
@@ -108,19 +84,6 @@ export const Documents = ({ projectName, projectId, categoryId, documentLabel, d
10884
</Box>
10985
</Box>
11086
</Grid>
111-
<Grid item xs={6} textAlign="right">
112-
<FormControlLabel
113-
control={
114-
<Switch
115-
disabled={!isToggleEnabled} // Disable the switch based on the isToggleEnabled state
116-
checked={isToggled}
117-
onChange={handleToggle} // Add onChange handler to toggle and navigate
118-
/>
119-
}
120-
label="View Consolidated Conditions"
121-
labelPlacement="end"
122-
/>
123-
</Grid>
12487
</Grid>
12588
<Box height={"100%"} px={BCDesignTokens.layoutPaddingXsmall}>
12689
<CardInnerBox

condition-web/src/routes/_authenticated/_dashboard/documents/project/$projectId/document-category/$categoryId/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ function DocumentPage() {
7272
<Documents
7373
projectName = {allDocuments?.project_name || ""}
7474
projectId = {projectId}
75-
categoryId = {categoryId}
7675
documentLabel = {allDocuments?.document_category || ""}
7776
documents={allDocuments?.documents}
7877
/>

0 commit comments

Comments
 (0)