My-Weekly-ToDo-List/src/components/DragDropProvider.tsx
mARTin 5d12999bab docs(02-04): complete gap closure plans for user experience and advanced features
- Implemented navigation controls with week switching and view toggling
- Added drag-and-drop functionality for task reorganization
- Enhanced UI with visual feedback and delete confirmation
- Implemented complete recurring task functionality
- Created tag/category assignment system
- Added reminder notification mechanism
- Enhanced task prioritization
- Expanded description capabilities

SUMMARY: .planning/phases/02-ux-and-advanced-features/02-04-SUMMARY.md
2026-01-24 15:12:55 +01:00

47 lines
1.2 KiB
TypeScript

import React, { createContext, useContext, ReactNode } from 'react';
// Define types for drag and drop
export interface DragItem {
type: 'task';
taskId: string;
sourceDay: string;
}
export interface DropResult {
taskId: string;
targetDay: string;
}
// Create context for drag and drop
interface DragDropContextType {
dragItem: DragItem | null;
setDragItem: (item: DragItem | null) => void;
onDrop: (result: DropResult) => void;
}
const DragDropContext = createContext<DragDropContextType | undefined>(undefined);
// Provider component
export const DragDropProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
const [dragItem, setDragItem] = React.useState<DragItem | null>(null);
const onDrop = (result: DropResult) => {
// This will be implemented by the consumer
console.log('Dropped task:', result);
};
return (
<DragDropContext.Provider value={{ dragItem, setDragItem, onDrop }}>
{children}
</DragDropContext.Provider>
);
};
// Hook to use drag and drop context
export const useDragDrop = () => {
const context = useContext(DragDropContext);
if (!context) {
throw new Error('useDragDrop must be used within a DragDropProvider');
}
return context;
};