Skip to content

Commit ea5c81a

Browse files
authored
Merge pull request #366 from wri/release/hotfix-jj-2024-07-10
[RELEASE] Hotfix JJ 2024 07 10
2 parents 698e39d + bb06909 commit ea5c81a

File tree

2 files changed

+37
-20
lines changed

2 files changed

+37
-20
lines changed

src/admin/components/Dialogs/StatusChangeModal.tsx

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { optionToChoices } from "@/utils/options";
2424

2525
interface StatusChangeModalProps extends DialogProps {
2626
handleClose: () => void;
27-
status: "approve" | "moreinfo" | undefined;
27+
status: "approve" | "moreinfo" | "restoration-in-progress" | undefined;
2828
}
2929

3030
const moreInfoValidationSchema = yup.object({
@@ -59,30 +59,38 @@ const StatusChangeModal = ({ handleClose, status, ...dialogProps }: StatusChange
5959
})();
6060

6161
const dialogTitle = (() => {
62-
let title = status === "approve" ? "Are you sure you want to approve this " : "Request more information for ";
63-
62+
let name;
6463
switch (resource as keyof typeof modules) {
6564
case "project":
66-
title += record?.name ?? "Project";
65+
name = record?.name ?? "Project";
6766
break;
6867
case "site":
69-
title += record?.name ?? "Site";
68+
name = record?.name ?? "Site";
7069
break;
7170
case "nursery":
72-
title += record?.name ?? "Nursery";
71+
name = record?.name ?? "Nursery";
7372
break;
7473
case "projectReport":
75-
title += record?.title ?? "Project Report";
74+
name = record?.title ?? "Project Report";
7675
break;
7776
case "siteReport":
78-
title += record?.title ?? "Site Report";
77+
name = record?.title ?? "Site Report";
7978
break;
8079
case "nurseryReport":
81-
title += record?.title ?? "Nursery Report";
80+
name = record?.title ?? "Nursery Report";
8281
break;
8382
}
8483

85-
return title;
84+
switch (status) {
85+
case "approve":
86+
return `Are you sure you want to approve this ${name}`;
87+
88+
case "moreinfo":
89+
return `Request more information for ${name}`;
90+
91+
case "restoration-in-progress":
92+
return `Are you sure you want to mark ${name} as Restoration In Progress?`;
93+
}
8694
})();
8795

8896
const { data: formResponse } = useGetV2FormsENTITYUUID<{ data: GetV2FormsENTITYUUIDResponse }>(
@@ -144,15 +152,17 @@ const StatusChangeModal = ({ handleClose, status, ...dialogProps }: StatusChange
144152
<DialogTitle>{dialogTitle}</DialogTitle>
145153

146154
<DialogContent>
147-
<TextField
148-
value={feedbackValue}
149-
onChange={e => setFeedbackValue(e.target.value)}
150-
label="Feedback"
151-
fullWidth
152-
multiline
153-
margin="dense"
154-
helperText={false}
155-
/>
155+
<When condition={status !== "restoration-in-progress"}>
156+
<TextField
157+
value={feedbackValue}
158+
onChange={e => setFeedbackValue(e.target.value)}
159+
label="Feedback"
160+
fullWidth
161+
multiline
162+
margin="dense"
163+
helperText={false}
164+
/>
165+
</When>
156166
<When condition={status === "moreinfo" && feedbackChoices.length > 0}>
157167
<AutocompleteArrayInput
158168
source="feedback_fields"

src/admin/components/ResourceTabs/InformationTab/components/SiteInformationAside/SiteOverview.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Text from "@/components/elements/Text/Text";
99
import { fetchGetV2SitesSiteCheckApprove } from "@/generated/apiComponents";
1010

1111
const SiteOverview: FC = () => {
12-
const [statusModal, setStatusModal] = useState<"approve" | "moreinfo" | undefined>();
12+
const [statusModal, setStatusModal] = useState<"approve" | "moreinfo" | "restoration-in-progress" | undefined>();
1313
const [checkPolygons, setCheckPolygons] = useState<boolean | undefined>(undefined);
1414

1515
const { record } = useShowContext();
@@ -81,6 +81,13 @@ const SiteOverview: FC = () => {
8181
>
8282
Request More Info
8383
</Button>
84+
<Button
85+
className="button-aside-page-admin"
86+
disabled={record?.status === "restoration-in-progress"}
87+
onClick={() => setStatusModal("restoration-in-progress")}
88+
>
89+
Restoration in Progress
90+
</Button>
8491
<Button
8592
className="button-aside-page-admin"
8693
startIcon={<Check />}

0 commit comments

Comments
 (0)