feat: project creating

This commit is contained in:
2025-08-30 14:46:56 +04:00
parent a0522357d4
commit 1b97739063
4 changed files with 58 additions and 10 deletions

View File

@ -0,0 +1,6 @@
.container {
width: min-content;
cursor: pointer;
padding: 6px;
height: 100%;
}

View File

@ -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;

View File

@ -1,6 +1,7 @@
"use client"; "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 ViewSelector from "@/app/deals/components/desktop/ViewSelector/ViewSelector";
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext"; import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
import ProjectSelect from "@/components/selects/ProjectSelect/ProjectSelect"; import ProjectSelect from "@/components/selects/ProjectSelect/ProjectSelect";
@ -16,12 +17,18 @@ const TopToolPanel = () => {
return ( return (
<Group justify={"space-between"}> <Group justify={"space-between"}>
<ViewSelector /> <ViewSelector />
<Flex
wrap={"nowrap"}
align={"center"}
gap={"sm"}>
<CreateProjectButton />
<ProjectSelect <ProjectSelect
data={projects} data={projects}
value={selectedProject} value={selectedProject}
onChange={value => value && setSelectedProjectId(value.id)} onChange={value => value && setSelectedProjectId(value.id)}
style={{ width: 250 }} style={{ width: 250 }}
/> />
</Flex>
</Group> </Group>
); );
}; };

View File

@ -81,9 +81,8 @@ const useCrudOperations = <
const onSettled = () => { const onSettled = () => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
predicate: (query: { queryKey: any }) => { predicate: (query: { queryKey: any }) =>
return query.queryKey[0]?._id === key; query.queryKey[0]?._id === key,
},
}); });
}; };