feat: header in deal editor for mobile
This commit is contained in:
@ -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>
|
||||
|
||||
Reference in New Issue
Block a user