feat: create first project modal

This commit is contained in:
2025-11-07 10:13:32 +04:00
parent 1a1f584b81
commit b0eab6cce7
8 changed files with 156 additions and 40 deletions

View File

@ -0,0 +1,36 @@
import { useEffect, useMemo, useRef } from "react";
import { modals } from "@mantine/modals";
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
const useCreateFirstProject = () => {
const hasOpened = useRef(false);
const { projects, projectsCrud, isLoading } = useProjectsContext();
const shouldOpen = useMemo(
() => !isLoading && projects.length === 0,
[isLoading, projects]
);
useEffect(() => {
if (!shouldOpen || hasOpened.current) return;
hasOpened.current = true;
modals.openContextModal({
modal: "createFirstProjectModal",
withCloseButton: false,
closeOnClickOutside: false,
closeOnEscape: false,
overlayProps: {
color: "black",
blur: 6,
backgroundOpacity: 0.45,
},
innerProps: {
onSubmit: values =>
projectsCrud.onCreate(values, modals.closeAll),
},
});
}, [shouldOpen]);
};
export default useCreateFirstProject;