add notice when time tracker is running in a different organization

This commit is contained in:
Gregor Vostrak
2024-04-26 02:10:45 +02:00
parent 3c158cc015
commit bb5ccf3606
9 changed files with 237 additions and 81 deletions

View File

@@ -22,6 +22,7 @@ const emptyTimeEntry = {
project_id: null,
tags: [],
billable: false,
organization_id: '',
} as TimeEntry;
export const useCurrentTimeEntryStore = defineStore('currentTimeEntry', () => {
@@ -56,20 +57,10 @@ export const useCurrentTimeEntryStore = defineStore('currentTimeEntry', () => {
async function fetchCurrentTimeEntry() {
const organizationId = getCurrentOrganizationId();
if (organizationId) {
const timeEntriesResponse = await handleApiRequestNotifications(
api.getTimeEntries({
queries: {
active: 'true',
user_id: getCurrentUserId(),
},
params: {
organization: organizationId,
},
})
);
const timeEntriesResponse = await api.getMyActiveTimeEntry({});
if (timeEntriesResponse?.data) {
if (timeEntriesResponse.data.length === 1) {
currentTimeEntry.value = timeEntriesResponse.data[0];
if (timeEntriesResponse.data) {
currentTimeEntry.value = timeEntriesResponse.data;
} else {
currentTimeEntry.value = { ...emptyTimeEntry };
}