diff --git a/dictation_client/src/features/user/operations.ts b/dictation_client/src/features/user/operations.ts index 8c35726..d975075 100644 --- a/dictation_client/src/features/user/operations.ts +++ b/dictation_client/src/features/user/operations.ts @@ -59,16 +59,17 @@ export const addUserAsync = createAsyncThunk< const config = new Configuration(configuration); const usersApi = new UsersApi(config); const { addUser } = state.user.apps; + const newUser = { ...addUser }; // roleがAUTHOR以外の場合、不要なプロパティをundefinedにする - if (addUser.role !== USER_ROLES.AUTHOR) { - addUser.authorId = undefined; - addUser.encryption = undefined; - addUser.prompt = undefined; - addUser.encryptionPassword = undefined; + if (newUser.role !== USER_ROLES.AUTHOR) { + newUser.authorId = undefined; + newUser.encryption = undefined; + newUser.prompt = undefined; + newUser.encryptionPassword = undefined; } try { - await usersApi.signup(addUser, { + await usersApi.signup(newUser, { headers: { authorization: `Bearer ${accessToken}` }, }); thunkApi.dispatch( diff --git a/dictation_client/src/features/user/selectors.ts b/dictation_client/src/features/user/selectors.ts index 854e02b..5cb63be 100644 --- a/dictation_client/src/features/user/selectors.ts +++ b/dictation_client/src/features/user/selectors.ts @@ -63,11 +63,8 @@ export const selectUpdateValidationErrors = (state: RootState) => { ); if (passwordError) { - // 最初にEncryptionがfasleで、Encryptionがtrueに変更された場合、EncryptionPasswordが必須 - if (!initEncryption) { - hasErrorIncorrectEncryptionPassword = true; - // Encryptionがある状態で変更がある場合、EncryptionPasswordが空でもエラーにしない - } else if (!encryptionPassword || encryptionPassword === "") { + // 最初にEncryptionがtrueで、EncryptionPassword変更されていない場合はエラーとしない + if (initEncryption && encryptionPassword === undefined) { hasErrorIncorrectEncryptionPassword = false; } else { hasErrorIncorrectEncryptionPassword = true; diff --git a/dictation_client/src/features/user/userSlice.ts b/dictation_client/src/features/user/userSlice.ts index 46066d7..528ca61 100644 --- a/dictation_client/src/features/user/userSlice.ts +++ b/dictation_client/src/features/user/userSlice.ts @@ -90,6 +90,9 @@ export const userSlice = createSlice({ ) => { const { encryption } = action.payload; state.apps.addUser.encryption = encryption; + if (!encryption) { + state.apps.addUser.encryptionPassword = undefined; + } }, changePrompt: (state, action: PayloadAction<{ prompt: boolean }>) => { const { prompt } = action.payload; @@ -170,14 +173,16 @@ export const userSlice = createSlice({ if (initEncryption && encryption && !password) { state.apps.hasPasswordMask = true; } + if (!encryption) { + state.apps.updateUser.encryptionPassword = undefined; + } }, changeUpdateEncryptionPassword: ( state, action: PayloadAction<{ encryptionPassword: string }> ) => { const { encryptionPassword } = action.payload; - state.apps.updateUser.encryptionPassword = - encryptionPassword === "" ? undefined : encryptionPassword; + state.apps.updateUser.encryptionPassword = encryptionPassword; }, changeUpdatePrompt: (state, action: PayloadAction<{ prompt: boolean }>) => { const { prompt } = action.payload; diff --git a/dictation_client/src/pages/UserListPage/index.tsx b/dictation_client/src/pages/UserListPage/index.tsx index 787f902..0f4ac6b 100644 --- a/dictation_client/src/pages/UserListPage/index.tsx +++ b/dictation_client/src/pages/UserListPage/index.tsx @@ -59,14 +59,12 @@ const UserListPage: React.FC = (): JSX.Element => { isOpen={isUpdatePopupOpen} onClose={() => { setIsUpdatePopupOpen(false); - dispatch(listUsersAsync()); }} /> { setIsPopupOpen(false); - dispatch(listUsersAsync()); }} />
diff --git a/dictation_client/src/pages/UserListPage/popup.tsx b/dictation_client/src/pages/UserListPage/popup.tsx index 9e0328f..35c8f0f 100644 --- a/dictation_client/src/pages/UserListPage/popup.tsx +++ b/dictation_client/src/pages/UserListPage/popup.tsx @@ -20,6 +20,7 @@ import { changePrompt, changeEncryption, changeEncryptionPassword, + listUsersAsync, } from "features/user"; import { USER_ROLES } from "components/auth/constants"; import close from "../../assets/images/close.svg"; @@ -75,6 +76,7 @@ export const UserAddPopup: React.FC = (props) => { if (meta.requestStatus === "fulfilled") { closePopup(); + dispatch(listUsersAsync()); } }, [ hasErrorEmptyName, @@ -146,9 +148,9 @@ export const UserAddPopup: React.FC = (props) => {
{t(getTranslationID("userListPage.label.role"))}
-
{t(getTranslationID("userListPage.label.setting"))}

-

-

-

{t(getTranslationID("userListPage.label.role"))}
-
{t(getTranslationID("userListPage.label.setting"))}

-

-

-