From 7bbd3891a76d3a6da20a4aa3888e6da87e41aa6d Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Mon, 10 Oct 2022 00:42:33 +0800 Subject: refactor/fix: Small refactors/fixes, update imports --- code/app/src/lib/api/time-entry.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'code/app/src/lib/api/time-entry.ts') 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 { +export async function create_time_entry(payload: WorkEntry): Promise { return http_post(api_base("v1/entries/create"), payload); } @@ -21,7 +21,7 @@ export async function get_time_entry(entryId: string): Promise { +export async function get_time_entries(entryQuery: WorkQuery): Promise { return http_post(api_base("v1/entries/query"), entryQuery); } @@ -30,7 +30,7 @@ export async function delete_time_entry(id: string): Promise { +export async function update_time_entry(entryDto: WorkEntry): Promise { 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 { +export async function create_time_label(labelDto: WorkLabel): Promise { return http_post(api_base("v1/labels/create"), labelDto); } @@ -52,7 +52,7 @@ export async function delete_time_label(id: string): Promise { +export async function update_time_label(labelDto: WorkLabel): Promise { 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 { +export async function create_time_category(category: WorkCategory): Promise { 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 { +export async function update_time_category(category: WorkCategory): Promise { 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"); -- cgit v1.3