mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
cleanup dayjs abstraction usage and useCurrentTimeEntry api for starting and stopping time entries
This commit is contained in:
@@ -4,8 +4,8 @@ import TimeTrackerStartStop from '@/packages/ui/src/TimeTrackerStartStop.vue';
|
||||
import { useProjectsStore } from '@/utils/useProjects';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { useCurrentTimeEntryStore } from '@/utils/useCurrentTimeEntry';
|
||||
import { getDayJsInstance } from '@/packages/ui/src/utils/time';
|
||||
|
||||
const props = defineProps<{
|
||||
title: string;
|
||||
@@ -20,16 +20,16 @@ const project = computed(() => {
|
||||
});
|
||||
|
||||
const { currentTimeEntry } = storeToRefs(useCurrentTimeEntryStore());
|
||||
const { stopTimer, startTimer } = useCurrentTimeEntryStore();
|
||||
const { setActiveState } = useCurrentTimeEntryStore();
|
||||
|
||||
async function startTaskTimer() {
|
||||
if (currentTimeEntry.value.id) {
|
||||
await stopTimer();
|
||||
await setActiveState(true);
|
||||
}
|
||||
currentTimeEntry.value.project_id = props.project_id;
|
||||
currentTimeEntry.value.task_id = props.task_id;
|
||||
currentTimeEntry.value.start = dayjs().utc().format();
|
||||
await startTimer();
|
||||
currentTimeEntry.value.start = getDayJsInstance().utc().format();
|
||||
await setActiveState(true);
|
||||
useCurrentTimeEntryStore().fetchCurrentTimeEntry();
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -42,14 +42,14 @@ const loadMoreContainer = ref<HTMLDivElement | null>(null);
|
||||
const isLoadMoreVisible = useElementVisibility(loadMoreContainer);
|
||||
const currentTimeEntryStore = useCurrentTimeEntryStore();
|
||||
const { currentTimeEntry } = storeToRefs(currentTimeEntryStore);
|
||||
const { stopTimer } = currentTimeEntryStore;
|
||||
const { setActiveState } = currentTimeEntryStore;
|
||||
const { tags } = storeToRefs(useTagsStore());
|
||||
|
||||
async function startTimeEntry(
|
||||
timeEntry: Omit<CreateTimeEntryBody, 'member_id'>
|
||||
) {
|
||||
if (currentTimeEntry.value.id) {
|
||||
await stopTimer();
|
||||
await setActiveState(false);
|
||||
}
|
||||
await createTimeEntry(timeEntry);
|
||||
fetchTimeEntries();
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
import TimeEntryAggregateRow from '@/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue';
|
||||
import TimeEntryRowHeading from '@/packages/ui/src/TimeEntry/TimeEntryRowHeading.vue';
|
||||
import TimeEntryRow from '@/packages/ui/src/TimeEntry/TimeEntryRow.vue';
|
||||
import dayjs from 'dayjs';
|
||||
import type { TimeEntriesGroupedByType } from '@/types/time-entries';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -106,7 +105,7 @@ function startTimeEntryFromExisting(entry: TimeEntry) {
|
||||
props.createTimeEntry({
|
||||
project_id: entry.project_id,
|
||||
task_id: entry.task_id,
|
||||
start: dayjs().utc().format(),
|
||||
start: getDayJsInstance().utc().format(),
|
||||
end: null,
|
||||
billable: entry.billable,
|
||||
description: entry.description,
|
||||
|
||||
@@ -205,8 +205,6 @@ export const useCurrentTimeEntryStore = defineStore('currentTimeEntry', () => {
|
||||
return {
|
||||
currentTimeEntry,
|
||||
fetchCurrentTimeEntry,
|
||||
startTimer,
|
||||
stopTimer,
|
||||
updateTimer,
|
||||
isActive,
|
||||
startLiveTimer,
|
||||
|
||||
Reference in New Issue
Block a user