From b59a5df44cb356df91cdcb29ee30515e325aa251 Mon Sep 17 00:00:00 2001 From: "oura.a" Date: Mon, 7 Aug 2023 01:52:03 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20303:=20PBI1224=5Fdev=E5=8B=95?= =?UTF-8?q?=E4=BD=9C=E7=A2=BA=E8=AA=8D=E6=8C=87=E6=91=98=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2325: PBI1224_dev動作確認指摘対応](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2325) 前PBIで指摘のあった箇所を修正しました。 ・IssueDateが空白の場合「-」とするように修正 ・ページ上部の「EFGI Legal」に会社名を入れるように修正 ・上記に伴い、アカウント情報取得API(accounts/me)で会社名を取得できるように修正 ・ページネーションの位置を修正 ・ページネーション部分に表示されている「xxx licenses」を「xxx histories」に修正 ・ページネーション周りの挙動を修正 ## レビューポイント なし ## UIの変更 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/Task2325?csf=1&web=1&e=g6hYEy ## 動作確認状況 ローカルで動作確認済み ## 補足 なし --- dictation_client/src/api/api.ts | 110 +++++++++++++++++- .../licenseOrderHistorySlice.ts | 21 +++- .../license/licenseOrderHistory/operations.ts | 16 ++- .../license/licenseOrderHistory/selectors.ts | 3 + .../license/licenseOrderHistory/state.ts | 1 + .../license/licenseOrderHistory/types.ts | 6 + .../partnerLicense/partnerLicenseSlice.ts | 2 +- .../pages/LicensePage/licenseOrderHistory.tsx | 90 ++++++-------- dictation_client/src/styles/app.module.scss | 24 +++- .../src/styles/app.module.scss.d.ts | 1 + dictation_client/src/translation/de.json | 3 +- dictation_client/src/translation/en.json | 3 +- dictation_client/src/translation/es.json | 3 +- dictation_client/src/translation/fr.json | 3 +- dictation_server/src/api/odms/openapi.json | 7 +- .../features/accounts/accounts.controller.ts | 8 +- .../src/features/accounts/accounts.service.ts | 31 ++++- .../src/features/accounts/types/types.ts | 2 + 18 files changed, 248 insertions(+), 86 deletions(-) create mode 100644 dictation_client/src/features/license/licenseOrderHistory/types.ts diff --git a/dictation_client/src/api/api.ts b/dictation_client/src/api/api.ts index ebfe077..180551e 100644 --- a/dictation_client/src/api/api.ts +++ b/dictation_client/src/api/api.ts @@ -48,6 +48,12 @@ export interface Account { * @memberof Account */ 'accountId': number; + /** + * + * @type {string} + * @memberof Account + */ + 'companyName': string; } /** * @@ -513,19 +519,19 @@ export interface GetOrderHistoriesRequest { /** * * @export - * @interface GetOrderHistoriesResponce + * @interface GetOrderHistoriesResponse */ -export interface GetOrderHistoriesResponce { +export interface GetOrderHistoriesResponse { /** * 合計件数 * @type {number} - * @memberof GetOrderHistoriesResponce + * @memberof GetOrderHistoriesResponse */ 'total': number; /** * * @type {Array} - * @memberof GetOrderHistoriesResponce + * @memberof GetOrderHistoriesResponse */ 'orderHistories': Array; } @@ -718,6 +724,25 @@ export interface IssueCardLicensesResponse { */ 'cardLicenseKeys': Array; } +/** + * + * @export + * @interface IssueLicenseRequest + */ +export interface IssueLicenseRequest { + /** + * 注文元アカウントID + * @type {number} + * @memberof IssueLicenseRequest + */ + 'orderedAccountId': number; + /** + * POナンバー + * @type {string} + * @memberof IssueLicenseRequest + */ + 'poNumber': string; +} /** * * @export @@ -1696,6 +1721,46 @@ export const AccountsApiAxiosParamCreator = function (configuration?: Configurat let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary + * @param {IssueLicenseRequest} issueLicenseRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + issueLicense: async (issueLicenseRequest: IssueLicenseRequest, options: AxiosRequestConfig = {}): Promise => { + // verify required parameter 'issueLicenseRequest' is not null or undefined + assertParamExists('issueLicense', 'issueLicenseRequest', issueLicenseRequest) + const localVarPath = `/accounts/licenses/issue`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication bearer required + // http bearer authentication required + await setBearerAuthToObject(localVarHeaderParameter, configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(issueLicenseRequest, localVarRequestOptions, configuration) + return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, @@ -1761,7 +1826,7 @@ export const AccountsApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async getOrderHistories(getOrderHistoriesRequest: GetOrderHistoriesRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + async getOrderHistories(getOrderHistoriesRequest: GetOrderHistoriesRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getOrderHistories(getOrderHistoriesRequest, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, @@ -1796,6 +1861,17 @@ export const AccountsApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.getTypists(options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @summary + * @param {IssueLicenseRequest} issueLicenseRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async issueLicense(issueLicenseRequest: IssueLicenseRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.issueLicense(issueLicenseRequest, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, } }; @@ -1852,7 +1928,7 @@ export const AccountsApiFactory = function (configuration?: Configuration, baseP * @param {*} [options] Override http request option. * @throws {RequiredError} */ - getOrderHistories(getOrderHistoriesRequest: GetOrderHistoriesRequest, options?: any): AxiosPromise { + getOrderHistories(getOrderHistoriesRequest: GetOrderHistoriesRequest, options?: any): AxiosPromise { return localVarFp.getOrderHistories(getOrderHistoriesRequest, options).then((request) => request(axios, basePath)); }, /** @@ -1883,6 +1959,16 @@ export const AccountsApiFactory = function (configuration?: Configuration, baseP getTypists(options?: any): AxiosPromise { return localVarFp.getTypists(options).then((request) => request(axios, basePath)); }, + /** + * + * @summary + * @param {IssueLicenseRequest} issueLicenseRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + issueLicense(issueLicenseRequest: IssueLicenseRequest, options?: any): AxiosPromise { + return localVarFp.issueLicense(issueLicenseRequest, options).then((request) => request(axios, basePath)); + }, }; }; @@ -1985,6 +2071,18 @@ export class AccountsApi extends BaseAPI { public getTypists(options?: AxiosRequestConfig) { return AccountsApiFp(this.configuration).getTypists(options).then((request) => request(this.axios, this.basePath)); } + + /** + * + * @summary + * @param {IssueLicenseRequest} issueLicenseRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AccountsApi + */ + public issueLicense(issueLicenseRequest: IssueLicenseRequest, options?: AxiosRequestConfig) { + return AccountsApiFp(this.configuration).issueLicense(issueLicenseRequest, options).then((request) => request(this.axios, this.basePath)); + } } diff --git a/dictation_client/src/features/license/licenseOrderHistory/licenseOrderHistorySlice.ts b/dictation_client/src/features/license/licenseOrderHistory/licenseOrderHistorySlice.ts index 5e1f0f6..d86f33c 100644 --- a/dictation_client/src/features/license/licenseOrderHistory/licenseOrderHistorySlice.ts +++ b/dictation_client/src/features/license/licenseOrderHistory/licenseOrderHistorySlice.ts @@ -1,4 +1,4 @@ -import { createSlice } from "@reduxjs/toolkit"; +import { PayloadAction, createSlice } from "@reduxjs/toolkit"; import { LicenseOrderHistoryState } from "./state"; import { getLicenseOrderHistoriesAsync } from "./operations"; import { LIMIT_ORDER_HISORY_NUM } from "./constants"; @@ -7,6 +7,7 @@ const initialState: LicenseOrderHistoryState = { domain: { total: 0, orderHistories: [], + companyName: "", }, apps: { limit: LIMIT_ORDER_HISORY_NUM, @@ -23,6 +24,17 @@ export const licenseOrderHistorySlice = createSlice({ cleanupApps: (state) => { state.domain = initialState.domain; }, + savePageInfo: ( + state, + action: PayloadAction<{ + limit: number; + offset: number; + }> + ) => { + const { limit, offset } = action.payload; + state.apps.limit = limit; + state.apps.offset = offset; + }, }, extraReducers: (builder) => { builder.addCase(getLicenseOrderHistoriesAsync.pending, (state) => { @@ -31,8 +43,9 @@ export const licenseOrderHistorySlice = createSlice({ builder.addCase( getLicenseOrderHistoriesAsync.fulfilled, (state, action) => { - state.domain.total = action.payload.total; - state.domain.orderHistories = action.payload.orderHistories; + state.domain.total = action.payload.histories.total; + state.domain.orderHistories = action.payload.histories.orderHistories; + state.domain.companyName = action.payload.companyName; state.apps.isLoading = false; } ); @@ -42,6 +55,6 @@ export const licenseOrderHistorySlice = createSlice({ }, }); -export const { cleanupApps } = licenseOrderHistorySlice.actions; +export const { cleanupApps, savePageInfo } = licenseOrderHistorySlice.actions; export default licenseOrderHistorySlice.reducer; diff --git a/dictation_client/src/features/license/licenseOrderHistory/operations.ts b/dictation_client/src/features/license/licenseOrderHistory/operations.ts index 307662c..75632d5 100644 --- a/dictation_client/src/features/license/licenseOrderHistory/operations.ts +++ b/dictation_client/src/features/license/licenseOrderHistory/operations.ts @@ -2,13 +2,14 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; import type { RootState } from "app/store"; import { getTranslationID } from "translation"; import { openSnackbar } from "features/ui/uiSlice"; -import { AccountsApi, GetOrderHistoriesResponce } from "../../../api/api"; +import { AccountsApi } from "../../../api/api"; import { Configuration } from "../../../api/configuration"; import { ErrorObject, createErrorObject } from "../../../common/errors"; +import { OrderHistoryView } from "./types"; export const getLicenseOrderHistoriesAsync = createAsyncThunk< // 正常時の戻り値の型 - GetOrderHistoriesResponce, + OrderHistoryView, { // パラメータ limit: number; @@ -32,15 +33,18 @@ export const getLicenseOrderHistoriesAsync = createAsyncThunk< try { const { selectedRow } = state.partnerLicense.apps; let accountId = 0; + let companyName = ""; // 他の画面から指定されていない場合はログインアカウントのidを取得する if (!selectedRow) { const getMyAccountResponse = await accountsApi.getMyAccount({ headers: { authorization: `Bearer ${accessToken}` }, }); - // accountIDを返す + // アカウントID,アカウント名を返す accountId = getMyAccountResponse.data.account.accountId; + companyName = getMyAccountResponse.data.account.companyName; } else { accountId = selectedRow.accountId; + companyName = selectedRow.companyName; } const res = await accountsApi.getOrderHistories( @@ -53,7 +57,11 @@ export const getLicenseOrderHistoriesAsync = createAsyncThunk< headers: { authorization: `Bearer ${accessToken}` }, } ); - return res.data; + const ret = { + histories: res.data, + companyName, + }; + return ret; } catch (e) { // e ⇒ errorObjectに変換" const error = createErrorObject(e); diff --git a/dictation_client/src/features/license/licenseOrderHistory/selectors.ts b/dictation_client/src/features/license/licenseOrderHistory/selectors.ts index 7edf09a..e3e4ceb 100644 --- a/dictation_client/src/features/license/licenseOrderHistory/selectors.ts +++ b/dictation_client/src/features/license/licenseOrderHistory/selectors.ts @@ -4,6 +4,9 @@ import { ceil, floor } from "lodash"; export const selectOrderHisory = (state: RootState) => state.licenseOrderHistory.domain.orderHistories; +export const selectCompanyName = (state: RootState) => + state.licenseOrderHistory.domain.companyName; + export const selectTotal = (state: RootState) => state.licenseOrderHistory.domain.total; diff --git a/dictation_client/src/features/license/licenseOrderHistory/state.ts b/dictation_client/src/features/license/licenseOrderHistory/state.ts index 6713e4a..4abde24 100644 --- a/dictation_client/src/features/license/licenseOrderHistory/state.ts +++ b/dictation_client/src/features/license/licenseOrderHistory/state.ts @@ -8,6 +8,7 @@ export interface LicenseOrderHistoryState { export interface Domain { total: number; orderHistories: LicenseOrder[]; + companyName: string; } export interface Apps { diff --git a/dictation_client/src/features/license/licenseOrderHistory/types.ts b/dictation_client/src/features/license/licenseOrderHistory/types.ts new file mode 100644 index 0000000..b44ced1 --- /dev/null +++ b/dictation_client/src/features/license/licenseOrderHistory/types.ts @@ -0,0 +1,6 @@ +import { GetOrderHistoriesResponse } from "../../../api/api"; + +export interface OrderHistoryView { + histories: GetOrderHistoriesResponse; + companyName: string; +} diff --git a/dictation_client/src/features/license/partnerLicense/partnerLicenseSlice.ts b/dictation_client/src/features/license/partnerLicense/partnerLicenseSlice.ts index 1b584b7..259eb02 100644 --- a/dictation_client/src/features/license/partnerLicense/partnerLicenseSlice.ts +++ b/dictation_client/src/features/license/partnerLicense/partnerLicenseSlice.ts @@ -6,7 +6,7 @@ import { ACCOUNTS_VIEW_LIMIT } from "./constants"; const initialState: PartnerLicensesState = { domain: { - myAccountInfo: { accountId: 0 }, + myAccountInfo: { accountId: 0, companyName: "" }, total: 0, ownPartnerLicense: { accountId: 0, diff --git a/dictation_client/src/pages/LicensePage/licenseOrderHistory.tsx b/dictation_client/src/pages/LicensePage/licenseOrderHistory.tsx index 7cfda4f..8713d6e 100644 --- a/dictation_client/src/pages/LicensePage/licenseOrderHistory.tsx +++ b/dictation_client/src/pages/LicensePage/licenseOrderHistory.tsx @@ -17,6 +17,9 @@ import { selectOrderHisory, selectTotal, selectTotalPage, + selectOffset, + savePageInfo, + selectCompanyName, } from "features/license/licenseOrderHistory"; import { selectSelectedRow } from "features/license/partnerLicense"; import undo from "../../assets/images/undo.svg"; @@ -34,6 +37,7 @@ export const LicenseOrderHistory: React.FC = ( const [t] = useTranslation(); const total = useSelector(selectTotal); const totalPage = useSelector(selectTotalPage); + const offset = useSelector(selectOffset); const currentPage = useSelector(selectCurrentPage); const isLoading = useSelector(selectIsLoading); const selectedRow = useSelector(selectSelectedRow); @@ -47,56 +51,25 @@ export const LicenseOrderHistory: React.FC = ( }, [isLoading, onReturn]); // ページネーションのボタンクリック時のアクション - const getFirstPage = useCallback(() => { + const movePage = (targetOffset: number) => { dispatch( - getLicenseOrderHistoriesAsync({ - limit: LIMIT_ORDER_HISORY_NUM, - offset: 0, - }) + savePageInfo({ limit: LIMIT_ORDER_HISORY_NUM, offset: targetOffset }) ); - }, [dispatch]); - - const getLastPage = useCallback(() => { - const lastPageOffset = (totalPage - 1) * LIMIT_ORDER_HISORY_NUM; - dispatch( - getLicenseOrderHistoriesAsync({ - limit: LIMIT_ORDER_HISORY_NUM, - offset: lastPageOffset, - }) - ); - }, [dispatch, totalPage]); - - const getPrevPage = useCallback(() => { - const prevPageOffset = (currentPage - 2) * LIMIT_ORDER_HISORY_NUM; - dispatch( - getLicenseOrderHistoriesAsync({ - limit: LIMIT_ORDER_HISORY_NUM, - offset: prevPageOffset, - }) - ); - }, [dispatch, currentPage]); - - const getNextPage = useCallback(() => { - const nextPageOffset = currentPage * LIMIT_ORDER_HISORY_NUM; - dispatch( - getLicenseOrderHistoriesAsync({ - limit: LIMIT_ORDER_HISORY_NUM, - offset: nextPageOffset, - }) - ); - }, [dispatch, currentPage]); + }; // apiからの値取得関係 const licenseOrderHistory = useSelector(selectOrderHisory); + const companyName = useSelector(selectCompanyName); useEffect(() => { dispatch( getLicenseOrderHistoriesAsync({ limit: LIMIT_ORDER_HISORY_NUM, - offset: 0, + offset, }) ); - }, [dispatch]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [dispatch, currentPage]); return (
@@ -104,7 +77,7 @@ export const LicenseOrderHistory: React.FC = (
-
+

{t(getTranslationID("orderHistoriesPage.label.title"))} @@ -112,13 +85,12 @@ export const LicenseOrderHistory: React.FC = (

-

- {t(getTranslationID("orderHistoriesPage.label.subTitle"))} -

- - {t(getTranslationID("orderHistoriesPage.label.orderHistory"))} -

-

+

{companyName}

+

+ + {t(getTranslationID("orderHistoriesPage.label.orderHistory"))} +

+
  • {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */} @@ -166,7 +138,7 @@ export const LicenseOrderHistory: React.FC = ( // eslint-disable-next-line react/jsx-key {x.orderDate} - {x.issueDate} + {x.issueDate ? x.issueDate : "-"} {x.numberOfOrder} {x.poNumber} @@ -267,17 +239,19 @@ export const LicenseOrderHistory: React.FC = ( /> )} {/** pagenation */} -
    +