Skip to content

Commit

Permalink
fix after rebase
Browse files Browse the repository at this point in the history
Signed-off-by: Teo Koon Peng <teokoonpeng@gmail.com>
  • Loading branch information
koonpeng committed Sep 5, 2024
1 parent be889d9 commit 0f4897d
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion packages/rmf-dashboard-framework/src/components/tasks/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { PostScheduledTaskRequest, TaskRequest, TaskStateOutput as TaskState } from 'api-client';
import {
PostScheduledTaskRequest,
Priority,
TaskRequest,
TaskStateOutput as TaskState,
} from 'api-client';

import { Schedule } from './create-task';
import { getTaskBookingLabelFromTaskState } from './task-booking-label-utils';
Expand Down Expand Up @@ -117,3 +122,26 @@ export const toApiSchedule = (
schedules: apiSchedules,
};
};

export function createTaskPriority(prioritize: boolean): Priority {
return { type: 'binary', value: prioritize ? 1 : 0 };
}

// FIXME(ac): This method of parsing is crude, and will be fixed using schemas
// when we migrate to jsonforms.
export function parseTaskPriority(priority: Priority | null | undefined): boolean {
if (!priority) {
return false;
}

if (
typeof priority == 'object' &&
'type' in priority &&
priority['type'] === 'binary' &&
'value' in priority &&
typeof priority['value'] == 'number'
) {
return (priority['value'] as number) > 0;
}
return false;
}

0 comments on commit 0f4897d

Please sign in to comment.