diff --git a/dictation_client/src/features/workflow/template/constants.ts b/dictation_client/src/features/workflow/template/constants.ts
new file mode 100644
index 0000000..358c4c8
--- /dev/null
+++ b/dictation_client/src/features/workflow/template/constants.ts
@@ -0,0 +1,2 @@
+// アップロード可能なファイルサイズの上限(MB)
+export const UPLOAD_FILE_SIZE_LIMIT: number = 5 * 1024 * 1024;
diff --git a/dictation_client/src/features/workflow/template/selectors.ts b/dictation_client/src/features/workflow/template/selectors.ts
index 45c3ccd..4a8522e 100644
--- a/dictation_client/src/features/workflow/template/selectors.ts
+++ b/dictation_client/src/features/workflow/template/selectors.ts
@@ -1,7 +1,26 @@
import { RootState } from "app/store";
+import { UPLOAD_FILE_SIZE_LIMIT } from "./constants";
export const selectTemplates = (state: RootState) =>
state.template.domain.templates;
export const selectIsLoading = (state: RootState) =>
state.template.apps.isLoading;
+
+export const selectUploadFile = (state: RootState) =>
+ state.template.apps.uploadFile;
+
+export const selectUploadFileError = (state: RootState) => {
+ const { uploadFile } = state.template.apps;
+
+ // 必須チェック
+ if (!uploadFile) {
+ return { hasErrorRequired: true, hasErrorFileSize: false };
+ }
+ // ファイルサイズチェック(5MB)
+ if (uploadFile.size > UPLOAD_FILE_SIZE_LIMIT) {
+ return { hasErrorRequired: false, hasErrorFileSize: true };
+ }
+
+ return { hasErrorRequired: false, hasErrorFileSize: false };
+};
diff --git a/dictation_client/src/features/workflow/template/state.ts b/dictation_client/src/features/workflow/template/state.ts
index 8805a9a..8fd0172 100644
--- a/dictation_client/src/features/workflow/template/state.ts
+++ b/dictation_client/src/features/workflow/template/state.ts
@@ -7,6 +7,7 @@ export interface TemplateState {
export interface Apps {
isLoading: boolean;
+ uploadFile?: File;
}
export interface Domain {
diff --git a/dictation_client/src/features/workflow/template/templateSlice.ts b/dictation_client/src/features/workflow/template/templateSlice.ts
index 9bbcab2..a333321 100644
--- a/dictation_client/src/features/workflow/template/templateSlice.ts
+++ b/dictation_client/src/features/workflow/template/templateSlice.ts
@@ -1,20 +1,27 @@
-import { createSlice } from "@reduxjs/toolkit";
+import { PayloadAction, createSlice } from "@reduxjs/toolkit";
import { TemplateState } from "./state";
import { listTemplateAsync } from "./operations";
const initialState: TemplateState = {
apps: {
isLoading: false,
+ uploadFile: undefined,
},
- domain: {
- templates: undefined,
- },
+ domain: {},
};
export const templateSlice = createSlice({
name: "template",
initialState,
- reducers: {},
+ reducers: {
+ cleanupTemplate: (state) => {
+ state.apps.uploadFile = initialState.apps.uploadFile;
+ },
+ changeUploadFile: (state, action: PayloadAction<{ file: File }>) => {
+ const { file } = action.payload;
+ state.apps.uploadFile = file;
+ },
+ },
extraReducers: (builder) => {
builder.addCase(listTemplateAsync.pending, (state) => {
state.apps.isLoading = true;
@@ -31,4 +38,6 @@ export const templateSlice = createSlice({
},
});
+export const { changeUploadFile, cleanupTemplate } = templateSlice.actions;
+
export default templateSlice.reducer;
diff --git a/dictation_client/src/pages/AccountPage/index.tsx b/dictation_client/src/pages/AccountPage/index.tsx
index d407582..8b6c52a 100644
--- a/dictation_client/src/pages/AccountPage/index.tsx
+++ b/dictation_client/src/pages/AccountPage/index.tsx
@@ -127,7 +127,8 @@ const AccountPage: React.FC = (): JSX.Element => {
{isTier5 && !viewInfo.account.parentAccountName && (