21 lines
472 B
TypeScript
Raw Normal View History

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-02-22 20:59:20 +00:00
project: ProjectSchema;
2024-02-21 02:01:35 +07:00
isCompact?: boolean;
};
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;