Skip to content

Commit 7de4571

Browse files
HarshHarsh
authored andcommitted
Merge branch 'develop' of https://github.com/bluewave-labs/verifywise into develop
2 parents ecb0f0c + e2bac6c commit 7de4571

File tree

6 files changed

+189
-69
lines changed

6 files changed

+189
-69
lines changed

Clients/src/presentation/components/IconButton/index.tsx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,20 +248,20 @@ const IconButton: React.FC<IconButtonProps> = ({
248248
*/
249249
const getMenuItemText = (item: string) => {
250250
if (item === "make visible") {
251-
return isVisible ? "Make Hidden" : "Make Visible";
251+
return isVisible ? "Make hidden" : "Make visible";
252252
}
253253
if (item === "archive" && type === "Incident") {
254254
return "Archive incident";
255255
}
256256
// Task-specific labels
257257
if ((type === "Task" || type === "task") && item === "archive") {
258-
return "Archive";
258+
return "Archive task";
259259
}
260260
if ((type === "Task" || type === "task") && item === "delete") {
261-
return "Delete";
261+
return "Delete permanently";
262262
}
263263
if ((type === "Task" || type === "task") && item === "restore") {
264-
return "Restore";
264+
return "Restore task";
265265
}
266266
return item.charAt(0).toUpperCase() + item.slice(1);
267267
};
@@ -356,11 +356,27 @@ const IconButton: React.FC<IconButtonProps> = ({
356356
}
357357
}}
358358
disabled={isDisabled}
359-
sx={
360-
item === "remove" || item === "archive" || item === "delete"
361-
? { color: "#d32f2f" }
362-
: {}
363-
}
359+
sx={{
360+
...(() => {
361+
// Archive (soft delete) uses warning color
362+
if (item === "archive" && (type === "Task" || type === "task")) {
363+
return { color: "#F59E0B" }; // warning color
364+
}
365+
// Hard delete uses error color
366+
if (item === "delete" && (type === "Task" || type === "task")) {
367+
return { color: "#d32f2f" }; // error color
368+
}
369+
// Other remove/archive uses error color
370+
if (item === "remove" || item === "archive") {
371+
return { color: "#d32f2f" };
372+
}
373+
// Restore uses primary/success color
374+
if (item === "restore") {
375+
return { color: "#13715B" }; // primary color
376+
}
377+
return {};
378+
})(),
379+
}}
364380
>
365381
{getMenuItemText(item)}
366382
</MenuItem>

Clients/src/presentation/components/Modals/Basic/index.tsx

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* A modal component that displays a confirmation dialog for deleting a vendor.
2+
* A modal component that displays a confirmation dialog for deleting/archiving items.
33
*
44
* @component
55
* @param {BasicModalProps} props - The properties for the BasicModal component.
@@ -12,13 +12,14 @@
1212
* <BasicModal isOpen={isOpen} setIsOpen={setIsOpen} />
1313
*/
1414

15-
import { Button, Modal, Stack, Typography, useTheme } from "@mui/material";
15+
import { Button, Modal, Stack, Typography, useTheme, CircularProgress } from "@mui/material";
1616
import { BasicModalProps } from "../../../../domain/interfaces/iSelect";
1717
import {
1818
BasicModalCancelButtonStyle,
1919
BasicModalDeleteButtonStyle,
2020
} from "./style";
2121
import { useModalKeyHandling } from "../../../../application/hooks/useModalKeyHandling";
22+
import { useState } from "react";
2223

2324
const BasicModal: React.FC<BasicModalProps> = ({
2425
isOpen,
@@ -30,17 +31,39 @@ const BasicModal: React.FC<BasicModalProps> = ({
3031
type,
3132
}) => {
3233
const theme = useTheme();
34+
const [isLoading, setIsLoading] = useState(false);
3335

3436
useModalKeyHandling({
3537
isOpen,
36-
onClose: () => setIsOpen(false),
38+
onClose: () => !isLoading && setIsOpen(false),
3739
});
3840

41+
const handleDelete = async (e: React.MouseEvent) => {
42+
setIsLoading(true);
43+
try {
44+
await onDelete(e);
45+
} finally {
46+
setIsLoading(false);
47+
}
48+
};
49+
50+
const handleCancel = (e: React.MouseEvent) => {
51+
if (!isLoading) {
52+
onCancel(e);
53+
}
54+
};
55+
56+
// Determine the action type and button styling
57+
const isArchiveAction = type === "Incident" || type === "Task";
58+
const isHardDelete = warningTitle?.toLowerCase().includes("permanently") || warningTitle?.toLowerCase().includes("delete");
59+
const buttonColor = isArchiveAction && !isHardDelete ? "warning" : "error";
60+
const buttonText = isArchiveAction ? `Archive ${type.toLowerCase()}` : (isHardDelete ? "Delete permanently" : `Delete ${type}`);
61+
3962
return (
4063
<Modal
4164
open={isOpen}
4265
onClose={(_event, reason) => {
43-
if (reason !== "backdropClick") {
66+
if (reason !== "backdropClick" && !isLoading) {
4467
setIsOpen(false);
4568
}
4669
}}
@@ -57,13 +80,13 @@ const BasicModal: React.FC<BasicModalProps> = ({
5780
top: "50%",
5881
left: "50%",
5982
transform: "translate(-50%, -50%)",
60-
width: 450,
83+
width: 480,
84+
maxWidth: "90vw",
6185
bgcolor: theme.palette.background.modal,
62-
border: 1,
63-
borderColor: theme.palette.border.dark,
86+
border: `1px solid ${theme.palette.border.light}`,
6487
borderRadius: theme.shape.borderRadius,
6588
boxShadow: 24,
66-
p: theme.spacing(15),
89+
p: theme.spacing(3),
6790
"&:focus": {
6891
outline: "none",
6992
},
@@ -73,20 +96,23 @@ const BasicModal: React.FC<BasicModalProps> = ({
7396
id="modal-delete-vendor"
7497
fontSize={16}
7598
fontWeight={600}
99+
color={theme.palette.text.primary}
76100
>
77101
{warningTitle}
78102
</Typography>
79103
<Typography
80104
id="delete-monitor-confirmation"
81105
fontSize={13}
82106
textAlign={"left"}
107+
color={theme.palette.text.secondary}
108+
sx={{ lineHeight: 1.5 }}
83109
>
84110
{warningMessage}
85111
</Typography>
86112
<Stack
87113
direction="row"
88-
gap={theme.spacing(4)}
89-
mt={theme.spacing(12)}
114+
gap={theme.spacing(2)}
115+
mt={theme.spacing(4)}
90116
justifyContent="flex-end"
91117
>
92118
<Button
@@ -95,8 +121,13 @@ const BasicModal: React.FC<BasicModalProps> = ({
95121
disableTouchRipple
96122
variant="text"
97123
color="inherit"
98-
onClick={(e) => onCancel(e)}
99-
sx={BasicModalCancelButtonStyle}
124+
onClick={handleCancel}
125+
disabled={isLoading}
126+
sx={{
127+
...BasicModalCancelButtonStyle,
128+
opacity: isLoading ? 0.5 : 1,
129+
cursor: isLoading ? "not-allowed" : "pointer",
130+
}}
100131
>
101132
Cancel
102133
</Button>
@@ -105,11 +136,20 @@ const BasicModal: React.FC<BasicModalProps> = ({
105136
disableFocusRipple
106137
disableTouchRipple
107138
variant="contained"
108-
color="error"
109-
sx={BasicModalDeleteButtonStyle}
110-
onClick={(e) => onDelete(e)}
139+
color={buttonColor}
140+
sx={{
141+
...BasicModalDeleteButtonStyle,
142+
opacity: isLoading ? 0.7 : 1,
143+
cursor: isLoading ? "not-allowed" : "pointer",
144+
display: "flex",
145+
alignItems: "center",
146+
gap: "8px",
147+
}}
148+
onClick={handleDelete}
149+
disabled={isLoading}
111150
>
112-
{type === "Incident" || type === "Task" ? `Archive ${type.toLowerCase()}` : `Delete ${type}`}
151+
{isLoading && <CircularProgress size={16} color="inherit" />}
152+
{buttonText}
113153
</Button>
114154
</Stack>
115155
</Stack>
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
export const BasicModalCancelButtonStyle = {
2-
width: 100,
2+
minWidth: 100,
33
textTransform: "capitalize",
44
fontSize: 13,
55
borderRadius: "4px",
6+
padding: "8px 16px",
67
"&:hover": {
78
boxShadow: "none",
8-
backgroundColor: "transparent",
9+
backgroundColor: "rgba(0, 0, 0, 0.04)",
910
},
1011
};
1112

1213
export const BasicModalDeleteButtonStyle = {
13-
width: 160,
14+
minWidth: 160,
1415
fontSize: 13,
1516
backgroundColor: "#DB504A",
1617
border: "1px solid #DB504A",
1718
boxShadow: "none",
1819
borderRadius: "4px",
20+
padding: "8px 16px",
21+
textTransform: "capitalize",
1922
"&:hover": {
2023
boxShadow: "none",
24+
backgroundColor: "#c23c34",
25+
borderColor: "#c23c34",
2126
},
2227
};

Clients/src/presentation/components/RiskLevel/riskValues.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export enum RiskLikelihood {
1212
Unlikely = "Unlikely",
1313
Possible = "Possible",
1414
Likely = "Likely",
15-
AlmostCertain = "Almost certain",
15+
AlmostCertain = "Almost Certain",
1616
}
1717
export enum RiskSeverity {
1818
Negligible = "Negligible",

Clients/src/presentation/components/Table/TasksTable/index.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,10 @@ const TasksTable: React.FC<ITasksTableProps> = ({
316316
sx={{
317317
...singleTheme.tableStyles.primary.body.row,
318318
cursor: isArchived ? "default" : "pointer",
319+
backgroundColor: isArchived ? "rgba(0, 0, 0, 0.02)" : "transparent",
320+
opacity: isArchived ? 0.7 : 1,
319321
"&:hover": {
320-
backgroundColor: "#f5f5f5",
322+
backgroundColor: isArchived ? "rgba(0, 0, 0, 0.04)" : "#f5f5f5",
321323
},
322324
}}
323325
onClick={() => !isArchived && onRowClick?.(task)}
@@ -333,7 +335,11 @@ const TasksTable: React.FC<ITasksTableProps> = ({
333335
<Box>
334336
<Typography
335337
variant="body2"
336-
sx={{ textTransform: "capitalize" }}
338+
sx={{
339+
textTransform: "capitalize",
340+
textDecoration: isArchived ? "line-through" : "none",
341+
color: isArchived ? "#9ca3af" : "inherit",
342+
}}
337343
>
338344
{task.title}
339345
</Typography>
@@ -547,8 +553,8 @@ const TasksTable: React.FC<ITasksTableProps> = ({
547553
onDelete={() => onArchive(task.id!)}
548554
onEdit={() => onEdit(task)}
549555
onMouseEvent={() => {}}
550-
warningTitle="Archive this task?"
551-
warningMessage="When you archive this task, it will be hidden from the active tasks list. You can restore it later using the 'include archived' toggle."
556+
warningTitle="Archive task?"
557+
warningMessage={`This task will be hidden from your active task list. You can restore "${task.title}" anytime from the archived view.`}
552558
type="Task"
553559
isArchived={task.status === TaskStatus.DELETED}
554560
onRestore={onRestore ? () => onRestore(task.id!) : undefined}

0 commit comments

Comments
 (0)