From 659d76b694fb6e7eb4da4c5eb7d958d49973dbff Mon Sep 17 00:00:00 2001 From: fakz9 Date: Mon, 4 Mar 2024 04:15:58 +0300 Subject: [PATCH] crap --- package.json | 17 ++-- src/client/index.ts | 5 ++ src/client/models/DealChangeStatusRequest.ts | 9 ++ src/client/models/DealChangeStatusResponse.ts | 8 ++ src/client/models/DealCreateRequest.ts | 8 ++ src/client/services/ClientService.ts | 30 +++++++ src/client/services/DealService.ts | 52 +++++++++++ src/components/Dnd/Board/Board.tsx | 8 +- .../CreateDealButton.module.css} | 0 .../Dnd/CreateDealButton/CreateDealButton.tsx | 31 +++++++ .../CreateDealForm/CreateDealForm.module.css | 15 ++++ .../Dnd/CreateDealForm/CreateDealFrom.tsx | 83 ++++++++++++++++++ .../Dnd/CreateLeadButton/CreateLeadButton.tsx | 60 ------------- .../Selects/ClientSelect/ClientSelect.tsx | 87 +++++++++++++++++++ src/main.tsx | 10 ++- src/pages/LeadsPage/ui/LeadsPage.tsx | 5 +- src/types/Client.ts | 5 ++ src/types/QuickDeal.ts | 8 ++ 18 files changed, 366 insertions(+), 75 deletions(-) create mode 100644 src/client/models/DealChangeStatusRequest.ts create mode 100644 src/client/models/DealChangeStatusResponse.ts create mode 100644 src/client/models/DealCreateRequest.ts create mode 100644 src/client/services/ClientService.ts create mode 100644 src/client/services/DealService.ts rename src/components/Dnd/{CreateLeadButton/CreateLeadButton.module.css => CreateDealButton/CreateDealButton.module.css} (100%) create mode 100644 src/components/Dnd/CreateDealButton/CreateDealButton.tsx create mode 100644 src/components/Dnd/CreateDealForm/CreateDealForm.module.css create mode 100644 src/components/Dnd/CreateDealForm/CreateDealFrom.tsx delete mode 100644 src/components/Dnd/CreateLeadButton/CreateLeadButton.tsx create mode 100644 src/components/Selects/ClientSelect/ClientSelect.tsx create mode 100644 src/types/Client.ts create mode 100644 src/types/QuickDeal.ts diff --git a/package.json b/package.json index f283e6f..f48b311 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,13 @@ }, "dependencies": { "@hello-pangea/dnd": "^16.5.0", - "@mantine/core": "^7.5.3", - "@mantine/dates": "^7.5.3", - "@mantine/dropzone": "^7.5.3", - "@mantine/hooks": "^7.5.3", - "@mantine/modals": "^7.5.3", - "@mantine/notifications": "^7.5.3", + "@mantine/core": "^7.6.1", + "@mantine/dates": "^7.6.1", + "@mantine/dropzone": "^7.6.1", + "@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", @@ -27,11 +28,13 @@ "axios": "^1.6.7", "clsx": "^2.1.0", "dayjs": "^1.11.10", + "mantine-form-zod-resolver": "^1.1.0", "mantine-react-table": "^2.0.0-beta.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-redux": "^9.1.0", - "reactflow": "^11.10.4" + "reactflow": "^11.10.4", + "zod": "^3.22.4" }, "devDependencies": { "@types/react": "^18.2.56", diff --git a/src/client/index.ts b/src/client/index.ts index c1809eb..bde18fe 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -9,7 +9,12 @@ export type { OpenAPIConfig } from './core/OpenAPI'; export type { AuthLoginRequest } from './models/AuthLoginRequest'; export type { AuthLoginResponse } from './models/AuthLoginResponse'; +export type { DealChangeStatusRequest } from './models/DealChangeStatusRequest'; +export type { DealChangeStatusResponse } from './models/DealChangeStatusResponse'; +export type { DealCreateRequest } from './models/DealCreateRequest'; export type { HTTPValidationError } from './models/HTTPValidationError'; export type { ValidationError } from './models/ValidationError'; export { AuthService } from './services/AuthService'; +export { ClientService } from './services/ClientService'; +export { DealService } from './services/DealService'; diff --git a/src/client/models/DealChangeStatusRequest.ts b/src/client/models/DealChangeStatusRequest.ts new file mode 100644 index 0000000..4413149 --- /dev/null +++ b/src/client/models/DealChangeStatusRequest.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type DealChangeStatusRequest = { + deal_id: number; + new_status: number; +}; + diff --git a/src/client/models/DealChangeStatusResponse.ts b/src/client/models/DealChangeStatusResponse.ts new file mode 100644 index 0000000..3c5046b --- /dev/null +++ b/src/client/models/DealChangeStatusResponse.ts @@ -0,0 +1,8 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type DealChangeStatusResponse = { + ok: boolean; +}; + diff --git a/src/client/models/DealCreateRequest.ts b/src/client/models/DealCreateRequest.ts new file mode 100644 index 0000000..9bee897 --- /dev/null +++ b/src/client/models/DealCreateRequest.ts @@ -0,0 +1,8 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type DealCreateRequest = { + name: string; +}; + diff --git a/src/client/services/ClientService.ts b/src/client/services/ClientService.ts new file mode 100644 index 0000000..14d1549 --- /dev/null +++ b/src/client/services/ClientService.ts @@ -0,0 +1,30 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class ClientService { + /** + * Search Clients + * @returns any Successful Response + * @throws ApiError + */ + public static searchClients({ + name, + }: { + name: string, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/client/search', + query: { + 'name': name, + }, + errors: { + 422: `Validation Error`, + }, + }); + } +} diff --git a/src/client/services/DealService.ts b/src/client/services/DealService.ts new file mode 100644 index 0000000..b5286ba --- /dev/null +++ b/src/client/services/DealService.ts @@ -0,0 +1,52 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { DealChangeStatusRequest } from '../models/DealChangeStatusRequest'; +import type { DealChangeStatusResponse } from '../models/DealChangeStatusResponse'; +import type { DealCreateRequest } from '../models/DealCreateRequest'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class DealService { + /** + * Create + * @returns any Successful Response + * @throws ApiError + */ + public static createDealCreatePost({ + requestBody, + }: { + requestBody: DealCreateRequest, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/deal/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * Change Status + * @returns DealChangeStatusResponse Successful Response + * @throws ApiError + */ + public static changeStatusDealChangeStatusPost({ + requestBody, + }: { + requestBody: DealChangeStatusRequest, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/deal/changeStatus', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } +} diff --git a/src/components/Dnd/Board/Board.tsx b/src/components/Dnd/Board/Board.tsx index d4927e5..ffc741e 100644 --- a/src/components/Dnd/Board/Board.tsx +++ b/src/components/Dnd/Board/Board.tsx @@ -2,7 +2,7 @@ import {FC} from "react"; import styles from './Board.module.css'; import {Divider, Text, Title} from '@mantine/core'; import {Draggable, Droppable} from "@hello-pangea/dnd"; -import CreateLeadButton from "../CreateLeadButton/CreateLeadButton.tsx"; +import CreateDealButton from "../CreateDealButton/CreateDealButton.tsx"; type Props = { droppableId: string; @@ -21,16 +21,16 @@ export const Board: FC = ({droppableId, title, withCreateButton = false}) - {(provided, snapshot) => ( + {(provided) => (
{withCreateButton && - { }} />} - {(provided, snapshot) => ( + {(provided) => (
void; +} +const CreateDealButton: FC = ({onClick}) => { + const [isCreating, setIsCreating] = useState(false); + + return ( +
{ + if (isCreating) return; + setIsCreating(prevState => !prevState) + }} + > + + Быстрое добавление + { + }} + onSubmit={() => { + }} + /> +
+ ) +} +export default CreateDealButton; \ No newline at end of file diff --git a/src/components/Dnd/CreateDealForm/CreateDealForm.module.css b/src/components/Dnd/CreateDealForm/CreateDealForm.module.css new file mode 100644 index 0000000..19e7638 --- /dev/null +++ b/src/components/Dnd/CreateDealForm/CreateDealForm.module.css @@ -0,0 +1,15 @@ +.inputs { + display: flex; + flex-direction: column; + width: 100% +} + +.inputs * { + width: 100%; +} + +.buttons { + display: flex; + gap: rem(10); +} + diff --git a/src/components/Dnd/CreateDealForm/CreateDealFrom.tsx b/src/components/Dnd/CreateDealForm/CreateDealFrom.tsx new file mode 100644 index 0000000..1b09937 --- /dev/null +++ b/src/components/Dnd/CreateDealForm/CreateDealFrom.tsx @@ -0,0 +1,83 @@ +import {Button, rem, Textarea, TextInput} from "@mantine/core"; +import {QuickDeal} from "../../../types/QuickDeal.ts"; +import {FC} from "react"; +import {useForm} from "@mantine/form"; +import styles from './CreateDealForm.module.css'; +import ClientSelect from "../../Selects/ClientSelect/ClientSelect.tsx"; +import {DateTimePicker} from "@mantine/dates"; + +type Props = { + onSubmit: (quickDeal: QuickDeal) => void + onCancel: () => void; +} +const CreateDealFrom: FC = ({onSubmit, onCancel}) => { + const form = useForm({ + initialValues: { + name: '', + clientName: '', + clientAddress: '', + comment: '', + acceptance_date: new Date() + } + }); + return ( +
console.log(values))} + > + +
+
+ +
+ +
+ { + }}/> +
+ +
+