mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-13 10:42:16 +01:00
add notice when time tracker is running in a different organization
This commit is contained in:
@@ -7,7 +7,6 @@ const page = usePage<{
|
||||
}>();
|
||||
|
||||
function currentUserHasPermission(permission: string) {
|
||||
console.log(page.props.auth.permissions);
|
||||
if (Array.isArray(page.props.auth.permissions)) {
|
||||
return page.props.auth.permissions.includes(permission);
|
||||
}
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
17
resources/js/utils/useOrganization.ts
Normal file
17
resources/js/utils/useOrganization.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { router } from '@inertiajs/vue3';
|
||||
import { initializeStores } from '@/utils/init';
|
||||
|
||||
export function switchOrganization(organizationId: string) {
|
||||
router.put(
|
||||
route('current-team.update'),
|
||||
{
|
||||
team_id: organizationId,
|
||||
},
|
||||
{
|
||||
preserveState: false,
|
||||
onSuccess: () => {
|
||||
initializeStores();
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user