export interface DragState { activeId: string | null; dragItems: T[] | null; } export type DragAction = { type: "start"; id: string; data: T[] } | { type: "clear" }; export function dragStateInitial(): DragState { return { activeId: null, dragItems: null }; } export function dragStateReducer(state: DragState, action: DragAction): DragState { switch (action.type) { case "start": return { activeId: action.id, dragItems: action.data }; case "clear": return { activeId: null, dragItems: null }; } }