add scheduling functionality for experiments with new ScheduleModal component

This commit is contained in:
Alireza Vaezi
2025-07-20 21:07:58 -04:00
parent 35268ba4ea
commit 1d3e993137
5 changed files with 357 additions and 1 deletions

View File

@@ -40,6 +40,7 @@ export interface Experiment {
entry_exit_height_diff_in: number
schedule_status: ScheduleStatus
results_status: ResultsStatus
scheduled_date?: string | null
created_at: string
updated_at: string
created_by: string
@@ -56,6 +57,7 @@ export interface CreateExperimentRequest {
entry_exit_height_diff_in: number
schedule_status?: ScheduleStatus
results_status?: ResultsStatus
scheduled_date?: string | null
}
export interface UpdateExperimentRequest {
@@ -69,6 +71,7 @@ export interface UpdateExperimentRequest {
entry_exit_height_diff_in?: number
schedule_status?: ScheduleStatus
results_status?: ResultsStatus
scheduled_date?: string | null
}
export interface UserRole {
@@ -349,6 +352,26 @@ export const experimentManagement = {
return data
},
// Schedule an experiment
async scheduleExperiment(id: string, scheduledDate: string): Promise<Experiment> {
const updates: UpdateExperimentRequest = {
scheduled_date: scheduledDate,
schedule_status: 'scheduled'
}
return this.updateExperiment(id, updates)
},
// Remove experiment schedule
async removeExperimentSchedule(id: string): Promise<Experiment> {
const updates: UpdateExperimentRequest = {
scheduled_date: null,
schedule_status: 'pending schedule'
}
return this.updateExperiment(id, updates)
},
// Check if experiment number is unique
async isExperimentNumberUnique(experimentNumber: number, excludeId?: string): Promise<boolean> {
let query = supabase