diff --git a/app/frontend/src/components/master/Department.tsx b/app/frontend/src/components/master/Department.tsx index 22e05343..6d2216dd 100644 --- a/app/frontend/src/components/master/Department.tsx +++ b/app/frontend/src/components/master/Department.tsx @@ -1,7 +1,7 @@ import React, {useEffect, useState} from "react"; import {useMessage} from "../application/Message.tsx"; import {useModal} from "../application/hooks.ts"; -import {useDepartment, useEmployee, useFetchDepartments, useFetchEmployees} from "./hooks.ts"; +import {useDepartment, useEmployee, useFetchDepartments, useFetchEmployees} from "./hooks"; import {showErrorMessage} from "../application/utils.ts"; import {DepartmentIdType, DepartmentType, EmployeeType} from "../../models"; import Modal from "react-modal"; diff --git a/app/frontend/src/components/master/Employee.tsx b/app/frontend/src/components/master/Employee.tsx index 7d57f9a2..f6ff599c 100644 --- a/app/frontend/src/components/master/Employee.tsx +++ b/app/frontend/src/components/master/Employee.tsx @@ -3,7 +3,7 @@ import Modal from "react-modal"; import {showErrorMessage} from "../application/utils.ts"; import {useMessage} from "../application/Message.tsx"; import {useModal} from "../application/hooks.ts"; -import {useDepartment, useEmployee, useFetchDepartments, useFetchEmployees} from "./hooks.ts"; +import {useDepartment, useEmployee, useFetchDepartments, useFetchEmployees} from "./hooks"; import {EmployeeType} from "../../models"; import {usePageNation} from "../../views/application/PageNation.tsx"; import {SiteLayout} from "../../views/SiteLayout.tsx"; diff --git a/app/frontend/src/components/master/ProductCategory.tsx b/app/frontend/src/components/master/ProductCategory.tsx index b5eb5088..c14c03c1 100644 --- a/app/frontend/src/components/master/ProductCategory.tsx +++ b/app/frontend/src/components/master/ProductCategory.tsx @@ -6,7 +6,7 @@ import {usePageNation} from "../../views/application/PageNation.tsx"; import LoadingIndicator from "../../views/application/LoadingIndicatior.tsx"; import {ProductCategoryType, ProductType} from "../../models"; -import {useFetchProductCategories, useFetchProducts, useProduct, useProductCategory} from "./hooks.ts"; +import {useFetchProductCategories, useFetchProducts, useProduct, useProductCategory} from "./hooks"; import Modal from "react-modal"; import {ProductCategoryCollectionView} from "../../views/master/product/ProductCategoryCollection.tsx"; import {ProductCategorySingleView} from "../../views/master/product/ProductCategorySingle.tsx"; @@ -280,7 +280,6 @@ export const ProductCategory: React.FC = () => { } return ( - <> { collectionItems={{productCategories, handleDeleteProductCategory, handleCheckProductCategory}} pageNationItems={{pageNation, fetchProductCategories: fetchProductCategories.load}} /> - ) }; diff --git a/app/frontend/src/components/master/ProductItem.tsx b/app/frontend/src/components/master/ProductItem.tsx index eb2b2535..c822d718 100644 --- a/app/frontend/src/components/master/ProductItem.tsx +++ b/app/frontend/src/components/master/ProductItem.tsx @@ -5,7 +5,7 @@ import {useMessage} from "../application/Message.tsx"; import {useModal, useTab} from "../application/hooks.ts"; import {usePageNation} from "../../views/application/PageNation.tsx"; import LoadingIndicator from "../../views/application/LoadingIndicatior.tsx"; -import {useFetchBoms, useFetchProducts, useFetchSubstitutes, useProduct} from "./hooks.ts"; +import {useFetchBoms, useFetchProducts, useFetchSubstitutes, useProduct} from "./hooks"; import {ProductType} from "../../models"; import {ProductCollectionView} from "../../views/master/product/ProductCollection.tsx"; import {ProductSingleView} from "../../views/master/product/ProductSingle.tsx"; @@ -156,7 +156,6 @@ export const ProductItem: React.FC = () => { {bomModal().bomEditModalView()} {isEditing && ( - <> 代替品 @@ -228,7 +227,6 @@ export const ProductItem: React.FC = () => { /> - ) } @@ -423,7 +421,6 @@ export const ProductItem: React.FC = () => { } return ( - <> { contentItems={{products, handleDeleteProduct, handleCheckProduct}} pageNationItems={{pageNation, fetchProducts: fetchProducts.load}} /> - ) }; diff --git a/app/frontend/src/components/master/hooks/department.ts b/app/frontend/src/components/master/hooks/department.ts new file mode 100644 index 00000000..98e44ff7 --- /dev/null +++ b/app/frontend/src/components/master/hooks/department.ts @@ -0,0 +1,52 @@ +import {useState} from "react"; +import { + DepartmentIdType, + DepartmentType, + LowerType, + SlitYnType +} from "../../../models"; +import {DepartmentService, DepartmentServiceType} from "../../../services/department.ts"; +import {PageNationType} from "../../../views/application/PageNation.tsx"; +import {useFetchEntities} from "../../application/hooks.ts"; + +export const useDepartment = () => { + const initialDepartment = { + departmentId: {deptCode: {value: ""}, departmentStartDate: {value: ""}}, + endDate: {value: ""}, + departmentName: "", + layer: 0, + path: {value: ""}, + lowerType: LowerType.NO, + slitYn: SlitYnType.NO, + employees: [], + checked: false + }; + + const [departments, setDepartments] = useState([]); + const [newDepartment, setNewDepartment] = useState(initialDepartment); + const [searchDepartmentId, setSearchDepartmentId] = useState({ + deptCode: {value: ""}, + departmentStartDate: {value: ""} + }); + const departmentService = DepartmentService(); + + return { + initialDepartment, + departments, + newDepartment, + setNewDepartment, + searchDepartmentId, + setSearchDepartmentId, + setDepartments, + departmentService, + } +} + +export const useFetchDepartments = ( + setLoading: (loading: boolean) => void, + setList: (list: DepartmentType[]) => void, + setPageNation: (pageNation: PageNationType) => void, + setError: (error: string) => void, + showErrorMessage: (message: string, callback: (error: string) => void) => void, + service: DepartmentServiceType +) => useFetchEntities(setLoading, setList, setPageNation, setError, showErrorMessage, service, "部門情報の取得に失敗しました:"); diff --git a/app/frontend/src/components/master/hooks/employee.ts b/app/frontend/src/components/master/hooks/employee.ts new file mode 100644 index 00000000..80f248d4 --- /dev/null +++ b/app/frontend/src/components/master/hooks/employee.ts @@ -0,0 +1,89 @@ +import {useState} from "react"; +import { + EmployeeType, + LowerType, + SlitYnType +} from "../../../models"; +import {EmployeeService, EmployeeServiceType} from "../../../services/employee.ts"; +import {PageNationType} from "../../../views/application/PageNation.tsx"; +import {useFetchEntities} from "../../application/hooks.ts"; + +export const useEmployee = () => { + const initialEmployee: EmployeeType = { + empCode: {value: ""}, + empName: { + firstName: "", + lastName: "", + firstNameKana: "", + lastNameKana: "" + }, + loginPassword: "", + tel: { + value: "", + areaCode: "", + localExchange: "", + subscriberNumber: "" + }, + fax: { + value: "", + areaCode: "", + localExchange: "", + subscriberNumber: "" + }, + occuCode: { + value: "" + }, + approvalCode: "", + department: { + departmentId: {deptCode: {value: ""}, departmentStartDate: {value: ""}}, + endDate: {value: ""}, + departmentName: "", + layer: 0, + path: {value: ""}, + lowerType: LowerType.NO, + slitYn: SlitYnType.NO, + employees: [], + checked: false + }, + user: { + userId: {value: ""}, + name: { + firstName: "", + lastName: "" + }, + password: { + value: "" + }, + roleName: "" + }, + addFlag: false, + deleteFlag: false, + checked: false + }; + + const [employees, setEmployees] = useState([]); + const [newEmployee, setNewEmployee] = useState(initialEmployee); + const [searchEmployeeCode, setSearchEmployeeCode] = useState(""); + + const employeeService = EmployeeService(); + + return { + initialEmployee, + employees, + newEmployee, + setNewEmployee, + setEmployees, + searchEmployeeCode, + setSearchEmployeeCode, + employeeService, + }; +} + +export const useFetchEmployees = ( + setLoading: (loading: boolean) => void, + setList: (list: EmployeeType[]) => void, + setPageNation: (pageNation: PageNationType) => void, + setError: (error: string) => void, + showErrorMessage: (message: string, callback: (error: string) => void) => void, + service: EmployeeServiceType +) => useFetchEntities(setLoading, setList, setPageNation, setError, showErrorMessage, service, "社員情報の取得に失敗しました:"); diff --git a/app/frontend/src/components/master/hooks/index.ts b/app/frontend/src/components/master/hooks/index.ts new file mode 100644 index 00000000..b0de351e --- /dev/null +++ b/app/frontend/src/components/master/hooks/index.ts @@ -0,0 +1,3 @@ +export * from './department'; +export * from './employee'; +export * from './product'; \ No newline at end of file diff --git a/app/frontend/src/components/master/hooks.ts b/app/frontend/src/components/master/hooks/product.ts similarity index 51% rename from app/frontend/src/components/master/hooks.ts rename to app/frontend/src/components/master/hooks/product.ts index f762824a..f5459c5a 100644 --- a/app/frontend/src/components/master/hooks.ts +++ b/app/frontend/src/components/master/hooks/product.ts @@ -1,142 +1,12 @@ import {useState} from "react"; import { - DepartmentIdType, - DepartmentType, - EmployeeType, - LowerType, ProductCategoryType, - ProductType, - SlitYnType -} from "../../models"; -import {DepartmentService, DepartmentServiceType} from "../../services/department.ts"; -import {EmployeeService, EmployeeServiceType} from "../../services/employee.ts"; -import {PageNationType} from "../../views/application/PageNation.tsx"; -import {ProductCategoryService, ProductCategoryServiceType} from "../../services/product_category.ts"; -import {ProductService, ProductServiceType} from "../../services/product.ts"; -import {useFetchEntities} from "../application/hooks.ts"; - -export const useDepartment = () => { - const initialDepartment = { - departmentId: {deptCode: {value: ""}, departmentStartDate: {value: ""}}, - endDate: {value: ""}, - departmentName: "", - layer: 0, - path: {value: ""}, - lowerType: LowerType.NO, - slitYn: SlitYnType.NO, - employees: [], - checked: false - }; - - const [departments, setDepartments] = useState([]); - const [newDepartment, setNewDepartment] = useState(initialDepartment); - const [searchDepartmentId, setSearchDepartmentId] = useState({ - deptCode: {value: ""}, - departmentStartDate: {value: ""} - }); - const departmentService = DepartmentService(); - - return { - initialDepartment, - departments, - newDepartment, - setNewDepartment, - searchDepartmentId, - setSearchDepartmentId, - setDepartments, - departmentService, - } -} - -export const useFetchDepartments = ( - setLoading: (loading: boolean) => void, - setList: (list: DepartmentType[]) => void, - setPageNation: (pageNation: PageNationType) => void, - setError: (error: string) => void, - showErrorMessage: (message: string, callback: (error: string) => void) => void, - service: DepartmentServiceType -) => useFetchEntities(setLoading, setList, setPageNation, setError, showErrorMessage, service, "部門情報の取得に失敗しました:"); - - -export const useEmployee = () => { - const initialEmployee: EmployeeType = { - empCode: {value: ""}, - empName: { - firstName: "", - lastName: "", - firstNameKana: "", - lastNameKana: "" - }, - loginPassword: "", - tel: { - value: "", - areaCode: "", - localExchange: "", - subscriberNumber: "" - }, - fax: { - value: "", - areaCode: "", - localExchange: "", - subscriberNumber: "" - }, - occuCode: { - value: "" - }, - approvalCode: "", - department: { - departmentId: {deptCode: {value: ""}, departmentStartDate: {value: ""}}, - endDate: {value: ""}, - departmentName: "", - layer: 0, - path: {value: ""}, - lowerType: LowerType.NO, - slitYn: SlitYnType.NO, - employees: [], - checked: false - }, - user: { - userId: {value: ""}, - name: { - firstName: "", - lastName: "" - }, - password: { - value: "" - }, - roleName: "" - }, - addFlag: false, - deleteFlag: false, - checked: false - }; - - const [employees, setEmployees] = useState([]); - const [newEmployee, setNewEmployee] = useState(initialEmployee); - const [searchEmployeeCode, setSearchEmployeeCode] = useState(""); - - const employeeService = EmployeeService(); - - return { - initialEmployee, - employees, - newEmployee, - setNewEmployee, - setEmployees, - searchEmployeeCode, - setSearchEmployeeCode, - employeeService, - }; -} - -export const useFetchEmployees = ( - setLoading: (loading: boolean) => void, - setList: (list: EmployeeType[]) => void, - setPageNation: (pageNation: PageNationType) => void, - setError: (error: string) => void, - showErrorMessage: (message: string, callback: (error: string) => void) => void, - service: EmployeeServiceType -) => useFetchEntities(setLoading, setList, setPageNation, setError, showErrorMessage, service, "社員情報の取得に失敗しました:"); + ProductType +} from "../../../models"; +import {PageNationType} from "../../../views/application/PageNation.tsx"; +import {ProductCategoryService, ProductCategoryServiceType} from "../../../services/product_category.ts"; +import {ProductService, ProductServiceType} from "../../../services/product.ts"; +import {useFetchEntities} from "../../application/hooks.ts"; export const useProductCategory = () => { const initialProductCategory: ProductCategoryType = {