chore: initial commit

This commit is contained in:
2026-07-22 17:50:30 +08:00
parent d46cdd676e
commit 3abf272e33
190 changed files with 18073 additions and 0 deletions

View File

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