From 56135ae10cff166572a4b96755e1b4e86a9d6b23 Mon Sep 17 00:00:00 2001 From: AlexSserb Date: Wed, 5 Mar 2025 16:56:39 +0400 Subject: [PATCH] feat: generation of modules from the server, moved modules fields from the general tab --- generateModules.sh | 3 + package.json | 1 + src/client/index.ts | 7 + src/client/models/CardGeneralInfoSchema.ts | 1 - src/client/models/ModuleSchema.ts | 1 + .../ProductsAndServicesGeneralInfoRequest.ts | 10 ++ .../ProductsAndServicesGeneralInfoResponse.ts | 9 ++ .../ProductsAndServicesGeneralInfoSchema.ts | 8 + src/client/models/UpdateCardClientRequest.ts | 9 ++ src/client/models/UpdateCardClientResponse.ts | 9 ++ src/client/models/UpdateCardManagerRequest.ts | 9 ++ .../models/UpdateCardManagerResponse.ts | 9 ++ src/client/services/CardService.ts | 66 ++++++++ .../CardAttributeFields.tsx | 2 +- .../components/CardAttributeField.tsx | 2 +- ...lStatusSelect.tsx => CardStatusSelect.tsx} | 4 +- .../Dnd/Cards/CardGroupView/CardGroupView.tsx | 33 ++-- .../Cards/CardSummaryItem/CardSummaryItem.tsx | 2 +- .../Cards/CardsDndColumn/CardsDndColumn.tsx | 2 +- .../CreateCardButton/CreateCardButton.tsx | 2 +- .../Cards/CreateCardForm/CreateCardForm.tsx | 2 +- src/components/Dnd/Statuses/Status/Status.tsx | 2 +- .../ManagerSelect/ManagerSelect.tsx | 4 +- .../Selects/ClientSelect/ClientSelect.tsx | 4 +- src/hooks/usePollingEffect.tsx | 2 +- src/main.tsx | 7 +- src/modals/modals.ts | 10 +- .../cardEditorTabs/ClientTab/ClientTab.tsx | 147 ++++++++++++++++++ .../EmployeesTab/EmployeesTab.tsx | 0 .../components/AvailableEmployeesSelect.tsx | 0 .../EmployeesTab/components/EmployeeInput.tsx | 0 .../components/EmployeesTable.tsx | 2 +- .../hooks/useAvailableEmployeesList.tsx | 0 .../EmployeesTab/hooks/useEmployeesTab.tsx | 2 +- .../hooks/useEmployeesTableColumns.tsx | 0 .../modals/AssignEmployeeModal.tsx | 0 .../types/AssignUserModalForm.tsx | 0 .../ManagersTab/ManagersTab.tsx | 70 +++++++++ .../ProductAndServiceTab.module.css | 2 +- .../ProductAndServiceTab.tsx | 58 ++++--- .../CardServicesTable}/CardServicesTable.tsx | 2 +- .../GeneralDataForm/GeneralDataForm.tsx | 107 +++++++++++++ .../PaymentLinkButton}/PaymentLinkButton.tsx | 8 +- .../PrintDealBarcodesButton.tsx | 14 +- .../ProductServicesTable.tsx | 2 +- .../ProductServicesTable/columns.tsx | 0 .../ProductView/ProductView.module.css | 0 .../components/ProductView/ProductView.tsx | 0 .../hooks/useProductAndServiceTabState.tsx | 2 +- .../modals/AddCardProductModal.tsx | 6 +- .../modals/AddCardServiceModal.tsx | 10 +- .../modals/ProductServiceFormModal.tsx | 10 +- .../ShippingTab/ShippingTab.module.css | 0 .../ShippingTab/ShippingTab.tsx | 0 .../ShippingTab/components/BoxesTable.tsx | 12 +- .../components/InlineShippingButton.tsx | 0 .../components/ShippingProductSelect.tsx | 0 .../components/ShippingProductsTable.tsx | 0 .../ShippingTab/components/ShippingTree.tsx | 2 +- .../hooks/shippingTableColumns.tsx | 2 +- .../ShippingTab/hooks/useShipping.tsx | 2 +- .../ShippingTab/hooks/useShippingQrs.tsx | 2 +- .../ShippingTab/hooks/useUpdateCard.tsx | 2 +- .../modals/ShippingProductModal.tsx | 0 .../ShippingTab/types/ShippingProductData.tsx | 0 .../ShippingTab/utils/getRestProducts.tsx | 0 src/modules/connectModules.tsx | 20 +++ src/modules/context/ModulesContext.tsx | 54 +++++++ src/modules/modules.tsx | 21 +++ src/modules/modulesFileGen/modulesFileGen.cjs | 61 ++++++++ src/modules/modulesFileGen/modulesFileGen.ts | 86 ++++++++++ src/modules/types.tsx | 16 ++ .../utils/isModuleInProject.ts | 3 +- src/pages/CardPage/ui/CardPage.tsx | 2 +- .../drawers/CardEditDrawer/CardEditDrawer.tsx | 58 ++++--- .../CardStatusChangeTable.tsx | 4 +- .../tabs}/CardStatusChangeTable/columns.tsx | 2 +- .../tabs/GeneralTab/GeneralTab.tsx | 137 +++------------- .../ProductPreview/ProductPreview.tsx | 2 +- .../hooks/usePrefillCard.tsx | 2 +- .../modals/CardsTableFiltersModal.tsx | 6 +- .../CardsPage/tabs/ClientTab/ClientTab.tsx | 103 ------------ .../ProfitTab/components/Filters/Filters.tsx | 4 +- src/routeTree.gen.ts | 24 ++- src/types/utils.ts | 2 +- 85 files changed, 924 insertions(+), 367 deletions(-) create mode 100755 generateModules.sh create mode 100644 src/client/models/ProductsAndServicesGeneralInfoRequest.ts create mode 100644 src/client/models/ProductsAndServicesGeneralInfoResponse.ts create mode 100644 src/client/models/ProductsAndServicesGeneralInfoSchema.ts create mode 100644 src/client/models/UpdateCardClientRequest.ts create mode 100644 src/client/models/UpdateCardClientResponse.ts create mode 100644 src/client/models/UpdateCardManagerRequest.ts create mode 100644 src/client/models/UpdateCardManagerResponse.ts rename src/components/DealStatusSelect/{DealStatusSelect.tsx => CardStatusSelect.tsx} (91%) create mode 100644 src/modules/cardModules/cardEditorTabs/ClientTab/ClientTab.tsx rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/EmployeesTab/EmployeesTab.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/EmployeesTab/components/AvailableEmployeesSelect.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/EmployeesTab/components/EmployeeInput.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/EmployeesTab/components/EmployeesTable.tsx (94%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/EmployeesTab/hooks/useAvailableEmployeesList.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/EmployeesTab/hooks/useEmployeesTab.tsx (95%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/EmployeesTab/hooks/useEmployeesTableColumns.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/EmployeesTab/modals/AssignEmployeeModal.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/EmployeesTab/types/AssignUserModalForm.tsx (100%) create mode 100644 src/modules/cardModules/cardEditorTabs/ManagersTab/ManagersTab.tsx rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ProductAndServiceTab/ProductAndServiceTab.module.css (97%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ProductAndServiceTab/ProductAndServiceTab.tsx (85%) rename src/{pages/CardsPage/tabs/ProductAndServiceTab/components/DealServicesTable => modules/cardModules/cardEditorTabs/ProductAndServiceTab/components/CardServicesTable}/CardServicesTable.tsx (98%) create mode 100644 src/modules/cardModules/cardEditorTabs/ProductAndServiceTab/components/GeneralDataForm/GeneralDataForm.tsx rename src/{pages/CardsPage/tabs/GeneralTab/components => modules/cardModules/cardEditorTabs/ProductAndServiceTab/components/PaymentLinkButton}/PaymentLinkButton.tsx (77%) rename src/{pages/CardsPage/tabs/GeneralTab/components => modules/cardModules/cardEditorTabs/ProductAndServiceTab/components/PrintDealBarcodesButton}/PrintDealBarcodesButton.tsx (83%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ProductAndServiceTab/components/ProductServicesTable/ProductServicesTable.tsx (98%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ProductAndServiceTab/components/ProductServicesTable/columns.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ProductAndServiceTab/components/ProductView/ProductView.module.css (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ProductAndServiceTab/components/ProductView/ProductView.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ProductAndServiceTab/hooks/useProductAndServiceTabState.tsx (97%) rename src/{pages/CardsPage => modules/cardModules/cardEditorTabs/ProductAndServiceTab}/modals/AddCardProductModal.tsx (94%) rename src/{pages/CardsPage => modules/cardModules/cardEditorTabs/ProductAndServiceTab}/modals/AddCardServiceModal.tsx (89%) rename src/{pages/CardsPage => modules/cardModules/cardEditorTabs/ProductAndServiceTab}/modals/ProductServiceFormModal.tsx (91%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/ShippingTab.module.css (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/ShippingTab.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/components/BoxesTable.tsx (96%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/components/InlineShippingButton.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/components/ShippingProductSelect.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/components/ShippingProductsTable.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/components/ShippingTree.tsx (98%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/hooks/shippingTableColumns.tsx (96%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/hooks/useShipping.tsx (97%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/hooks/useShippingQrs.tsx (88%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/hooks/useUpdateCard.tsx (81%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/modals/ShippingProductModal.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/types/ShippingProductData.tsx (100%) rename src/{pages/CardsPage/tabs => modules/cardModules/cardEditorTabs}/ShippingTab/utils/getRestProducts.tsx (100%) create mode 100644 src/modules/connectModules.tsx create mode 100644 src/modules/context/ModulesContext.tsx create mode 100644 src/modules/modules.tsx create mode 100644 src/modules/modulesFileGen/modulesFileGen.cjs create mode 100644 src/modules/modulesFileGen/modulesFileGen.ts create mode 100644 src/modules/types.tsx rename src/{pages/CardsPage => modules}/utils/isModuleInProject.ts (89%) rename src/pages/CardsPage/{components => drawers/CardEditDrawer/tabs}/CardStatusChangeTable/CardStatusChangeTable.tsx (83%) rename src/pages/CardsPage/{components => drawers/CardEditDrawer/tabs}/CardStatusChangeTable/columns.tsx (96%) rename src/pages/CardsPage/{ => drawers/CardEditDrawer}/tabs/GeneralTab/GeneralTab.tsx (57%) delete mode 100644 src/pages/CardsPage/tabs/ClientTab/ClientTab.tsx diff --git a/generateModules.sh b/generateModules.sh new file mode 100755 index 0000000..e2ddcc9 --- /dev/null +++ b/generateModules.sh @@ -0,0 +1,3 @@ +sudo npx tsc ./src/modules/modulesFileGen/modulesFileGen.ts +mv -f ./src/modules/modulesFileGen/modulesFileGen.js ./src/modules/modulesFileGen/modulesFileGen.cjs +sudo node ./src/modules/modulesFileGen/modulesFileGen.cjs diff --git a/package.json b/package.json index d481a7b..f2e0feb 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "@types/eslint__js": "^8.42.3", "@types/file-saver": "^2.0.7", "@types/lodash": "^4.17.7", + "@types/node": "^22.13.9", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@typescript-eslint/eslint-plugin": "^7.16.1", diff --git a/src/client/index.ts b/src/client/index.ts index b9b3fad..5f33b29 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -300,6 +300,9 @@ export type { ProductGenerateBarcodeResponse } from './models/ProductGenerateBar export type { ProductGetBarcodeImageResponse } from './models/ProductGetBarcodeImageResponse'; export type { ProductGetResponse } from './models/ProductGetResponse'; export type { ProductImageSchema } from './models/ProductImageSchema'; +export type { ProductsAndServicesGeneralInfoRequest } from './models/ProductsAndServicesGeneralInfoRequest'; +export type { ProductsAndServicesGeneralInfoResponse } from './models/ProductsAndServicesGeneralInfoResponse'; +export type { ProductsAndServicesGeneralInfoSchema } from './models/ProductsAndServicesGeneralInfoSchema'; export type { ProductSchema } from './models/ProductSchema'; export type { ProductUpdateRequest } from './models/ProductUpdateRequest'; export type { ProductUpdateResponse } from './models/ProductUpdateResponse'; @@ -357,6 +360,10 @@ export type { UpdateBoardOrderRequest } from './models/UpdateBoardOrderRequest'; export type { UpdateBoardOrderResponse } from './models/UpdateBoardOrderResponse'; export type { UpdateBoardRequest } from './models/UpdateBoardRequest'; export type { UpdateBoardResponse } from './models/UpdateBoardResponse'; +export type { UpdateCardClientRequest } from './models/UpdateCardClientRequest'; +export type { UpdateCardClientResponse } from './models/UpdateCardClientResponse'; +export type { UpdateCardManagerRequest } from './models/UpdateCardManagerRequest'; +export type { UpdateCardManagerResponse } from './models/UpdateCardManagerResponse'; export type { UpdateDepartmentRequest } from './models/UpdateDepartmentRequest'; export type { UpdateDepartmentResponse } from './models/UpdateDepartmentResponse'; export type { UpdateDepartmentSectionRequest } from './models/UpdateDepartmentSectionRequest'; diff --git a/src/client/models/CardGeneralInfoSchema.ts b/src/client/models/CardGeneralInfoSchema.ts index 17d61b2..485b160 100644 --- a/src/client/models/CardGeneralInfoSchema.ts +++ b/src/client/models/CardGeneralInfoSchema.ts @@ -9,7 +9,6 @@ export type CardGeneralInfoSchema = { isDeleted: boolean; isCompleted: boolean; comment: string; - shippingWarehouse?: (string | null); manager?: (UserSchema | null); boardId: number; statusId: number; diff --git a/src/client/models/ModuleSchema.ts b/src/client/models/ModuleSchema.ts index 5978ea4..d29dcd8 100644 --- a/src/client/models/ModuleSchema.ts +++ b/src/client/models/ModuleSchema.ts @@ -6,6 +6,7 @@ export type ModuleSchema = { id: number; key: string; label: string; + iconName?: (string | null); isDeleted: boolean; }; diff --git a/src/client/models/ProductsAndServicesGeneralInfoRequest.ts b/src/client/models/ProductsAndServicesGeneralInfoRequest.ts new file mode 100644 index 0000000..76034d9 --- /dev/null +++ b/src/client/models/ProductsAndServicesGeneralInfoRequest.ts @@ -0,0 +1,10 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ProductsAndServicesGeneralInfoSchema } from './ProductsAndServicesGeneralInfoSchema'; +export type ProductsAndServicesGeneralInfoRequest = { + cardId: number; + data: ProductsAndServicesGeneralInfoSchema; +}; + diff --git a/src/client/models/ProductsAndServicesGeneralInfoResponse.ts b/src/client/models/ProductsAndServicesGeneralInfoResponse.ts new file mode 100644 index 0000000..96c8b4e --- /dev/null +++ b/src/client/models/ProductsAndServicesGeneralInfoResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ProductsAndServicesGeneralInfoResponse = { + ok: boolean; + message: string; +}; + diff --git a/src/client/models/ProductsAndServicesGeneralInfoSchema.ts b/src/client/models/ProductsAndServicesGeneralInfoSchema.ts new file mode 100644 index 0000000..377f551 --- /dev/null +++ b/src/client/models/ProductsAndServicesGeneralInfoSchema.ts @@ -0,0 +1,8 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ProductsAndServicesGeneralInfoSchema = { + shippingWarehouse?: (string | null); +}; + diff --git a/src/client/models/UpdateCardClientRequest.ts b/src/client/models/UpdateCardClientRequest.ts new file mode 100644 index 0000000..e795ecf --- /dev/null +++ b/src/client/models/UpdateCardClientRequest.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type UpdateCardClientRequest = { + cardId: number; + clientId: number; +}; + diff --git a/src/client/models/UpdateCardClientResponse.ts b/src/client/models/UpdateCardClientResponse.ts new file mode 100644 index 0000000..8ce30a5 --- /dev/null +++ b/src/client/models/UpdateCardClientResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type UpdateCardClientResponse = { + ok: boolean; + message: string; +}; + diff --git a/src/client/models/UpdateCardManagerRequest.ts b/src/client/models/UpdateCardManagerRequest.ts new file mode 100644 index 0000000..90b9f43 --- /dev/null +++ b/src/client/models/UpdateCardManagerRequest.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type UpdateCardManagerRequest = { + cardId: number; + managerId: (number | null); +}; + diff --git a/src/client/models/UpdateCardManagerResponse.ts b/src/client/models/UpdateCardManagerResponse.ts new file mode 100644 index 0000000..e710651 --- /dev/null +++ b/src/client/models/UpdateCardManagerResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type UpdateCardManagerResponse = { + ok: boolean; + message: string; +}; + diff --git a/src/client/services/CardService.ts b/src/client/services/CardService.ts index 2922e4b..8d4fa36 100644 --- a/src/client/services/CardService.ts +++ b/src/client/services/CardService.ts @@ -59,6 +59,12 @@ import type { GetCardProductsBarcodesPdfResponse } from '../models/GetCardProduc import type { ManageEmployeeRequest } from '../models/ManageEmployeeRequest'; import type { ManageEmployeeResponse } from '../models/ManageEmployeeResponse'; import type { ParseCardsExcelResponse } from '../models/ParseCardsExcelResponse'; +import type { ProductsAndServicesGeneralInfoRequest } from '../models/ProductsAndServicesGeneralInfoRequest'; +import type { ProductsAndServicesGeneralInfoResponse } from '../models/ProductsAndServicesGeneralInfoResponse'; +import type { UpdateCardClientRequest } from '../models/UpdateCardClientRequest'; +import type { UpdateCardClientResponse } from '../models/UpdateCardClientResponse'; +import type { UpdateCardManagerRequest } from '../models/UpdateCardManagerRequest'; +import type { UpdateCardManagerResponse } from '../models/UpdateCardManagerResponse'; import type { CancelablePromise } from '../core/CancelablePromise'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; @@ -236,6 +242,66 @@ export class CardService { }, }); } + /** + * Update Products And Services General Info + * @returns ProductsAndServicesGeneralInfoResponse Successful Response + * @throws ApiError + */ + public static updateProductsAndServicesGeneralInfo({ + requestBody, + }: { + requestBody: ProductsAndServicesGeneralInfoRequest, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/card/update-products-and-services-general-info', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * Update Card Manager + * @returns UpdateCardManagerResponse Successful Response + * @throws ApiError + */ + public static updateCardManager({ + requestBody, + }: { + requestBody: UpdateCardManagerRequest, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/card/update-card-manager', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * Update Card Client + * @returns UpdateCardClientResponse Successful Response + * @throws ApiError + */ + public static updateCardClient({ + requestBody, + }: { + requestBody: UpdateCardClientRequest, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/card/update-card-client', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } /** * Add Kit To Card * @returns CardAddKitResponse Successful Response diff --git a/src/components/CardAttributeFields/CardAttributeFields.tsx b/src/components/CardAttributeFields/CardAttributeFields.tsx index ce090a7..977b8ea 100644 --- a/src/components/CardAttributeFields/CardAttributeFields.tsx +++ b/src/components/CardAttributeFields/CardAttributeFields.tsx @@ -3,7 +3,7 @@ import { UseFormReturnType } from "@mantine/form"; import { rem, Stack } from "@mantine/core"; import { ReactNode } from "react"; import CardAttributeField from "./components/CardAttributeField.tsx"; -import { CardGeneralFormType } from "../../pages/CardsPage/tabs/GeneralTab/GeneralTab.tsx"; +import { CardGeneralFormType } from "../../pages/CardsPage/drawers/CardEditDrawer/tabs/GeneralTab/GeneralTab.tsx"; type Props = { project: ProjectSchema; diff --git a/src/components/CardAttributeFields/components/CardAttributeField.tsx b/src/components/CardAttributeFields/components/CardAttributeField.tsx index a77ce1b..e0f015b 100644 --- a/src/components/CardAttributeFields/components/CardAttributeField.tsx +++ b/src/components/CardAttributeFields/components/CardAttributeField.tsx @@ -2,7 +2,7 @@ import { AttributeSchema } from "../../../client"; import { Checkbox, Group, NumberInput, TextInput, Tooltip } from "@mantine/core"; import { UseFormReturnType } from "@mantine/form"; import { DatePickerInput, DateTimePicker } from "@mantine/dates"; -import { CardGeneralFormType } from "../../../pages/CardsPage/tabs/GeneralTab/GeneralTab.tsx"; +import { CardGeneralFormType } from "../../../pages/CardsPage/drawers/CardEditDrawer/tabs/GeneralTab/GeneralTab.tsx"; import { IconInfoCircle } from "@tabler/icons-react"; type Props = { diff --git a/src/components/DealStatusSelect/DealStatusSelect.tsx b/src/components/DealStatusSelect/CardStatusSelect.tsx similarity index 91% rename from src/components/DealStatusSelect/DealStatusSelect.tsx rename to src/components/DealStatusSelect/CardStatusSelect.tsx index 9ab924e..dcacc1c 100644 --- a/src/components/DealStatusSelect/DealStatusSelect.tsx +++ b/src/components/DealStatusSelect/CardStatusSelect.tsx @@ -10,7 +10,7 @@ type SelectProps = Omit, "data" | "getLab type Props = OtherProps & SelectProps; -const DealStatusSelect: FC = ({ board, ...props}) => { +const CardStatusSelect: FC = ({ board, ...props}) => { const [isInitial, setIsInitial] = useState(true); const filteredData = board?.statuses.filter( @@ -37,4 +37,4 @@ const DealStatusSelect: FC = ({ board, ...props}) => { /> ); }; -export default DealStatusSelect; +export default CardStatusSelect; diff --git a/src/components/Dnd/Cards/CardGroupView/CardGroupView.tsx b/src/components/Dnd/Cards/CardGroupView/CardGroupView.tsx index c2f0f3e..50b76a1 100644 --- a/src/components/Dnd/Cards/CardGroupView/CardGroupView.tsx +++ b/src/components/Dnd/Cards/CardGroupView/CardGroupView.tsx @@ -5,6 +5,8 @@ import { Flex, rem, Text, TextInput, useMantineColorScheme } from "@mantine/core import { IconGripHorizontal } from "@tabler/icons-react"; import { useDebouncedValue } from "@mantine/hooks"; import { notifications } from "../../../../shared/lib/notifications.ts"; +import { useProjectsContext } from "../../../../contexts/ProjectsContext.tsx"; +import isModuleInProject, { Modules } from "../../../../modules/utils/isModuleInProject.ts"; type Props = { cards: CardSummary[]; @@ -15,6 +17,9 @@ export const CardGroupView: FC = ({ cards, group }) => { const theme = useMantineColorScheme(); const [name, setName] = useState(group.name || ""); const [debouncedName] = useDebouncedValue(name, 200); + const { selectedProject } = useProjectsContext(); + const isServicesAndProductsIncluded = isModuleInProject(Modules.SERVICES_AND_PRODUCTS, selectedProject); + const totalPrice = useMemo(() => cards.reduce((acc, card) => acc + card.totalPrice, 0), [cards]); const totalProducts = useMemo(() => cards.reduce((acc, card) => acc + card.totalProducts, 0), [cards]); const updateName = () => { @@ -70,19 +75,21 @@ export const CardGroupView: FC = ({ cards, group }) => { /> ))} - - Сумма: {totalPrice.toLocaleString("ru-RU")} руб. - Всего товаров: {totalProducts.toLocaleString("ru-RU")} шт. - + {isServicesAndProductsIncluded && ( + + Сумма: {totalPrice.toLocaleString("ru-RU")} руб. + Всего товаров: {totalProducts.toLocaleString("ru-RU")} шт. + + )} ); }; \ No newline at end of file diff --git a/src/components/Dnd/Cards/CardSummaryItem/CardSummaryItem.tsx b/src/components/Dnd/Cards/CardSummaryItem/CardSummaryItem.tsx index e811f11..f6e3b32 100644 --- a/src/components/Dnd/Cards/CardSummaryItem/CardSummaryItem.tsx +++ b/src/components/Dnd/Cards/CardSummaryItem/CardSummaryItem.tsx @@ -9,7 +9,7 @@ import { faCheck } from "@fortawesome/free-solid-svg-icons"; import { IconCheck, IconLayoutGridRemove, IconTrash } from "@tabler/icons-react"; import { useContextMenu } from "mantine-contextmenu"; import useCardSummaryState from "./useCardSummaryState.tsx"; -import isModuleInProject, { Modules } from "../../../../pages/CardsPage/utils/isModuleInProject.ts"; +import isModuleInProject, { Modules } from "../../../../modules/utils/isModuleInProject.ts"; import { useProjectsContext } from "../../../../contexts/ProjectsContext.tsx"; type Props = { diff --git a/src/components/Dnd/Cards/CardsDndColumn/CardsDndColumn.tsx b/src/components/Dnd/Cards/CardsDndColumn/CardsDndColumn.tsx index 365ebec..a1bd53d 100644 --- a/src/components/Dnd/Cards/CardsDndColumn/CardsDndColumn.tsx +++ b/src/components/Dnd/Cards/CardsDndColumn/CardsDndColumn.tsx @@ -9,7 +9,7 @@ import { groupBy, has, uniq } from "lodash"; import { CardGroupView } from "../CardGroupView/CardGroupView.tsx"; import CreateDealsFromFileButton from "../CreateCardsFromFileButton/CreateDealsFromFileButton.tsx"; import DragState from "../../../../pages/CardsPage/enums/DragState.ts"; -import isModuleInProject, { Modules } from "../../../../pages/CardsPage/utils/isModuleInProject.ts"; +import isModuleInProject, { Modules } from "../../../../modules/utils/isModuleInProject.ts"; import { useProjectsContext } from "../../../../contexts/ProjectsContext.tsx"; type Props = { diff --git a/src/components/Dnd/Cards/CreateCardButton/CreateCardButton.tsx b/src/components/Dnd/Cards/CreateCardButton/CreateCardButton.tsx index 5d9eeae..f16487f 100644 --- a/src/components/Dnd/Cards/CreateCardButton/CreateCardButton.tsx +++ b/src/components/Dnd/Cards/CreateCardButton/CreateCardButton.tsx @@ -7,7 +7,7 @@ import { CardService, StatusSchema } from "../../../../client"; import { useQueryClient } from "@tanstack/react-query"; import { dateWithoutTimezone } from "../../../../shared/lib/date.ts"; import { usePrefillCardContext } from "../../../../pages/CardsPage/contexts/PrefillCardContext.tsx"; -import isModuleInProject, { Modules } from "../../../../pages/CardsPage/utils/isModuleInProject.ts"; +import isModuleInProject, { Modules } from "../../../../modules/utils/isModuleInProject.ts"; import { useProjectsContext } from "../../../../contexts/ProjectsContext.tsx"; type Props = { diff --git a/src/components/Dnd/Cards/CreateCardForm/CreateCardForm.tsx b/src/components/Dnd/Cards/CreateCardForm/CreateCardForm.tsx index 09125fa..4e8ca56 100644 --- a/src/components/Dnd/Cards/CreateCardForm/CreateCardForm.tsx +++ b/src/components/Dnd/Cards/CreateCardForm/CreateCardForm.tsx @@ -9,7 +9,7 @@ import ShippingWarehouseAutocomplete from "../../../Selects/ShippingWarehouseAutocomplete/ShippingWarehouseAutocomplete.tsx"; import BaseMarketplaceSelect from "../../../Selects/BaseMarketplaceSelect/BaseMarketplaceSelect.tsx"; import { usePrefillCardContext } from "../../../../pages/CardsPage/contexts/PrefillCardContext.tsx"; -import isModuleInProject, { Modules } from "../../../../pages/CardsPage/utils/isModuleInProject.ts"; +import isModuleInProject, { Modules } from "../../../../modules/utils/isModuleInProject.ts"; import { useProjectsContext } from "../../../../contexts/ProjectsContext.tsx"; type Props = { diff --git a/src/components/Dnd/Statuses/Status/Status.tsx b/src/components/Dnd/Statuses/Status/Status.tsx index 91a23b8..dd11393 100644 --- a/src/components/Dnd/Statuses/Status/Status.tsx +++ b/src/components/Dnd/Statuses/Status/Status.tsx @@ -9,7 +9,7 @@ import DragState from "../../../../pages/CardsPage/enums/DragState.ts"; import { useContextMenu } from "mantine-contextmenu"; import { IconEdit, IconTrash } from "@tabler/icons-react"; import useStatus from "./hooks/useStatus.tsx"; -import isModuleInProject, { Modules } from "../../../../pages/CardsPage/utils/isModuleInProject.ts"; +import isModuleInProject, { Modules } from "../../../../modules/utils/isModuleInProject.ts"; type Props = { diff --git a/src/components/ManagerSelect/ManagerSelect.tsx b/src/components/ManagerSelect/ManagerSelect.tsx index fe49987..68204f7 100644 --- a/src/components/ManagerSelect/ManagerSelect.tsx +++ b/src/components/ManagerSelect/ManagerSelect.tsx @@ -7,7 +7,7 @@ type Props = Omit< ObjectSelectProps, "data" | "getValueFn" | "getLabelFn" >; -const UserSelect: FC = props => { +const ManagerSelect: FC = props => { const { objects: managers } = useManagersList(); return ( = props => { /> ); }; -export default UserSelect; +export default ManagerSelect; diff --git a/src/components/Selects/ClientSelect/ClientSelect.tsx b/src/components/Selects/ClientSelect/ClientSelect.tsx index 0f3d5cf..f27f06b 100644 --- a/src/components/Selects/ClientSelect/ClientSelect.tsx +++ b/src/components/Selects/ClientSelect/ClientSelect.tsx @@ -9,8 +9,9 @@ type Props = { withLabel?: boolean; error?: string; inputContainer?: (children: ReactNode) => ReactNode; + disabled?: boolean; }; -const ClientSelect: FC = ({ value, onChange, error, inputContainer, withLabel = false }) => { +const ClientSelect: FC = ({ value, onChange, error, inputContainer, withLabel = false, disabled = false }) => { const { clients } = useClientsList(); const options = clients.map(client => ({ label: client.name, @@ -37,6 +38,7 @@ const ClientSelect: FC = ({ value, onChange, error, inputContainer, withL label={withLabel && "Клиент"} error={error} inputContainer={inputContainer} + disabled={disabled} /> ); }; diff --git a/src/hooks/usePollingEffect.tsx b/src/hooks/usePollingEffect.tsx index 6bb21f7..69a652a 100644 --- a/src/hooks/usePollingEffect.tsx +++ b/src/hooks/usePollingEffect.tsx @@ -13,7 +13,7 @@ function usePollingEffect( ): void { const { interval = 3000, isActive = true, onCleanUp = () => {} } = options; - const timeoutIdRef = useRef(null); + const timeoutIdRef = useRef(null); useEffect(() => { if (!isActive) { diff --git a/src/main.tsx b/src/main.tsx index f3c2d9b..5da7839 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -24,6 +24,7 @@ import { modals } from "./modals/modals.ts"; import TasksProvider from "./providers/TasksProvider/TasksProvider.tsx"; import { ContextMenuProvider } from "mantine-contextmenu"; import { ProjectsContextProvider } from "./contexts/ProjectsContext.tsx"; +import { ModulesContextProvider } from "./modules/context/ModulesContext.tsx"; // Configuring router const router = createRouter({ routeTree }); @@ -56,8 +57,10 @@ ReactDOM.createRoot(document.getElementById("root")!).render( - - + + + + diff --git a/src/modals/modals.ts b/src/modals/modals.ts index a54a0a0..8130404 100644 --- a/src/modals/modals.ts +++ b/src/modals/modals.ts @@ -3,13 +3,13 @@ import CreateServiceCategoryModal from "../pages/ServicesPage/modals/CreateServi import CreateServiceModal from "../pages/ServicesPage/modals/CreateServiceModal.tsx"; import createProductModal from "../pages/ProductsPage/modals/CreateProductModal/CreateProductModal.tsx"; import ProductFormModal from "../pages/ClientsPage/modals/ClientFormModal/ClientFormModal.tsx"; -import AddCardServiceModal from "../pages/CardsPage/modals/AddCardServiceModal.tsx"; -import AddCardProductModal from "../pages/CardsPage/modals/AddCardProductModal.tsx"; +import AddCardServiceModal from "../modules/cardModules/cardEditorTabs/ProductAndServiceTab/modals/AddCardServiceModal.tsx"; +import AddCardProductModal from "../modules/cardModules/cardEditorTabs/ProductAndServiceTab/modals/AddCardProductModal.tsx"; import PrintBarcodeModal from "./PrintBarcodeModal/PrintBarcodeModal.tsx"; import AddBarcodeModal from "./AddBarcodeModal/AddBarcodeModal.tsx"; import BarcodeTemplateFormModal from "../pages/BarcodePage/modals/BarcodeTemplateFormModal/BarcodeTemplateFormModal.tsx"; -import ProductServiceFormModal from "../pages/CardsPage/modals/ProductServiceFormModal.tsx"; +import ProductServiceFormModal from "../modules/cardModules/cardEditorTabs/ProductAndServiceTab/modals/ProductServiceFormModal.tsx"; import UserFormModal from "../pages/AdminPage/modals/UserFormModal/UserFormModal.tsx"; import EmployeeSelectModal from "./EmployeeSelectModal/EmployeeSelectModal.tsx"; import EmployeeTableModal from "./EmployeeTableModal/EmployeeTableModal.tsx"; @@ -24,11 +24,11 @@ import MarketplaceFormModal from "../pages/MarketplacesPage/modals/MarketplaceFo import ScanningModal from "./ScanningModal/ScanningModal.tsx"; import TransactionFormModal from "../pages/AdminPage/tabs/Transactions/modals/TransactionFormModal.tsx"; import TransactionTagsModal from "../pages/AdminPage/tabs/Transactions/modals/TransactionTagsModal.tsx"; -import ShippingProductModal from "../pages/CardsPage/tabs/ShippingTab/modals/ShippingProductModal.tsx"; +import ShippingProductModal from "../modules/cardModules/cardEditorTabs/ShippingTab/modals/ShippingProductModal.tsx"; import DepartmentModal from "../pages/AdminPage/tabs/OrganizationalStructureTab/modals/DepartmentModal.tsx"; import AddUserToDepartmentModal from "../pages/AdminPage/tabs/OrganizationalStructureTab/modals/AddUserToDepartmentModal.tsx"; -import AssignEmployeeModal from "../pages/CardsPage/tabs/EmployeesTab/modals/AssignEmployeeModal.tsx"; +import AssignEmployeeModal from "../modules/cardModules/cardEditorTabs/EmployeesTab/modals/AssignEmployeeModal.tsx"; import ResidualProductModal from "../pages/ResiduesPage/modals/ResidualProductModal/ResidualProductModal.tsx"; import NewReceiptModal from "../pages/ReceiptPage/components/NewReceipt/modals/NewReceiptModal.tsx"; import ReceiptModal from "../pages/ReceiptPage/components/ReceiptEditing/modals/ReceiptModal.tsx"; diff --git a/src/modules/cardModules/cardEditorTabs/ClientTab/ClientTab.tsx b/src/modules/cardModules/cardEditorTabs/ClientTab/ClientTab.tsx new file mode 100644 index 0000000..ec5d684 --- /dev/null +++ b/src/modules/cardModules/cardEditorTabs/ClientTab/ClientTab.tsx @@ -0,0 +1,147 @@ +import { Button, Fieldset, Group, rem, Stack, Textarea, TextInput } from "@mantine/core"; +import { useCardPageContext } from "../../../../pages/CardsPage/contexts/CardPageContext.tsx"; +import { useForm } from "@mantine/form"; +import { CardService, ClientSchema, ClientService } from "../../../../client"; +import { notifications } from "../../../../shared/lib/notifications.ts"; +import ClientSelect from "../../../../components/Selects/ClientSelect/ClientSelect.tsx"; +import { useEffect, useState } from "react"; +import InlineButton from "../../../../components/InlineButton/InlineButton.tsx"; +import { isEqual } from "lodash"; + +const ClientTab = () => { + const { selectedCard: card, refetchCard } = useCardPageContext(); + const [initialValues, setInitialValues] = useState>(card?.client ?? {}); + + const [client, setClient] = useState(card?.client ?? undefined); + + const form = useForm>( + { + initialValues, + }, + ); + + useEffect(() => { + const data = card?.client ?? {}; + setInitialValues(data); + form.setValues(data); + }, [card]); + + const isEditorDisabled = () => client?.id !== card?.client?.id; + + const handleSubmitClientInfo = (values: ClientSchema) => { + ClientService.updateClient({ + requestBody: { + data: values, + }, + }) + .then(({ ok, message }) => { + if (!ok) { + notifications.error({ message }); + return; + } + refetchCard(); + }) + .catch(err => console.log(err)); + }; + + const handleSelectClient = () => { + if (!(card && client)) return; + + CardService.updateCardClient({ + requestBody: { + cardId: card?.id, + clientId: client?.id, + }, + }) + .then(({ ok, message }) => { + if (!ok) { + notifications.error({ message }); + return; + } + refetchCard(); + }) + .catch(err => console.log(err)); + }; + + const clientDataEditor = ( +
+
handleSubmitClientInfo(values as ClientSchema)) + }> + + + + + + +