feat: project creating
This commit is contained in:
@ -0,0 +1,6 @@
|
||||
.container {
|
||||
width: min-content;
|
||||
cursor: pointer;
|
||||
padding: 6px;
|
||||
height: 100%;
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
import { IconPlus } from "@tabler/icons-react";
|
||||
import { ActionIcon, Box } from "@mantine/core";
|
||||
import { modals } from "@mantine/modals";
|
||||
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
|
||||
import style from "./CreateProjectButton.module.css";
|
||||
|
||||
const CreateProjectButton = () => {
|
||||
const { projectsCrud } = useProjectsContext();
|
||||
|
||||
const onCreateClick = () => {
|
||||
modals.openContextModal({
|
||||
modal: "enterNameModal",
|
||||
title: "Создание проекта",
|
||||
withCloseButton: true,
|
||||
innerProps: {
|
||||
onComplete: (name: string) => {
|
||||
projectsCrud.onCreate(name);
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<ActionIcon
|
||||
variant={"default"}
|
||||
onClick={onCreateClick}
|
||||
radius="lg"
|
||||
className={style.container}>
|
||||
<IconPlus />
|
||||
</ActionIcon>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default CreateProjectButton;
|
||||
@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { Group } from "@mantine/core";
|
||||
import { Flex, Group } from "@mantine/core";
|
||||
import CreateProjectButton from "@/app/deals/components/desktop/CreateProjectButton/CreateProjectButton";
|
||||
import ViewSelector from "@/app/deals/components/desktop/ViewSelector/ViewSelector";
|
||||
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
|
||||
import ProjectSelect from "@/components/selects/ProjectSelect/ProjectSelect";
|
||||
@ -16,12 +17,18 @@ const TopToolPanel = () => {
|
||||
return (
|
||||
<Group justify={"space-between"}>
|
||||
<ViewSelector />
|
||||
<Flex
|
||||
wrap={"nowrap"}
|
||||
align={"center"}
|
||||
gap={"sm"}>
|
||||
<CreateProjectButton />
|
||||
<ProjectSelect
|
||||
data={projects}
|
||||
value={selectedProject}
|
||||
onChange={value => value && setSelectedProjectId(value.id)}
|
||||
style={{ width: 250 }}
|
||||
/>
|
||||
</Flex>
|
||||
</Group>
|
||||
);
|
||||
};
|
||||
|
||||
@ -81,9 +81,8 @@ const useCrudOperations = <
|
||||
|
||||
const onSettled = () => {
|
||||
queryClient.invalidateQueries({
|
||||
predicate: (query: { queryKey: any }) => {
|
||||
return query.queryKey[0]?._id === key;
|
||||
},
|
||||
predicate: (query: { queryKey: any }) =>
|
||||
query.queryKey[0]?._id === key,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user