Skip to content

Commit

Permalink
chore: fix navigation buttons urls
Browse files Browse the repository at this point in the history
  • Loading branch information
shon-button committed Dec 11, 2024
1 parent ba8615b commit 9949aa6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import {
} from "@reporting/src/data/jsonSchema/nonAttributableEmissions/nonAttributableEmissions";
import { actionHandler } from "@bciers/actions";

const BASE_URL = "/reporting/reports";
const CANCEL_URL = "/reports";

interface ActivityData {
id: number;
activity: string;
Expand Down Expand Up @@ -71,8 +68,8 @@ export default function NonAttributableEmissionsForm({

const router = useRouter();

const SAVE_AND_CONTINUE_URL = `${BASE_URL}/${versionId}/facilities/${facilityId}/emission-summary`;
const BACK_URL = `activities?step=-1`;
const saveAndContinueUrl = `/reports/${versionId}/facilities/${facilityId}/emission-summary`;
const backUrl = `activities?step=-1`;

const schema = generateUpdatedSchema(gasTypes, emissionCategories);
const taskListElements: TaskListElement[] = [
Expand Down Expand Up @@ -103,9 +100,6 @@ export default function NonAttributableEmissionsForm({
const response = await actionHandler(endpoint, "POST", endpoint, {
body: JSON.stringify(formData),
});
if (response) {
router.push(SAVE_AND_CONTINUE_URL);
}
};

return (
Expand All @@ -122,12 +116,11 @@ export default function NonAttributableEmissionsForm({
schema={schema}
uiSchema={nonAttributableEmissionUiSchema}
formData={formData}
baseUrl={BASE_URL}
cancelUrl={CANCEL_URL}
cancelUrl="#"
onChange={(data) => setFormData(data.formData)}
onSubmit={() => handleSubmit()}
backUrl={BACK_URL}
continueUrl={SAVE_AND_CONTINUE_URL}
backUrl={backUrl}
continueUrl={saveAndContinueUrl}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe("NonAttributableEmissionsForm Component", () => {

await waitFor(() => expect(actionHandler).toHaveBeenCalled());
expect(mockPush).toHaveBeenCalledWith(
`/reporting/reports/${versionId}/facilities/${facilityId}/emission-summary`,
`/reports/${versionId}/facilities/${facilityId}/emission-summary`,
);
});

Expand Down

0 comments on commit 9949aa6

Please sign in to comment.