Skip to content
Snippets Groups Projects
Commit 8e993ddc authored by Bernard Roland (Student Com20)'s avatar Bernard Roland (Student Com20)
Browse files

Implemented the work adapters

parent 69b9c7e0
No related branches found
No related tags found
No related merge requests found
import { executeApiGet, executeApiPost, executeApiPut } from './util';
export interface Work {
id: string;
task: string;
......@@ -7,3 +9,19 @@ export interface Work {
finished?: Date;
}
export function startWork(task: string): Promise<string> {
return executeApiPost(`work/start`, { task: task }, ({ id }) => id, "Failed to start work");
}
export function finishWork() {
return executeApiPut(`work/finish`, null, () => {}, "Failed to finish work");
}
export function openWork(): Promise<Work> {
return executeApiGet(`work/`, ({ work }) => ({
...work,
started: new Date(work.started),
finished: work.finished ? new Date(work.finished) : undefined,
}), "Failed to get open work");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment