Skip to content

Commit

Permalink
chore: verification refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pbastia committed Dec 30, 2024
1 parent 4c63dfe commit bba9b81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const FinalReviewForm: React.FC<Props> = ({ version_id, taskListElements }) => {
cancelUrl="#"
backUrl={backUrl}
continueUrl={saveAndContinueUrl}
noFormSave={submitHandler}
noFormSave={() => {}}
>
Placeholder for Final Review
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
cancelUrlReports,
} from "@reporting/src/app/utils/constants";
import { actionHandler } from "@bciers/actions";
import safeJsonParse from "@bciers/utils/src/safeJsonParse";
import serializeSearchParams from "@bciers/utils/src/serializeSearchParams";

interface Props {
Expand All @@ -30,7 +29,7 @@ export default function VerificationForm({
taskListElements,
}: Props) {
const [formData, setFormData] = useState(initialData);
const [error, setError] = useState(undefined);
const [errors, setErrors] = useState<string[]>();
const searchParams = useSearchParams();
const queryString = serializeSearchParams(searchParams);

Expand All @@ -47,16 +46,17 @@ export default function VerificationForm({
const endpoint = `reporting/report-version/${version_id}/report-verification`;
const method = "POST";
const pathToRevalidate = "reporting/reports";
const payload = safeJsonParse(JSON.stringify(formData));

const response = await actionHandler(endpoint, method, pathToRevalidate, {
body: JSON.stringify(payload),
body: JSON.stringify(formData),
});

if (response?.error) {
setError(response.error);
return;
if (response.error) {
setErrors([response.error]);
return false;
} else {
setError(undefined);
setErrors(undefined);
return true;
}
};

Expand All @@ -73,7 +73,7 @@ export default function VerificationForm({
backUrl={backUrl}
onChange={handleChange}
onSubmit={handleSubmit}
error={error}
errors={errors}
continueUrl={saveAndContinueUrl}
/>
);
Expand Down

0 comments on commit bba9b81

Please sign in to comment.