Enhance scheduling and drag-and-drop functionality in the Calendar component

- Improved drag-and-drop experience for event scheduling with visual feedback and better cursor styles.
- Added state management for tracking repetitions, including locked schedules and currently scheduling repetitions.
- Implemented re-staggering logic to prevent overlap of scheduled events.
- Enhanced event generation to include time points for soaking, airdrying, and cracking phases.
- Updated the calendar to preserve and restore scroll position during event updates.
- Refactored event handling to ensure smooth interaction and improved user experience.
This commit is contained in:
salirezav
2025-10-29 14:16:19 -04:00
parent 98c93f9e0e
commit 9f669e7dff
12 changed files with 560 additions and 574 deletions

View File

@@ -29,20 +29,15 @@ CREATE TABLE IF NOT EXISTS public.experiments (
-- Create experiment repetitions table
CREATE TABLE IF NOT EXISTS public.experiment_repetitions (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
experiment_number INTEGER NOT NULL,
experiment_phase_id UUID NOT NULL,
experiment_id UUID NOT NULL REFERENCES public.experiments(id) ON DELETE CASCADE,
repetition_number INTEGER NOT NULL CHECK (repetition_number > 0),
status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'in_progress', 'completed', 'cancelled')),
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
created_by UUID NOT NULL REFERENCES public.user_profiles(id),
-- Foreign key to experiments using composite key
FOREIGN KEY (experiment_number, experiment_phase_id)
REFERENCES public.experiments(experiment_number, phase_id) ON DELETE CASCADE,
-- Ensure unique repetition numbers per experiment
UNIQUE(experiment_number, experiment_phase_id, repetition_number)
UNIQUE(experiment_id, repetition_number)
);
-- =============================================
@@ -52,7 +47,7 @@ CREATE TABLE IF NOT EXISTS public.experiment_repetitions (
CREATE INDEX IF NOT EXISTS idx_experiments_phase_id ON public.experiments(phase_id);
CREATE INDEX IF NOT EXISTS idx_experiments_experiment_number ON public.experiments(experiment_number);
CREATE INDEX IF NOT EXISTS idx_experiments_created_by ON public.experiments(created_by);
CREATE INDEX IF NOT EXISTS idx_experiment_repetitions_experiment_composite ON public.experiment_repetitions(experiment_number, experiment_phase_id);
CREATE INDEX IF NOT EXISTS idx_experiment_repetitions_experiment_id ON public.experiment_repetitions(experiment_id);
CREATE INDEX IF NOT EXISTS idx_experiment_repetitions_created_by ON public.experiment_repetitions(created_by);
-- =============================================