diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-10-09 18:42:33 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-10-09 18:42:33 +0200 |
| commit | 7bbd3891a76d3a6da20a4aa3888e6da87e41aa6d (patch) | |
| tree | c3602e6b8c3f2f79fb9c28465963365aaf49d8c4 /code/app/src/lib/api/time-entry.ts | |
| parent | b2b76d0552ecf0c57a4d39fb0a1caa9b4c10bee9 (diff) | |
| download | greatoffice-7bbd3891a76d3a6da20a4aa3888e6da87e41aa6d.tar.xz greatoffice-7bbd3891a76d3a6da20a4aa3888e6da87e41aa6d.zip | |
refactor/fix: Small refactors/fixes, update imports
Diffstat (limited to 'code/app/src/lib/api/time-entry.ts')
| -rw-r--r-- | code/app/src/lib/api/time-entry.ts | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/code/app/src/lib/api/time-entry.ts b/code/app/src/lib/api/time-entry.ts index a40b0c2..faedb48 100644 --- a/code/app/src/lib/api/time-entry.ts +++ b/code/app/src/lib/api/time-entry.ts @@ -1,16 +1,16 @@ -import {api_base} from "$lib/configuration"; -import {is_guid} from "$lib/helpers"; -import {http_delete, http_get, http_post} from "./internal-fetch"; -import type {TimeCategoryDto} from "$lib/models/TimeCategoryDto"; -import type {TimeLabelDto} from "$lib/models/TimeLabelDto"; -import type {TimeEntryDto} from "$lib/models/TimeEntryDto"; -import type {TimeEntryQuery} from "$lib/models/TimeEntryQuery"; -import type {IInternalFetchResponse} from "$lib/models/IInternalFetchResponse"; +import { api_base } from "$lib/configuration"; +import { is_guid } from "$lib/helpers"; +import { http_delete, http_get, http_post } from "./internal-fetch"; +import type { WorkCategory } from "$lib/models/work/WorkCategory"; +import type { WorkLabel } from "$lib/models/work/WorkLabel"; +import type { WorkEntry } from "$lib/models/work/WorkEntry"; +import type { WorkQuery } from "$lib/models/work/WorkQuery"; +import type { IInternalFetchResponse } from "$lib/models/internal/IInternalFetchResponse"; // ENTRIES -export async function create_time_entry(payload: TimeEntryDto): Promise<IInternalFetchResponse> { +export async function create_time_entry(payload: WorkEntry): Promise<IInternalFetchResponse> { return http_post(api_base("v1/entries/create"), payload); } @@ -21,7 +21,7 @@ export async function get_time_entry(entryId: string): Promise<IInternalFetchRes throw new Error("entryId is not a valid guid."); } -export async function get_time_entries(entryQuery: TimeEntryQuery): Promise<IInternalFetchResponse> { +export async function get_time_entries(entryQuery: WorkQuery): Promise<IInternalFetchResponse> { return http_post(api_base("v1/entries/query"), entryQuery); } @@ -30,7 +30,7 @@ export async function delete_time_entry(id: string): Promise<IInternalFetchRespo return http_delete(api_base("v1/entries/" + id + "/delete")); } -export async function update_time_entry(entryDto: TimeEntryDto): Promise<IInternalFetchResponse> { +export async function update_time_entry(entryDto: WorkEntry): Promise<IInternalFetchResponse> { if (!is_guid(entryDto.id ?? "")) throw new Error("id is not a valid guid"); if (!entryDto.category) throw new Error("category is empty"); if (!entryDto.stop) throw new Error("stop is empty"); @@ -39,7 +39,7 @@ export async function update_time_entry(entryDto: TimeEntryDto): Promise<IIntern } // LABELS -export async function create_time_label(labelDto: TimeLabelDto): Promise<IInternalFetchResponse> { +export async function create_time_label(labelDto: WorkLabel): Promise<IInternalFetchResponse> { return http_post(api_base("v1/labels/create"), labelDto); } @@ -52,7 +52,7 @@ export async function delete_time_label(id: string): Promise<IInternalFetchRespo return http_delete(api_base("v1/labels/" + id + "/delete")); } -export async function update_time_label(labelDto: TimeLabelDto): Promise<IInternalFetchResponse> { +export async function update_time_label(labelDto: WorkLabel): Promise<IInternalFetchResponse> { if (!is_guid(labelDto.id ?? "")) throw new Error("id is not a valid guid"); if (!labelDto.name) throw new Error("name is empty"); if (!labelDto.color) throw new Error("color is empty"); @@ -60,7 +60,7 @@ export async function update_time_label(labelDto: TimeLabelDto): Promise<IIntern } // CATEGORIES -export async function create_time_category(category: TimeCategoryDto): Promise<IInternalFetchResponse> { +export async function create_time_category(category: WorkCategory): Promise<IInternalFetchResponse> { if (!category.name) throw new Error("name is empty"); if (!category.color) throw new Error("color is empty"); return http_post(api_base("v1/categories/create"), category); @@ -75,7 +75,7 @@ export async function delete_time_category(id: string): Promise<IInternalFetchRe return http_delete(api_base("v1/categories/" + id + "/delete")); } -export async function update_time_category(category: TimeCategoryDto): Promise<IInternalFetchResponse> { +export async function update_time_category(category: WorkCategory): Promise<IInternalFetchResponse> { if (!is_guid(category.id ?? "")) throw new Error("id is not a valid guid"); if (!category.name) throw new Error("name is empty"); if (!category.color) throw new Error("color is empty"); |
