Merged PR 420: 結合動作確認不具合対応
## 概要 [Task2684: 結合動作確認不具合対応](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2684) - Active WorktypeIDの変更について結合動作確認で見つかった不具合に対応しました。 - ActiveWorktypeIDの変更がダイアログ表示の前にセレクトボックスに反映される - 変更成功時に成功スナックバーを表示する ## レビューポイント - セレクトボックスの変更時のイベントの取り扱いは適切か ## UIの変更 - [Task2648](https://ndstokyo.sharepoint.com/:f:/r/sites/Piranha/Shared%20Documents/General/OMDS/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88/Task2648?csf=1&web=1&e=rxWAF0) ## 動作確認状況 - ローカルで確認
This commit is contained in:
parent
3f5f75a48f
commit
ec5df50aa0
@ -312,6 +312,12 @@ export const updateActiveWorktypeAsync = createAsyncThunk<
|
|||||||
headers: { authorization: `Bearer ${accessToken}` },
|
headers: { authorization: `Bearer ${accessToken}` },
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
thunkApi.dispatch(
|
||||||
|
openSnackbar({
|
||||||
|
level: "info",
|
||||||
|
message: getTranslationID("common.message.success"),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { UpdateTokenTimer } from "components/auth/updateTokenTimer";
|
import { UpdateTokenTimer } from "components/auth/updateTokenTimer";
|
||||||
import Footer from "components/footer";
|
import Footer from "components/footer";
|
||||||
import Header from "components/header";
|
import Header from "components/header";
|
||||||
import React, { useCallback, useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { getTranslationID } from "translation";
|
import { getTranslationID } from "translation";
|
||||||
import styles from "styles/app.module.scss";
|
import styles from "styles/app.module.scss";
|
||||||
import undo from "assets/images/undo.svg";
|
import undo from "assets/images/undo.svg";
|
||||||
@ -39,32 +39,51 @@ const WorktypeIdSettingPage: React.FC = (): JSX.Element => {
|
|||||||
const [isShowEditOptionItemPopup, setIsShowEditOptionItemPopup] =
|
const [isShowEditOptionItemPopup, setIsShowEditOptionItemPopup] =
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
|
|
||||||
|
// ActiveWorktypeIDのセレクトボックス表示の値
|
||||||
|
const [selectedActiveWorktypeId, setSelectedActiveWorktypeId] = useState<
|
||||||
|
number | undefined
|
||||||
|
>(undefined);
|
||||||
|
|
||||||
|
// 初期表示
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(listWorktypesAsync());
|
dispatch(listWorktypesAsync());
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
const onChangeActiveWorktype = useCallback(
|
// APIから取得したactiveWorktypeIdを画面表示に反映
|
||||||
async (e: React.ChangeEvent<HTMLSelectElement>) => {
|
useEffect(() => {
|
||||||
|
setSelectedActiveWorktypeId(activeWorktypeId);
|
||||||
|
}, [activeWorktypeId]);
|
||||||
|
|
||||||
|
// ActiveWorktypeIDのセレクトボックス変更時(セレクトボックスに表示するActiveWorktypeIDの変更時)
|
||||||
|
useEffect(() => {
|
||||||
|
// 画面表示の変更後にダイアログを表示するため、setTimeoutを使用
|
||||||
|
const timeout = setTimeout(async () => {
|
||||||
|
if (selectedActiveWorktypeId === activeWorktypeId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// ダイアログ確認
|
// ダイアログ確認
|
||||||
if (
|
if (
|
||||||
// eslint-disable-next-line no-alert
|
// eslint-disable-next-line no-alert
|
||||||
!window.confirm(t(getTranslationID("common.message.dialogConfirm")))
|
!window.confirm(t(getTranslationID("common.message.dialogConfirm")))
|
||||||
) {
|
) {
|
||||||
|
setSelectedActiveWorktypeId(activeWorktypeId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { value } = e.target;
|
|
||||||
const active = value === "" ? undefined : Number(value);
|
|
||||||
|
|
||||||
const { meta } = await dispatch(
|
const { meta } = await dispatch(
|
||||||
updateActiveWorktypeAsync({ id: active })
|
updateActiveWorktypeAsync({ id: selectedActiveWorktypeId })
|
||||||
);
|
);
|
||||||
|
|
||||||
if (meta.requestStatus === "fulfilled") {
|
if (meta.requestStatus === "fulfilled") {
|
||||||
dispatch(listWorktypesAsync());
|
dispatch(listWorktypesAsync());
|
||||||
|
} else {
|
||||||
|
setSelectedActiveWorktypeId(activeWorktypeId);
|
||||||
}
|
}
|
||||||
},
|
}, 0);
|
||||||
[dispatch, t]
|
return () => {
|
||||||
);
|
clearTimeout(timeout);
|
||||||
|
};
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [selectedActiveWorktypeId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -140,8 +159,12 @@ const WorktypeIdSettingPage: React.FC = (): JSX.Element => {
|
|||||||
<select
|
<select
|
||||||
name="Active Worktype"
|
name="Active Worktype"
|
||||||
className={styles.formInput}
|
className={styles.formInput}
|
||||||
value={activeWorktypeId ?? ""}
|
value={selectedActiveWorktypeId ?? ""}
|
||||||
onChange={onChangeActiveWorktype}
|
onChange={(e) => {
|
||||||
|
const { value } = e.target;
|
||||||
|
const active = value === "" ? undefined : Number(value);
|
||||||
|
setSelectedActiveWorktypeId(active);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
|
{/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
|
||||||
<option value="" />
|
<option value="" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user