feat: header in deal editor for mobile

This commit is contained in:
2025-09-03 12:17:49 +04:00
parent 9d8ec496a1
commit 5f621c295b
5 changed files with 61 additions and 18 deletions

View File

@ -1,4 +1,4 @@
import { FC, useState } from "react";
import React, { FC } from "react";
import { Stack, Text, TextInput } from "@mantine/core";
import { useForm } from "@mantine/form";
import Footer from "@/app/deals/drawers/DealEditorDrawer/tabs/GeneralTab/Footer";
@ -12,14 +12,19 @@ type Props = {
project: ProjectSchema;
dealsCrud: DealsCrud;
deal: DealSchema;
setDeal: React.Dispatch<React.SetStateAction<DealSchema>>;
onClose: () => void;
};
const GeneralTab: FC<Props> = ({ project, deal, dealsCrud, onClose }) => {
const [initialValues, setInitialValues] =
useState<Partial<DealSchema>>(deal);
const GeneralTab: FC<Props> = ({
project,
deal,
setDeal,
dealsCrud,
onClose,
}) => {
const form = useForm<Partial<DealSchema>>({
initialValues,
initialValues: deal,
validate: {
name: value => !value && "Введите название",
board: value => !value && "Выберите доску",
@ -33,7 +38,10 @@ const GeneralTab: FC<Props> = ({ project, deal, dealsCrud, onClose }) => {
boardId: values.board?.id,
statusId: values.status?.id,
});
setInitialValues(values);
setDeal(prev => ({
...prev,
...values,
}));
};
const onDelete = () => {
@ -64,7 +72,7 @@ const GeneralTab: FC<Props> = ({ project, deal, dealsCrud, onClose }) => {
/>
<Footer
form={form}
initialValues={initialValues}
initialValues={deal}
onDelete={onDelete}
/>
</Stack>