diff --git a/package.json b/package.json index b84eec1..67b1d22 100644 --- a/package.json +++ b/package.json @@ -11,54 +11,58 @@ "generate-client": "openapi --input http://127.0.0.1:8000/openapi.json --output ./src/client --client axios --useOptions --useUnionTypes" }, "dependencies": { - "@hello-pangea/dnd": "^16.5.0", - "@mantine/core": "^7.6.1", - "@mantine/dates": "^7.6.1", - "@mantine/dropzone": "^7.9.2", - "@mantine/form": "^7.6.1", - "@mantine/hooks": "^7.6.1", - "@mantine/modals": "^7.6.1", - "@mantine/notifications": "^7.6.1", - "@reduxjs/toolkit": "^2.2.1", - "@tabler/icons-react": "^2.47.0", - "@tanstack/react-query": "^5.22.2", - "@tanstack/react-router": "^1.16.6", - "@tanstack/router-devtools": "^1.16.6", - "@tanstack/router-vite-plugin": "^1.16.5", - "axios": "^1.6.7", + "@hello-pangea/dnd": "^16.6.0", + "@mantine/core": "^7.11.2", + "@mantine/dates": "^7.11.2", + "@mantine/dropzone": "^7.11.2", + "@mantine/form": "^7.11.2", + "@mantine/hooks": "^7.11.2", + "@mantine/modals": "^7.11.2", + "@mantine/notifications": "^7.11.2", + "@reduxjs/toolkit": "^2.2.6", + "@tabler/icons-react": "^3.11.0", + "@tanstack/react-query": "^5.51.9", + "@tanstack/react-router": "^1.45.6", + "@tanstack/router-devtools": "^1.45.6", + "@tanstack/router-vite-plugin": "^1.45.3", + "axios": "^1.7.2", "classnames": "^2.5.1", - "clsx": "^2.1.0", - "dayjs": "^1.11.10", - "dot-object": "^2.1.4", + "clsx": "^2.1.1", + "dayjs": "^1.11.12", + "dot-object": "^2.1.5", + "framer-motion": "^11.3.8", "lodash": "^4.17.21", "mantine-form-zod-resolver": "^1.1.0", - "mantine-react-table": "^2.0.0-beta.0", - "react": "^18.2.0", - "react-barcode": "^1.5.1", - "react-dom": "^18.2.0", - "react-redux": "^9.1.0", + "mantine-react-table": "^2.0.0-beta.5", + "phone": "^3.1.49", + "react": "^18.3.1", + "react-barcode": "^1.5.3", + "react-dom": "^18.3.1", + "react-imask": "^7.6.1", + "react-redux": "^9.1.2", "react-to-print": "^2.15.1", - "reactflow": "^11.10.4", - "zod": "^3.22.4" + "reactflow": "^11.11.4", + "zod": "^3.23.8" }, "devDependencies": { - "@types/dot-object": "^2", - "@types/lodash": "^4", - "@types/react": "^18.2.56", - "@types/react-dom": "^18.2.19", - "@typescript-eslint/eslint-plugin": "^7.0.2", - "@typescript-eslint/parser": "^7.0.2", - "@vitejs/plugin-react-swc": "^3.5.0", - "eslint": "^8.56.0", - "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.4.5", - "openapi-typescript-codegen": "^0.27.0", - "postcss": "^8.4.35", - "postcss-preset-mantine": "^1.13.0", + "@types/dot-object": "^2.1.6", + "@types/lodash": "^4.17.7", + "@types/react": "^18.3.3", + "@types/react-dom": "^18.3.0", + "@typescript-eslint/eslint-plugin": "^7.16.1", + "@typescript-eslint/parser": "^7.16.1", + "@vitejs/plugin-react-swc": "^3.7.0", + "eslint": "^9.7.0", + "eslint-plugin-react-hooks": "^4.6.2", + "eslint-plugin-react-refresh": "^0.4.8", + "openapi-typescript-codegen": "^0.29.0", + "postcss": "^8.4.39", + "postcss-preset-mantine": "^1.16.0", "postcss-simple-vars": "^7.0.1", - "sass": "^1.71.1", - "typescript": "^5.2.2", - "vite": "^5.1.4" + "sass": "^1.77.8", + "typescript": "^5.5.3", + "vite": "^5.3.4", + "yarn-upgrade-all": "^0.7.2" }, "packageManager": "yarn@4.1.0" } diff --git a/src/client/index.ts b/src/client/index.ts index 723c215..cc83878 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -36,6 +36,8 @@ export type { ClientUpdateRequest } from './models/ClientUpdateRequest'; export type { ClientUpdateResponse } from './models/ClientUpdateResponse'; export type { CreateBarcodeTemplateAttributeRequest } from './models/CreateBarcodeTemplateAttributeRequest'; export type { CreateBarcodeTemplateAttributeResponse } from './models/CreateBarcodeTemplateAttributeResponse'; +export type { CreatePositionRequest } from './models/CreatePositionRequest'; +export type { CreatePositionResponse } from './models/CreatePositionResponse'; export type { DealAddProductRequest } from './models/DealAddProductRequest'; export type { DealAddProductResponse } from './models/DealAddProductResponse'; export type { DealAddServiceRequest } from './models/DealAddServiceRequest'; @@ -80,7 +82,10 @@ export type { DealUpdateServiceResponse } from './models/DealUpdateServiceRespon export type { GetAllBarcodeTemplateAttributesResponse } from './models/GetAllBarcodeTemplateAttributesResponse'; export type { GetAllBarcodeTemplateSizesResponse } from './models/GetAllBarcodeTemplateSizesResponse'; export type { GetAllBarcodeTemplatesResponse } from './models/GetAllBarcodeTemplatesResponse'; +export type { GetAllPositionsResponse } from './models/GetAllPositionsResponse'; +export type { GetAllRolesResponse } from './models/GetAllRolesResponse'; export type { GetAllShippingWarehousesResponse } from './models/GetAllShippingWarehousesResponse'; +export type { GetAllUsersResponse } from './models/GetAllUsersResponse'; export type { GetBarcodeTemplateByIdRequest } from './models/GetBarcodeTemplateByIdRequest'; export type { GetBarcodeTemplateByIdResponse } from './models/GetBarcodeTemplateByIdResponse'; export type { GetProductBarcodePdfRequest } from './models/GetProductBarcodePdfRequest'; @@ -89,6 +94,8 @@ export type { GetProductBarcodeRequest } from './models/GetProductBarcodeRequest export type { GetProductBarcodeResponse } from './models/GetProductBarcodeResponse'; export type { HTTPValidationError } from './models/HTTPValidationError'; export type { PaginationInfoSchema } from './models/PaginationInfoSchema'; +export type { PermissionSchema } from './models/PermissionSchema'; +export type { PositionSchema } from './models/PositionSchema'; export type { ProductAddBarcodeRequest } from './models/ProductAddBarcodeRequest'; export type { ProductAddBarcodeResponse } from './models/ProductAddBarcodeResponse'; export type { ProductCreateRequest } from './models/ProductCreateRequest'; @@ -104,6 +111,7 @@ export type { ProductSchema } from './models/ProductSchema'; export type { ProductUpdateRequest } from './models/ProductUpdateRequest'; export type { ProductUpdateResponse } from './models/ProductUpdateResponse'; export type { ProductUploadImageResponse } from './models/ProductUploadImageResponse'; +export type { RoleSchema } from './models/RoleSchema'; export type { ServiceCategorySchema } from './models/ServiceCategorySchema'; export type { ServiceCreateCategoryRequest } from './models/ServiceCreateCategoryRequest'; export type { ServiceCreateCategoryResponse } from './models/ServiceCreateCategoryResponse'; @@ -118,13 +126,19 @@ export type { ServiceSchema } from './models/ServiceSchema'; export type { ServiceUpdateRequest } from './models/ServiceUpdateRequest'; export type { ServiceUpdateResponse } from './models/ServiceUpdateResponse'; export type { ShippingWarehouseSchema } from './models/ShippingWarehouseSchema'; +export type { UpdateUserRequest } from './models/UpdateUserRequest'; +export type { UpdateUserResponse } from './models/UpdateUserResponse'; export type { UserSchema } from './models/UserSchema'; +export type { UserUpdate } from './models/UserUpdate'; export type { ValidationError } from './models/ValidationError'; export { AuthService } from './services/AuthService'; export { BarcodeService } from './services/BarcodeService'; export { ClientService } from './services/ClientService'; export { DealService } from './services/DealService'; +export { PositionService } from './services/PositionService'; export { ProductService } from './services/ProductService'; +export { RoleService } from './services/RoleService'; export { ServiceService } from './services/ServiceService'; export { ShippingWarehouseService } from './services/ShippingWarehouseService'; +export { UserService } from './services/UserService'; diff --git a/src/client/models/CreatePositionRequest.ts b/src/client/models/CreatePositionRequest.ts new file mode 100644 index 0000000..4047ffa --- /dev/null +++ b/src/client/models/CreatePositionRequest.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { PositionSchema } from './PositionSchema'; +export type CreatePositionRequest = { + data: PositionSchema; +}; + diff --git a/src/client/models/CreatePositionResponse.ts b/src/client/models/CreatePositionResponse.ts new file mode 100644 index 0000000..f27d795 --- /dev/null +++ b/src/client/models/CreatePositionResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type CreatePositionResponse = { + ok: boolean; + message: string; +}; + diff --git a/src/client/models/DealGeneralInfoSchema.ts b/src/client/models/DealGeneralInfoSchema.ts index 46e753d..8757120 100644 --- a/src/client/models/DealGeneralInfoSchema.ts +++ b/src/client/models/DealGeneralInfoSchema.ts @@ -7,5 +7,6 @@ export type DealGeneralInfoSchema = { isDeleted: boolean; isCompleted: boolean; comment: string; + shippingWarehouse?: (string | null); }; diff --git a/src/client/models/DealSchema.ts b/src/client/models/DealSchema.ts index 3abf04b..9c2e947 100644 --- a/src/client/models/DealSchema.ts +++ b/src/client/models/DealSchema.ts @@ -20,6 +20,6 @@ export type DealSchema = { isCompleted: boolean; client: ClientSchema; comment: string; - shippingWarehouse?: (ShippingWarehouseSchema | null); + shippingWarehouse?: (ShippingWarehouseSchema | string | null); }; diff --git a/src/client/models/GetAllPositionsResponse.ts b/src/client/models/GetAllPositionsResponse.ts new file mode 100644 index 0000000..77f8423 --- /dev/null +++ b/src/client/models/GetAllPositionsResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { PositionSchema } from './PositionSchema'; +export type GetAllPositionsResponse = { + positions: Array; +}; + diff --git a/src/client/models/GetAllRolesResponse.ts b/src/client/models/GetAllRolesResponse.ts new file mode 100644 index 0000000..69c77c1 --- /dev/null +++ b/src/client/models/GetAllRolesResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { RoleSchema } from './RoleSchema'; +export type GetAllRolesResponse = { + roles: Array; +}; + diff --git a/src/client/models/GetAllUsersResponse.ts b/src/client/models/GetAllUsersResponse.ts new file mode 100644 index 0000000..e40088c --- /dev/null +++ b/src/client/models/GetAllUsersResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { UserSchema } from './UserSchema'; +export type GetAllUsersResponse = { + users: Array; +}; + diff --git a/src/client/models/PermissionSchema.ts b/src/client/models/PermissionSchema.ts new file mode 100644 index 0000000..ece3cd9 --- /dev/null +++ b/src/client/models/PermissionSchema.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type PermissionSchema = { + key: string; + name: string; +}; + diff --git a/src/client/models/PositionSchema.ts b/src/client/models/PositionSchema.ts new file mode 100644 index 0000000..253ea36 --- /dev/null +++ b/src/client/models/PositionSchema.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type PositionSchema = { + name: string; + key: string; +}; + diff --git a/src/client/models/RoleSchema.ts b/src/client/models/RoleSchema.ts new file mode 100644 index 0000000..51c9ae6 --- /dev/null +++ b/src/client/models/RoleSchema.ts @@ -0,0 +1,11 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { PermissionSchema } from './PermissionSchema'; +export type RoleSchema = { + key: string; + name: string; + permissions: Array; +}; + diff --git a/src/client/models/UpdateUserRequest.ts b/src/client/models/UpdateUserRequest.ts new file mode 100644 index 0000000..68d1f44 --- /dev/null +++ b/src/client/models/UpdateUserRequest.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { UserUpdate } from './UserUpdate'; +export type UpdateUserRequest = { + data: UserUpdate; +}; + diff --git a/src/client/models/UpdateUserResponse.ts b/src/client/models/UpdateUserResponse.ts new file mode 100644 index 0000000..bae65dc --- /dev/null +++ b/src/client/models/UpdateUserResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type UpdateUserResponse = { + ok: boolean; + message: string; +}; + diff --git a/src/client/models/UserSchema.ts b/src/client/models/UserSchema.ts index 2feeee9..633acab 100644 --- a/src/client/models/UserSchema.ts +++ b/src/client/models/UserSchema.ts @@ -2,10 +2,20 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { PositionSchema } from './PositionSchema'; +import type { RoleSchema } from './RoleSchema'; export type UserSchema = { id: number; telegramId: number; phoneNumber?: (string | null); + firstName: string; + secondName: string; + comment: string; isAdmin: boolean; + isBlocked: boolean; + isDeleted: boolean; + roleKey: string; + role: RoleSchema; + position?: (PositionSchema | null); }; diff --git a/src/client/models/UserUpdate.ts b/src/client/models/UserUpdate.ts new file mode 100644 index 0000000..64fec47 --- /dev/null +++ b/src/client/models/UserUpdate.ts @@ -0,0 +1,17 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type UserUpdate = { + id: number; + telegramId: number; + phoneNumber?: (string | null); + firstName: string; + secondName: string; + comment: string; + isAdmin: boolean; + isBlocked: boolean; + isDeleted: boolean; + positionKey?: (string | null); +}; + diff --git a/src/client/services/PositionService.ts b/src/client/services/PositionService.ts new file mode 100644 index 0000000..5556e76 --- /dev/null +++ b/src/client/services/PositionService.ts @@ -0,0 +1,43 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CreatePositionRequest } from '../models/CreatePositionRequest'; +import type { CreatePositionResponse } from '../models/CreatePositionResponse'; +import type { GetAllPositionsResponse } from '../models/GetAllPositionsResponse'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class PositionService { + /** + * Get All + * @returns GetAllPositionsResponse Successful Response + * @throws ApiError + */ + public static getAllPositions(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/position/get-all', + }); + } + /** + * Create + * @returns CreatePositionResponse Successful Response + * @throws ApiError + */ + public static createPosition({ + requestBody, + }: { + requestBody: CreatePositionRequest, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/position/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } +} diff --git a/src/client/services/RoleService.ts b/src/client/services/RoleService.ts new file mode 100644 index 0000000..6698eae --- /dev/null +++ b/src/client/services/RoleService.ts @@ -0,0 +1,21 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { GetAllRolesResponse } from '../models/GetAllRolesResponse'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class RoleService { + /** + * Get All + * @returns GetAllRolesResponse Successful Response + * @throws ApiError + */ + public static getAllRoles(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/role/get-all', + }); + } +} diff --git a/src/client/services/UserService.ts b/src/client/services/UserService.ts new file mode 100644 index 0000000..cd56e68 --- /dev/null +++ b/src/client/services/UserService.ts @@ -0,0 +1,43 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { GetAllUsersResponse } from '../models/GetAllUsersResponse'; +import type { UpdateUserRequest } from '../models/UpdateUserRequest'; +import type { UpdateUserResponse } from '../models/UpdateUserResponse'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class UserService { + /** + * Get All + * @returns GetAllUsersResponse Successful Response + * @throws ApiError + */ + public static getAllUsers(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/user/get-all', + }); + } + /** + * Update + * @returns UpdateUserResponse Successful Response + * @throws ApiError + */ + public static updateUser({ + requestBody, + }: { + requestBody: UpdateUserRequest, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/user/update', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } +} diff --git a/src/components/AnimatedOutlet/au.tsx b/src/components/AnimatedOutlet/au.tsx new file mode 100644 index 0000000..ff8d7c9 --- /dev/null +++ b/src/components/AnimatedOutlet/au.tsx @@ -0,0 +1,34 @@ +import {forwardRef, RefObject, useContext, useRef} from "react"; +import {getRouterContext, Outlet} from "@tanstack/react-router"; +import {motion, useIsPresent} from "framer-motion"; +import {cloneDeep} from "lodash"; + +const AnimatedOutlet = forwardRef((_, ref) => { + const RouterContext = getRouterContext(); + + const routerContext = useContext(RouterContext); + + const renderedContext = useRef(routerContext); + + const isPresent = useIsPresent(); + + if (isPresent) { + renderedContext.current = cloneDeep(routerContext); + } + + return ( + { + (ref as RefObject).current?.style.removeProperty("transform") + }} + > + + + + + ); +}); +export default AnimatedOutlet \ No newline at end of file diff --git a/src/components/BaseTable/BaseTable.tsx b/src/components/BaseTable/BaseTable.tsx index ed23ee3..6ba5e07 100644 --- a/src/components/BaseTable/BaseTable.tsx +++ b/src/components/BaseTable/BaseTable.tsx @@ -26,7 +26,7 @@ export type BaseTableRef = { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error export const BaseTable = forwardRef, Props>((props, ref) => { - const {data, columns, restProps, striped, onSelectionChange} = props; + const {data, columns, restProps, striped = true, onSelectionChange} = props; const table = useMantineReactTable({ localization: MRT_Localization_RU, diff --git a/src/components/Navbar/Navbar.tsx b/src/components/Navbar/Navbar.tsx index fd873e1..1b10b24 100644 --- a/src/components/Navbar/Navbar.tsx +++ b/src/components/Navbar/Navbar.tsx @@ -2,7 +2,7 @@ import {Center, Image, rem, Stack, Tooltip, UnstyledButton, useMantineColorSchem import { IconBarcode, IconBox, - IconCash, + IconCash, IconDashboard, IconFileBarcode, IconHome2, IconLogout, @@ -76,7 +76,7 @@ export function Navbar() { const dispatch = useAppDispatch(); const navigate = useNavigate(); const router = useRouterState(); - const {colorScheme, toggleColorScheme} = useMantineColorScheme({keepTransitions: false}); + const {colorScheme, toggleColorScheme} = useMantineColorScheme({keepTransitions: true}); const onLogoutClick = () => { dispatch(logout()); navigate({to: '/login'}); @@ -110,6 +110,12 @@ export function Navbar() { + onNavlinkClick({href: "/admin", index: -1, icon: IconDashboard})} + /> diff --git a/src/components/ObjectSelect/ObjectSelect.tsx b/src/components/ObjectSelect/ObjectSelect.tsx index d1013e9..7378ece 100644 --- a/src/components/ObjectSelect/ObjectSelect.tsx +++ b/src/components/ObjectSelect/ObjectSelect.tsx @@ -1,35 +1,55 @@ import {Select, SelectProps} from "@mantine/core"; import {useEffect, useMemo, useState} from "react"; -import {ObjectWithNameAndId} from "../../types/utils.ts"; import {groupBy, omit} from "lodash"; +interface ObjectWithIdAndName { + id: number, + name: string +} -export type SelectObjectType = T; +export type SelectObjectType = T; -type ControlledValueProps = { +type ControlledValueProps = { value: SelectObjectType, onChange: (value: SelectObjectType) => void; } +type CustomLabelAndKeyProps = { + getLabelFn: (item: SelectObjectType) => string; + getValueFn: (item: SelectObjectType) => string; +} -type RestProps = { +type RestProps = { defaultValue?: SelectObjectType onChange: (value: SelectObjectType) => void; data: SelectObjectType[]; groupBy?: (item: SelectObjectType) => string; filterBy?: (item: SelectObjectType) => boolean; +}; +const defaultGetLabelFn = (item: T): string => { + return item.name; } -export type ObjectSelectProps = +const defaultGetValueFn = (item: T): string => { + return item.id.toString(); +} +export type ObjectSelectProps = (RestProps & Partial>) - & Omit; + & Omit + & (T extends ObjectWithIdAndName ? Partial> : CustomLabelAndKeyProps) -const ObjectSelect = (props: ObjectSelectProps) => { +const ObjectSelect = (props: ObjectSelectProps) => { const isControlled = 'value' in props; + const haveGetValueFn = 'getValueFn' in props; + const haveGetLabelFn = 'getLabelFn' in props; const [internalValue, setInternalValue] = useState | undefined>(props.defaultValue); const value = isControlled ? props.value : internalValue; + + const getValueFn = (haveGetValueFn && props.getValueFn) || defaultGetValueFn; + const getLabelFn = (haveGetLabelFn && props.getLabelFn) || defaultGetLabelFn; + const data = useMemo(() => { const propsData = props.filterBy ? props.data.filter(props.filterBy) : props.data; if (props.groupBy) { @@ -38,21 +58,21 @@ const ObjectSelect = (props: ObjectSelectProps< return Object.entries(groupedData).map(([group, items]) => ({ group, items: items.map(item => ({ - label: item.name, - value: item.id.toString() + label: getLabelFn(item), + value: getValueFn(item) })) })); } else { return propsData.map(item => ({ - label: item.name, - value: item.id.toString() + label: getLabelFn(item), + value: getValueFn(item) })); } }, [props.data, props.groupBy]); const handleOnChange = (event: string | null) => { if (!event) return; - const object = props.data.find(item => parseInt(event) == item.id); + const object = props.data.find(item => event == getValueFn(item)); if (!object) return; if (isControlled) { props.onChange(object); @@ -65,11 +85,11 @@ const ObjectSelect = (props: ObjectSelectProps< if (isControlled || !internalValue) return; props.onChange(internalValue); }, [internalValue]); - const restProps = omit(props, ['filterBy', 'groupBy']); + const restProps = omit(props, ['filterBy', 'groupBy', 'getValueFn', 'getLabelFn']); return ( + + + +
+ + + + {form.values.role.key === UserRoleEnum.EMPLOYEE && + + } + + +
+
+ + + +