summaryrefslogtreecommitdiffstats
path: root/apps/projects/src/app/pages
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-06-13 21:08:22 +0200
committerivarlovlie <git@ivarlovlie.no>2022-06-13 21:08:22 +0200
commit3ff255b3f75d3c2d860ccd84aa06032f840ce0e6 (patch)
treea693e36f007e5e4f3c20ecfffc91b2f2ad77b0ce /apps/projects/src/app/pages
parent39735309b2f2831ea8fe94104139fa0e9f6ace56 (diff)
downloadgreatoffice-3ff255b3f75d3c2d860ccd84aa06032f840ce0e6.tar.xz
greatoffice-3ff255b3f75d3c2d860ccd84aa06032f840ce0e6.zip
refactor: Introduce templated translation string for getting logged time today string
Diffstat (limited to 'apps/projects/src/app/pages')
-rw-r--r--apps/projects/src/app/pages/home.svelte28
1 files changed, 15 insertions, 13 deletions
diff --git a/apps/projects/src/app/pages/home.svelte b/apps/projects/src/app/pages/home.svelte
index ff52275..145ae66 100644
--- a/apps/projects/src/app/pages/home.svelte
+++ b/apps/projects/src/app/pages/home.svelte
@@ -1,25 +1,26 @@
<script lang="ts">
import LL from "$app/lib/i18n/i18n-svelte";
- import {delete_time_entry, get_time_entries, get_time_entry} from "$shared/lib/api/time-entry";
- import {IconNames, QueryKeys} from "$shared/lib/configuration";
- import {TimeEntryDto} from "$shared/lib/models/TimeEntryDto";
- import {Temporal} from "@js-temporal/polyfill";
- import {useMutation, useQuery, useQueryClient} from "@sveltestack/svelte-query";
- import {onMount} from "svelte";
+ import { delete_time_entry, get_time_entries, get_time_entry } from "$shared/lib/api/time-entry";
+ import { IconNames, QueryKeys } from "$shared/lib/configuration";
+ import { TimeEntryDto } from "$shared/lib/models/TimeEntryDto";
+ import { Temporal } from "@js-temporal/polyfill";
+ import { useMutation, useQuery, useQueryClient } from "@sveltestack/svelte-query";
+ import { onMount } from "svelte";
import Tile from "$shared/components/tile.svelte";
import Button from "$shared/components/button.svelte";
import Stopwatch from "$shared/components/stopwatch.svelte";
- import {Table, THead, TBody, TCell, TRow} from "$shared/components/table";
+ import { Table, THead, TBody, TCell, TRow } from "$shared/components/table";
import Layout from "./_layout.svelte";
import EntryFrom from "$app/pages/views/entry-form/index.svelte";
- import {seconds_to_hour_minute_string, unwrap_date_time_from_entry} from "$shared/lib/helpers";
- import {TimeEntryQueryDuration} from "$shared/lib/models/TimeEntryQuery";
+ import { seconds_to_hour_minute, unwrap_date_time_from_entry } from "$shared/lib/helpers";
+ import { TimeEntryQueryDuration } from "$shared/lib/models/TimeEntryQuery";
let currentTime = "";
let isLoading = false;
let EditEntryForm: any;
let timeEntries = [] as Array<TimeEntryDto>;
- let timeLoggedTodayString = "0" + $LL.home.hourSingleChar() + "0" + $LL.home.minSingleChar();
+ let timeLoggedTodayString = $LL.home.loggedTimeTodayString({hours: 0, minutes: 0});
+ let loggedSecondsToday = 0;
const queryClient = useQueryClient();
const queryResult = useQuery(QueryKeys.entries, async () => await get_time_entries({
@@ -28,7 +29,7 @@
pageSize: 100,
})?.data ?? []
);
-
+
function set_current_time() {
currentTime = Temporal.Now.plainTimeISO().toLocaleString(undefined, {
timeStyle: "short",
@@ -56,6 +57,7 @@
}
function on_create_from_stopwatch(event) {
+ console.log(event.detail);
EditEntryForm.set_time({to: event.detail.to, from: event.detail.from});
if (event.detail.description) {
EditEntryForm.set_description(event.detail.description);
@@ -69,7 +71,7 @@
}, 1e4);
queryResult.subscribe((result) => {
const newEntries = [];
- let loggedSecondsToday = 0;
+ loggedSecondsToday = 0;
for (const entry of result.data?.results ?? []) {
const date_time = unwrap_date_time_from_entry(entry);
newEntries.push({
@@ -80,7 +82,7 @@
});
loggedSecondsToday += (date_time.duration.hours * 60 * 60) + (date_time.duration.minutes * 60);
}
- timeLoggedTodayString = seconds_to_hour_minute_string(loggedSecondsToday);
+ timeLoggedTodayString = $LL.home.loggedTimeTodayString(seconds_to_hour_minute(loggedSecondsToday));
timeEntries = newEntries;
});
});