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 */} -
    +