Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MDS-6265] Project Summary: Change from Change Requested -> Under Review on final submit only #3353

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions services/common/src/components/forms/SteppedForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface SteppedFormProps extends Omit<FormWrapperProps, "onSubmit"> {
children: Array<ReactElement<StepProps>>;
handleTabChange: (newTab: string) => void | Promise<void>;
handleSaveDraft?: (formValues) => Promise<void>;
handleSaveData?: (values, newActiveTab?: string) => Promise<void>;
handleSaveData?: (values, newActiveTab?: string, currentTab?: string) => Promise<void>;
handleCancel?: () => void | Promise<void>;
transformPayload?: (values: any) => any;
activeTab: string;
Expand Down Expand Up @@ -108,7 +108,7 @@ const SteppedForm: FC<SteppedFormProps> = ({
setIsSubmitting(true);
try {
if (handleSaveData && (await saveCheck())) {
await handleSaveData(getValues(formValues), tab);
await handleSaveData(getValues(formValues), tab, `${tabs[tabIndex]}`);
}
if (errors.length > 0) return;
setTabIndex(indexOf(tabs, tab));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { areAuthFieldsDisabled, areDocumentFieldsDisabled, areFieldsDisabled, is
interface ProjectSummaryFormProps {
initialValues: IProjectSummary;
handleTabChange: (newTab: string) => void;
handleSaveData: (formValues, newActiveTab?) => Promise<void>;
handleSaveData: (formValues, newActiveTab?, currentTab?) => Promise<void>;
activeTab: string;
isEditMode?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,20 @@ export const ProjectSummaryPage = () => {
history.push(url);
};

const handleSaveData = async (formValues, newActiveTab?: string) => {
const handleSaveData = async (formValues, newActiveTab?: string, currentTab?: string) => {
let message = newActiveTab
? "Successfully updated the project description."
: "Successfully submitted a project description to the Province of British Columbia.";
let status_code = projectSummary.status_code;
let is_historic = projectSummary.is_historic;

if (status_code === "CHR" && formValues.confirmation_of_submission) {
if (
status_code === "CHR" &&
formValues.confirmation_of_submission &&
currentTab === "declaration"
) {
// If a proponent re-submits the declaration, when changes are made to the project description,
// change it back to under review.
status_code = "UNR";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love for this business logic to live in the API instead so you can't get around it, but that's something for another time 🙃

} else if ((!status_code || !isEditMode) && status_code !== "UNR") {
status_code = "DFT";
Expand Down
Loading