Skip to content

Commit

Permalink
Merge pull request #366 from wri/release/hotfix-jj-2024-07-10
Browse files Browse the repository at this point in the history
[RELEASE] Hotfix JJ 2024 07 10
  • Loading branch information
roguenet authored Jul 10, 2024
2 parents 698e39d + bb06909 commit ea5c81a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
48 changes: 29 additions & 19 deletions src/admin/components/Dialogs/StatusChangeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { optionToChoices } from "@/utils/options";

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

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

const dialogTitle = (() => {
let title = status === "approve" ? "Are you sure you want to approve this " : "Request more information for ";

let name;
switch (resource as keyof typeof modules) {
case "project":
title += record?.name ?? "Project";
name = record?.name ?? "Project";
break;
case "site":
title += record?.name ?? "Site";
name = record?.name ?? "Site";
break;
case "nursery":
title += record?.name ?? "Nursery";
name = record?.name ?? "Nursery";
break;
case "projectReport":
title += record?.title ?? "Project Report";
name = record?.title ?? "Project Report";
break;
case "siteReport":
title += record?.title ?? "Site Report";
name = record?.title ?? "Site Report";
break;
case "nurseryReport":
title += record?.title ?? "Nursery Report";
name = record?.title ?? "Nursery Report";
break;
}

return title;
switch (status) {
case "approve":
return `Are you sure you want to approve this ${name}`;

case "moreinfo":
return `Request more information for ${name}`;

case "restoration-in-progress":
return `Are you sure you want to mark ${name} as Restoration In Progress?`;
}
})();

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

<DialogContent>
<TextField
value={feedbackValue}
onChange={e => setFeedbackValue(e.target.value)}
label="Feedback"
fullWidth
multiline
margin="dense"
helperText={false}
/>
<When condition={status !== "restoration-in-progress"}>
<TextField
value={feedbackValue}
onChange={e => setFeedbackValue(e.target.value)}
label="Feedback"
fullWidth
multiline
margin="dense"
helperText={false}
/>
</When>
<When condition={status === "moreinfo" && feedbackChoices.length > 0}>
<AutocompleteArrayInput
source="feedback_fields"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Text from "@/components/elements/Text/Text";
import { fetchGetV2SitesSiteCheckApprove } from "@/generated/apiComponents";

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

const { record } = useShowContext();
Expand Down Expand Up @@ -81,6 +81,13 @@ const SiteOverview: FC = () => {
>
Request More Info
</Button>
<Button
className="button-aside-page-admin"
disabled={record?.status === "restoration-in-progress"}
onClick={() => setStatusModal("restoration-in-progress")}
>
Restoration in Progress
</Button>
<Button
className="button-aside-page-admin"
startIcon={<Check />}
Expand Down

0 comments on commit ea5c81a

Please sign in to comment.