Skip to content

Commit

Permalink
Rename props to be more descriptive
Browse files Browse the repository at this point in the history
Signed-off-by: angatupyry <fierrofenix@gmail.com>
  • Loading branch information
Angatupyry committed Sep 18, 2023
1 parent 644583b commit cfb4a26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions packages/dashboard/src/components/tasks/task-schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const TaskSchedule = () => {
const [calendarEvents, setCalendarEvents] = React.useState<ProcessedEvent[]>([]);
const [openDeleteScheduleDialog, setOpenDeleteScheduleDialog] = React.useState(false);
const [openCreateTaskForm, setOpenCreateTaskForm] = React.useState(false);
const [selectedSchedule, setSelectedSchedule] = React.useState<Schedule>({
const [scheduleToEdit, setScheduleToEdit] = React.useState<Schedule>({
startOn: new Date(),
days: [false, false, false, false, false, false, false],
until: undefined,
Expand Down Expand Up @@ -146,9 +146,9 @@ export const TaskSchedule = () => {
throw new Error('No task found');
}
setCurrentScheduledTask(task);
setSelectedSchedule(apiScheduleToSchedule(task.schedules));
setScheduleToEdit(apiScheduleToSchedule(task.schedules));
if (eventScope === EventScopes.CURRENT) {
setSelectedSchedule(scheduleWithSelectedDay(task.schedules, exceptDateRef.current));
setScheduleToEdit(scheduleWithSelectedDay(task.schedules, exceptDateRef.current));
}
AppEvents.refreshTaskApp.next();
scheduler.close();
Expand Down Expand Up @@ -288,7 +288,7 @@ export const TaskSchedule = () => {
pickupPoints={pickupPoints}
dropoffPoints={dropoffPoints}
open={openCreateTaskForm}
currentSchedule={selectedSchedule}
scheduleToEdit={scheduleToEdit}
requestTask={currentScheduleTask?.task_request}
onClose={() => {
setOpenCreateTaskForm(false);
Expand Down
12 changes: 6 additions & 6 deletions packages/react-components/lib/tasks/create-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ export interface CreateTaskFormProps
pickupPoints?: Record<string, string>;
dropoffPoints?: Record<string, string>;
favoritesTasks?: TaskFavorite[];
currentSchedule?: Schedule;
scheduleToEdit?: Schedule;
requestTask?: TaskRequest;
submitTasks?(tasks: TaskRequest[], schedule: Schedule | null): Promise<void>;
tasksFromFile?(): Promise<TaskRequest[]> | TaskRequest[];
Expand All @@ -693,7 +693,7 @@ export function CreateTaskForm({
pickupPoints = {},
dropoffPoints = {},
favoritesTasks = [],
currentSchedule,
scheduleToEdit,
requestTask,
submitTasks,
tasksFromFile,
Expand Down Expand Up @@ -734,15 +734,15 @@ export function CreateTaskForm({
const taskRequest = taskRequests[selectedTaskIdx];
const [openSchedulingDialog, setOpenSchedulingDialog] = React.useState(false);
const [schedule, setSchedule] = React.useState<Schedule>(
currentSchedule ?? {
scheduleToEdit ?? {
startOn: new Date(),
days: [true, true, true, true, true, true, true],
until: undefined,
},
);
const [atTime, setAtTime] = React.useState(new Date());
const [scheduleUntilValue, setScheduleUntilValue] = React.useState<string>(
currentSchedule?.until ? ScheduleUntilValue.ON : ScheduleUntilValue.NEVER,
scheduleToEdit?.until ? ScheduleUntilValue.ON : ScheduleUntilValue.NEVER,
);

const handleScheduleUntilValue = (event: React.ChangeEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -1139,13 +1139,13 @@ export function CreateTaskForm({
className={classes.actionBtn}
onClick={() => setOpenSchedulingDialog(true)}
>
{currentSchedule ? 'Edit schedule' : 'Add to Schedule'}
{scheduleToEdit ? 'Edit schedule' : 'Add to Schedule'}
</Button>
<Button
variant="contained"
type="submit"
color="primary"
disabled={submitting || !formFullyFilled || currentSchedule !== undefined}
disabled={submitting || !formFullyFilled || scheduleToEdit !== undefined}
className={classes.actionBtn}
aria-label={submitText}
onClick={handleSubmitNow}
Expand Down

0 comments on commit cfb4a26

Please sign in to comment.