Skip to content

Commit

Permalink
会員登録のステップの遷移とステップ数修正 (#315)
Browse files Browse the repository at this point in the history
## Issue

- Github Issue: #314 

## 変更内容
- 会員登録画面のステップの遷移がおかしかったので修正

@coderabbitai: ignore
  • Loading branch information
takecchi authored Feb 21, 2024
1 parent 4f93b82 commit 6cacc24
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/app/(plain)/(guest)/signup/_components/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export default function SignUpForm() {

// 招待限定
const { data: systemSettings } = useSystem();
// 1 => 招待コード入力, 2 => 表示名とメールアドレス入力, 3 => 確認コード入力, 4 => パスワード入力とユーザー名入力
const [step, setStep] = useState(1);

// 0 => 招待コード入力, 1 => 表示名とメールアドレス入力, 2 => 確認コード入力, 3 => パスワード入力とユーザー名入力
const [step, setStep] = useState(0);

const [invitationCode, setInvitationCode] = useState('');
const [displayName, setDisplayName] = useState('');
Expand All @@ -25,45 +26,52 @@ export default function SignUpForm() {
return <></>;
}

const maxStep = 4 - (systemSettings.invitationOnly ? 0 : 1);
// 招待コードの有無で表示上のステップを変更する
const maxStep = systemSettings.invitationOnly ? 4 : 3;
const addStep = systemSettings.invitationOnly ? 1 : 0;

// 招待コード入力をスキップする
if (systemSettings.invitationOnly === false && step === 0) {
setStep(1);
}

return (
<>
{step === 1 - (systemSettings.invitationOnly ? 0 : 1) && (
{step === 0 && (
<StepInvitationCode
onSuccess={(code) => {
setInvitationCode(code);
setStep(2);
setStep(1);
}}
step={step}
step={step + addStep}
maxStep={maxStep}
/>
)}
{step === 2 - (systemSettings.invitationOnly ? 0 : 1) && (
{step === 1 && (
<StepEmail
onSuccess={(email, displayName) => {
setEmail(email);
setDisplayName(displayName);
setStep(3);
setStep(2);
}}
step={step}
step={step + addStep}
maxStep={maxStep}
/>
)}
{step === 3 - (systemSettings.invitationOnly ? 0 : 1) && (
{step === 2 && (
<StepVerifyCode
email={email}
onSuccess={(pinCode) => {
setPinCode(pinCode);
setStep(4);
setStep(3);
}}
step={step}
step={step + addStep}
maxStep={maxStep}
/>
)}
{step === 4 - (systemSettings.invitationOnly ? 0 : 1) && (
{step === 3 && (
<StepSignup
step={step}
step={step + addStep}
maxStep={maxStep}
email={email}
displayName={displayName}
Expand Down

0 comments on commit 6cacc24

Please sign in to comment.