import { createContext, useContext, useState, type ReactNode } from 'react' import { type Role } from '@/schemas' import type { Action } from '../constants' type CrudContextType = { action: Action setAction: (action: Action) => void currentRow: T | null setCurrentRow: (row: T | null) => void } export const CrudContext = createContext | null>(null) export const CrudProvider = ({ children }: { children: ReactNode }) => { const [action, setAction] = useState(null) const [currentRow, setCurrentRow] = useState(null) return ( {children} ) } export const useCrud = () => { const context = useContext(CrudContext) if (!context) { throw new Error('context must be used within a CrudProvider') } return context }