Merged PR 360: 画面実装(注文履歴画面修正)

## 概要
[Task2483: 画面実装(注文履歴画面修正)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2483)

- 何をどう変更したか、追加したライブラリなど
Order Cancelボタン押下時にライセンス注文キャンセルAPIを呼び出す処理を追加。

- このPull Requestでの対象/対象外
- 影響範囲(他の機能にも影響があるか)
特になし

## レビューポイント
- 特にレビューしてほしい箇所
- 軽微なものや自明なものは記載不要
- 修正範囲が大きい場合などに記載
- 全体的にや仕様を満たしているか等は本当に必要な時のみ記載

## UIの変更
特になし

## 動作確認状況
- ローカルで確認

## 補足
- 相談、参考資料などがあれば
特になし
This commit is contained in:
masaaki 2023-08-29 01:29:34 +00:00
parent 89751396bf
commit ef8e6c44ec
9 changed files with 5814 additions and 4034 deletions

File diff suppressed because it is too large Load Diff

View File

@ -47,4 +47,5 @@ export const errorCodes = [
"E010805", // ライセンス有効期限切れエラー
"E010806", // ライセンス割り当て不可エラー
"E010807", // ライセンス割り当て解除不可エラー
"E010808", // ライセンス注文キャンセル不可エラー
] as const;

View File

@ -1,6 +1,10 @@
import { PayloadAction, createSlice } from "@reduxjs/toolkit";
import { LicenseOrderHistoryState } from "./state";
import { getLicenseOrderHistoriesAsync, issueLicenseAsync } from "./operations";
import {
getLicenseOrderHistoriesAsync,
issueLicenseAsync,
cancelOrderAsync,
} from "./operations";
import { LIMIT_ORDER_HISORY_NUM } from "./constants";
const initialState: LicenseOrderHistoryState = {
@ -61,6 +65,15 @@ export const licenseOrderHistorySlice = createSlice({
builder.addCase(issueLicenseAsync.rejected, (state) => {
state.apps.isLoading = false;
});
builder.addCase(cancelOrderAsync.pending, (state) => {
state.apps.isLoading = true;
});
builder.addCase(cancelOrderAsync.fulfilled, (state) => {
state.apps.isLoading = false;
});
builder.addCase(cancelOrderAsync.rejected, (state) => {
state.apps.isLoading = false;
});
},
});

View File

@ -2,7 +2,7 @@ import { createAsyncThunk } from "@reduxjs/toolkit";
import type { RootState } from "app/store";
import { getTranslationID } from "translation";
import { openSnackbar } from "features/ui/uiSlice";
import { AccountsApi } from "../../../api/api";
import { AccountsApi, LicensesApi } from "../../../api/api";
import { Configuration } from "../../../api/configuration";
import { ErrorObject, createErrorObject } from "../../../common/errors";
import { OrderHistoryView } from "./types";
@ -141,3 +141,64 @@ export const issueLicenseAsync = createAsyncThunk<
return thunkApi.rejectWithValue({ error });
}
});
export const cancelOrderAsync = createAsyncThunk<
{
/* Empty Object */
},
{
// パラメータ
poNumber: string;
},
{
// rejectした時の返却値の型
rejectValue: {
error: ErrorObject;
};
}
>("licenses/cancelOrderAsync", async (args, thunkApi) => {
const { poNumber } = args;
// apiのConfigurationを取得する
const { getState } = thunkApi;
const state = getState() as RootState;
const { configuration, accessToken } = state.auth;
const config = new Configuration(configuration);
const licensesApi = new LicensesApi(config);
try {
await licensesApi.cancelOrder(
{
poNumber,
},
{
headers: { authorization: `Bearer ${accessToken}` },
}
);
thunkApi.dispatch(
openSnackbar({
level: "info",
message: getTranslationID("common.message.success"),
})
);
return {};
} catch (e) {
// e ⇒ errorObjectに変換"
const error = createErrorObject(e);
let errorMessage = getTranslationID("common.message.internalServerError");
if (error.code === "E010808") {
errorMessage = getTranslationID(
"orderHistoriesPage.message.alreadyLicenseIssueOrCancel"
);
}
thunkApi.dispatch(
openSnackbar({
level: "error",
message: errorMessage,
})
);
return thunkApi.rejectWithValue({ error });
}
});

View File

@ -18,6 +18,7 @@ import {
selectTotal,
selectTotalPage,
issueLicenseAsync,
cancelOrderAsync,
selectOffset,
savePageInfo,
selectCompanyName,
@ -85,6 +86,27 @@ export const LicenseOrderHistory: React.FC<LicenseOrderHistoryProps> = (
[dispatch]
);
// Order Cancelボタンを押下時の処理
const onCancelOrder = useCallback(
async (poNumber: string) => {
// ダイアログ確認
// eslint-disable-next-line no-alert
if (window.confirm(t(getTranslationID("common.message.dialogConfirm")))) {
// ライセンス注文キャンセルAPIの呼び出し
const { meta } = await dispatch(
cancelOrderAsync({
poNumber,
})
);
if (meta.requestStatus === "fulfilled") {
UpdateHistoriesList();
}
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[dispatch]
);
// ページネーションのボタンクリック時のアクション
const movePage = (targetOffset: number) => {
dispatch(
@ -207,12 +229,16 @@ export const LicenseOrderHistory: React.FC<LicenseOrderHistoryProps> = (
className={`${styles.menuAction} ${styles.inTable}`}
>
<li>
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}
<a
className={`${styles.menuLink} ${
x.status === STATUS.ISSUE_REQESTING
? styles.isActive
: ""
}`}
onClick={() => {
onCancelOrder(x.poNumber);
}}
>
{t(
getTranslationID(

View File

@ -329,7 +329,8 @@
},
"message": {
"notEnoughOfNumberOfLicense": "(de)ライセンスが不足しているため、発行することができませんでした。ライセンスの注文を行ってください。",
"alreadyIssueLicense": "(de)すでに発行済みの注文です。画面を更新してください。"
"alreadyIssueLicense": "(de)すでに発行済みの注文です。画面を更新してください。",
"alreadyLicenseIssueOrCancel": "(de)ライセンス注文のキャンセルに失敗しました。選択された注文はすでに発行またはキャンセルされています。画面を更新して再度ご確認ください。"
}
},
"allocateLicensePopupPage": {

View File

@ -329,7 +329,8 @@
},
"message": {
"notEnoughOfNumberOfLicense": "ライセンスが不足しているため、発行することができませんでした。ライセンスの注文を行ってください。",
"alreadyIssueLicense": "すでに発行済みの注文です。画面を更新してください。"
"alreadyIssueLicense": "すでに発行済みの注文です。画面を更新してください。",
"alreadyLicenseIssueOrCancel": "ライセンス注文のキャンセルに失敗しました。選択された注文はすでに発行またはキャンセルされています。画面を更新して再度ご確認ください。"
}
},
"allocateLicensePopupPage": {

View File

@ -329,7 +329,8 @@
},
"message": {
"notEnoughOfNumberOfLicense": "(es)ライセンスが不足しているため、発行することができませんでした。ライセンスの注文を行ってください。",
"alreadyIssueLicense": "(es)すでに発行済みの注文です。画面を更新してください。"
"alreadyIssueLicense": "(es)すでに発行済みの注文です。画面を更新してください。",
"alreadyLicenseIssueOrCancel": "(es)ライセンス注文のキャンセルに失敗しました。選択された注文はすでに発行またはキャンセルされています。画面を更新して再度ご確認ください。"
}
},
"allocateLicensePopupPage": {

View File

@ -329,7 +329,8 @@
},
"message": {
"notEnoughOfNumberOfLicense": "(fr)ライセンスが不足しているため、発行することができませんでした。ライセンスの注文を行ってください。",
"alreadyIssueLicense": "(fr)すでに発行済みの注文です。画面を更新してください。"
"alreadyIssueLicense": "(fr)すでに発行済みの注文です。画面を更新してください。",
"alreadyLicenseIssueOrCancel": "(fr)ライセンス注文のキャンセルに失敗しました。選択された注文はすでに発行またはキャンセルされています。画面を更新して再度ご確認ください。"
}
},
"allocateLicensePopupPage": {