## 概要 [Task1597: 画面実装(ユーザー認証画面/認証完了画面)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1597) - アカウントへのユーザ追加でメール認証URLから認証を実行した際の画面を実装しました。 - 完了後の画面はアカウント登録のものをそのまま流用しています。 ## レビューポイント - 認証APIからのレスポンスはアカウント登録と同様のものを想定して、完了画面をそのまま流用していますが問題ないでしょうか。 - 画面のパスを`/mail-confirm/user`としましたが問題ないでしょうか? ## UIの変更 - アカウント登録の認証完了画面と同様 ## 動作確認状況 - ローカルで確認 - 認証APIでアカウント登録と同様のレスポンスを想定
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { createSlice } from "@reduxjs/toolkit";
|
|
import { VerifyState } from "./state";
|
|
import { userVerifyAsync, verifyAsync } from "./operations";
|
|
|
|
const initialState: VerifyState = {
|
|
apps: {
|
|
VerifyState: "duringVerify",
|
|
},
|
|
};
|
|
|
|
export const verifySlice = createSlice({
|
|
name: "verify",
|
|
initialState,
|
|
reducers: {},
|
|
extraReducers: (builder) => {
|
|
// アカウント登録
|
|
builder.addCase(verifyAsync.pending, (state) => {
|
|
state.apps.VerifyState = "duringVerify";
|
|
});
|
|
builder.addCase(verifyAsync.fulfilled, (state) => {
|
|
state.apps.VerifyState = "success";
|
|
});
|
|
builder.addCase(verifyAsync.rejected, (state, action) => {
|
|
const { payload } = action;
|
|
|
|
// メール認証済みかをエラーコードから判定
|
|
if (payload?.error.code === "E010202") {
|
|
state.apps.VerifyState = "alreadySuccess";
|
|
} else {
|
|
state.apps.VerifyState = "failed";
|
|
}
|
|
});
|
|
// ユーザ追加
|
|
builder.addCase(userVerifyAsync.pending, (state) => {
|
|
state.apps.VerifyState = "duringVerify";
|
|
});
|
|
builder.addCase(userVerifyAsync.fulfilled, (state) => {
|
|
state.apps.VerifyState = "success";
|
|
});
|
|
builder.addCase(userVerifyAsync.rejected, (state, action) => {
|
|
const { payload } = action;
|
|
|
|
// メール認証済みかをエラーコードから判定
|
|
if (payload?.error.code === "E010202") {
|
|
state.apps.VerifyState = "alreadySuccess";
|
|
} else {
|
|
state.apps.VerifyState = "failed";
|
|
}
|
|
});
|
|
},
|
|
});
|
|
|
|
export default verifySlice.reducer;
|