2024-02-21 02:01:35 +07:00
|
|
|
import { createContext, useContext } from "react";
|
2024-02-22 20:59:20 +00:00
|
|
|
import type { ProjectSchema } from "~/server/db/schema/project";
|
2024-02-21 02:01:35 +07:00
|
|
|
|
|
|
|
type TProjectContext = {
|
2024-03-12 07:46:07 +07:00
|
|
|
project: ProjectSchema & { isMutable: boolean };
|
2024-02-21 02:01:35 +07:00
|
|
|
isCompact?: boolean;
|
2024-02-28 22:32:31 +00:00
|
|
|
isEmbed?: boolean;
|
2024-02-21 02:01:35 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
const ProjectContext = createContext<TProjectContext | null>(null);
|
|
|
|
|
|
|
|
export const useProjectContext = () => {
|
|
|
|
const ctx = useContext(ProjectContext);
|
|
|
|
if (!ctx) {
|
|
|
|
throw new Error("Component not in ProjectContext!");
|
|
|
|
}
|
|
|
|
|
|
|
|
return ctx;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ProjectContext;
|