Skip to content

Commit

Permalink
Replace send a new code link when the code expires
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjuhuss committed Jan 24, 2025
1 parent de4869b commit 0d429c1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/apis/eduidSignup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export interface SignupState {
initiated_signup: boolean;
is_logged_in: boolean;
};
name: {
given_name?: string;
surname?: string;
};
tou: { completed: boolean; version?: string };
captcha: { completed: boolean };
credentials: {
Expand Down
29 changes: 20 additions & 9 deletions src/components/Signup/SignupEnterCode.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { verifyEmailRequest } from "apis/eduidSignup";
import { registerEmailRequest, verifyEmailRequest } from "apis/eduidSignup";
import EduIDButton from "components/Common/EduIDButton";
import { ResponseCodeButtons } from "components/Common/ResponseCodeAbortButton";
import { TimeRemainingWrapper } from "components/Common/TimeRemaining";
Expand Down Expand Up @@ -35,6 +35,22 @@ export function SignupEnterCode(): JSX.Element {
setIsExpired(true);
}

async function registerEmail() {
if (signupState?.email.address && signupState?.name?.given_name && signupState?.name?.surname) {
const res = await dispatch(
registerEmailRequest({
email: signupState?.email.address,
given_name: signupState?.name?.given_name,
surname: signupState?.name?.surname,
})
);

if (registerEmailRequest.fulfilled.match(res)) {
setIsExpired(false);
}
}
}

function handleAbortButtonOnClick(event: React.MouseEvent<HTMLButtonElement>) {
event.preventDefault();
signupContext.signupService.send({ type: "ABORT" });
Expand Down Expand Up @@ -81,18 +97,13 @@ export function SignupEnterCode(): JSX.Element {
</div>
<p>
<FormattedMessage
defaultMessage="To receive a new code, click the link below. You will be redirected to the register page."
defaultMessage="Click the link below to receive a new code. You will be redirected to a page where you can enter the new code."
description="Signup, code expired"
/>
</p>

<EduIDButton
buttonstyle="link"
className="lowercase"
onClick={handleAbortButtonOnClick}
id="return-to-register-button"
>
<FormattedMessage defaultMessage="Return to Register" description="Return to register" />
<EduIDButton buttonstyle="link" className="lowercase" onClick={registerEmail} id="send-new-code">
<FormattedMessage defaultMessage="Send a new code" description="send a new code" />
</EduIDButton>
</div>
);
Expand Down
4 changes: 4 additions & 0 deletions src/tests/signup/SignupMain-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const emptyState: SignupState = {
completed: false,
version: "1999-v1",
},
name: {
given_name: "",
surname: "",
},
user_created: false,
};
const testFirstName = "test";
Expand Down

0 comments on commit 0d429c1

Please sign in to comment.