Skip to content

Commit

Permalink
Fix error wrapper type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jamdelion committed Nov 28, 2024
1 parent 03454a3 commit 4260930
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions editor.planx.uk/src/pages/VerifyEmail/VerifyEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,33 @@ export const VerifyEmail = ({ params }: VerifyEmailProps): JSX.Element => {
const {
data: downloadData,
isLoading,
isError,
status: downloadStatus,
error: downloadError,
} = useQueryApplicationFileDownload(sessionId, email, team, {
enabled: emailInputIsValid,
retry: false,
});

const [downloadApplicationError, setDownloadApplicationError] = useState<
string | undefined
>();

useEffect(() => {
if (downloadData) {
downloadZipFile(downloadData.data);
}
}, [downloadData]);

useEffect(() => {
if (isError) {
setDownloadApplicationError(
"Sorry, something went wrong. Please try again.",
);
} else {
setDownloadApplicationError(undefined);
}
}, [isError]);

useEffect(() => {
// if the request has finished, invalidate query cache so other requests can be run
if (downloadStatus !== "pending") {
Expand All @@ -55,7 +69,7 @@ export const VerifyEmail = ({ params }: VerifyEmailProps): JSX.Element => {
queryKey: [`${DOWNLOAD_APPLICATION_FILE_QUERY_KEY}`, sessionId],
});
}
}, [downloadStatus]);
}, [downloadStatus, queryClient, sessionId]);

const formik = useFormik({
initialValues: {
Expand All @@ -79,12 +93,7 @@ export const VerifyEmail = ({ params }: VerifyEmailProps): JSX.Element => {
) : (
<Box width="100%">
<Card handleSubmit={formik.handleSubmit}>
<ErrorWrapper
error={
downloadError &&
`Sorry, something went wrong. Please try again.`
}
>
<ErrorWrapper error={downloadApplicationError}>
<>
<CardHeader
title="Verify your email address"
Expand Down

0 comments on commit 4260930

Please sign in to comment.