Skip to content

Commit 5e822ab

Browse files
authored
Merge pull request #175 from don-aot/CONDITIONS-task#96-fix
CR-96:Changes to '+ Add Document' button
2 parents 88afb2e + b17debc commit 5e822ab

File tree

3 files changed

+23
-44
lines changed

3 files changed

+23
-44
lines changed

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

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -76,64 +76,43 @@ export const Documents = ({ projectName, projectId, categoryId, documentLabel, d
7676
boxShadow: "0px 1px 2px rgba(0, 0, 0, 0.1)",
7777
}}
7878
>
79-
<Typography
80-
variant="h6"
79+
<Box
8180
sx={{
8281
px: BCDesignTokens.layoutPaddingXsmall,
8382
py: BCDesignTokens.layoutPaddingSmall,
8483
borderBottom: `1px solid ${BCDesignTokens.surfaceColorBorderDefault}`,
8584
}}
8685
>
87-
<Grid container direction="row" paddingBottom={3}>
88-
<Grid item xs={6}>
89-
<Box
90-
sx={{
91-
px: 2.5,
92-
display: "flex",
93-
alignItems: "center",
94-
}}
95-
>
86+
<Grid container direction="row" alignItems="center" paddingBottom={3}>
87+
<Grid item xs>
88+
<Box sx={{ px: 2.5, display: "flex", alignItems: "center" }}>
9689
<Box sx={{ display: "flex", alignItems: "center" }}>
97-
{documentLabel}
90+
<Typography variant="h6" component="span">{documentLabel}</Typography>
9891
<LayersOutlinedIcon fontSize="small" sx={{ ml: 1, mr: 1 }} />
9992
</Box>
10093
<Box sx={{ display: "flex", alignItems: "center", fontWeight: "normal" }}>
10194
<DocumentStatusChip status={isAllApproved === null ? "nodata" : String(isAllApproved) as DocumentStatus} />
10295
</Box>
10396
</Box>
10497
</Grid>
105-
<Grid item xs={6} textAlign="right" sx={{ display: "flex", alignItems: "center", justifyContent: "flex-end", gap: 2 }}>
106-
{project && documentType && (
98+
{project && documentType && (
99+
<Grid item sx={{ pr: BCDesignTokens.layoutPaddingMedium, flex: { xs: "auto", sm: "0 0 15%" } }}>
107100
<LoadingButton
108101
variant="contained"
102+
color="primary"
103+
size="small"
104+
startIcon={<AddIcon />}
109105
onClick={handleOpenAddDocument}
110106
loading={isOpeningModal}
111107
sx={{
112-
display: "flex",
113-
padding: "8px 22px 7px 15px",
114-
alignItems: "center",
115-
gap: "14.178px",
116-
height: "70%",
117108
borderRadius: "4px",
118-
border: "2px solid #353433",
119-
backgroundColor: "#013366",
120-
color: "#FFF",
121-
textAlign: "center",
122-
fontFamily: '"BC Sans"',
123-
fontSize: "16px",
124-
fontStyle: "normal",
125-
fontWeight: 400,
126-
lineHeight: "27.008px",
127-
"&:hover": {
128-
backgroundColor: "#002a52",
129-
border: "2px solid #353433",
130-
},
109+
width: "100%",
131110
}}
132111
>
133-
<AddIcon fontSize="small" /> Add Document
112+
Add Document
134113
</LoadingButton>
135-
)}
136-
</Grid>
114+
</Grid>
115+
)}
137116
</Grid>
138117
<Box height={"100%"} px={BCDesignTokens.layoutPaddingXsmall}>
139118
<CardInnerBox
@@ -145,7 +124,7 @@ export const Documents = ({ projectName, projectId, categoryId, documentLabel, d
145124
/>
146125
</CardInnerBox>
147126
</Box>
148-
</Typography>
127+
</Box>
149128
</Box>
150129
</ContentBox>
151130
{project && documentType && (

condition-web/src/components/Projects/CreateDocumentModal.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { ProjectModel } from "@/models/Project";
2424
import { DocumentTypes } from "@/utils/enums"
2525
import { useCreateDocument, useGetDocumentsByProject } from "@/hooks/api/useDocuments";
2626
import { useCreateAmendment } from "@/hooks/api/useAmendments";
27+
import { QUERY_KEY } from "@/hooks/api/constants";
2728
import { CreateAmendmentModel } from "@/models/Amendment";
2829
import { CreateDocumentModel, DocumentModel } from "@/models/Document";
2930
import { CustomTooltip } from '../Shared/Common';
@@ -201,7 +202,9 @@ export const CreateDocumentModal = ({
201202
? await createAmendment(payload as CreateAmendmentModel)
202203
: await createDocument(payload as CreateDocumentModel);
203204

204-
queryClient.invalidateQueries({ queryKey: ["projects"] });
205+
queryClient.invalidateQueries({ queryKey: [QUERY_KEY.PROJECTS] });
206+
queryClient.invalidateQueries({ queryKey: [QUERY_KEY.DOCUMENT] });
207+
queryClient.invalidateQueries({ queryKey: [QUERY_KEY.PROJECTDOCUMENT] });
205208

206209
if (response) {
207210
const navigateTo = isAmendment

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,17 @@ export const Projects = ({ projects, documentType }: ProjectsParams) => {
8989
variant="contained"
9090
color="primary"
9191
size="small"
92+
startIcon={<AddIcon fontSize="small" />}
9293
sx={{
93-
flex: { xs: "auto", sm: "0 0 15%" }, // Auto width, no extra space
94-
width: { xs: "100%", sm: "auto" }, // Full width on mobile, auto on large screens
94+
flex: { xs: "auto", sm: "0 0 15%" },
95+
width: { xs: "100%", sm: "auto" },
9596
height: "70%",
9697
borderRadius: "4px",
97-
paddingLeft: "2px",
98-
display: "flex",
99-
alignItems: "center",
100-
justifyContent: "center",
10198
}}
10299
onClick={handleOpenCreateNewDocument}
103100
loading={isOpeningModal}
104101
>
105-
<AddIcon fontSize="small" /> Add Document
102+
Add Document
106103
</LoadingButton>
107104
</Stack>
108105
</Grid>

0 commit comments

Comments
 (0)