mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-12 10:12:17 +01:00
add is_billable support for create / update project and in timetracker, fixes ST-217
This commit is contained in:
committed by
Constantin Graf
parent
d9244d1ab4
commit
7fb58ea341
@@ -108,3 +108,18 @@ export type AggregatedTimeEntriesQueryParams = ZodiosQueryParamsByAlias<
|
||||
SolidTimeApi,
|
||||
'getAggregatedTimeEntries'
|
||||
>;
|
||||
|
||||
export type OrganizationResponse = ZodiosResponseByAlias<
|
||||
SolidTimeApi,
|
||||
'getOrganization'
|
||||
>;
|
||||
|
||||
export type Organization = ZodiosResponseByAlias<
|
||||
SolidTimeApi,
|
||||
'getOrganization'
|
||||
>['data'];
|
||||
|
||||
export type UpdateOrganizationBody = ZodiosBodyByAlias<
|
||||
SolidTimeApi,
|
||||
'updateOrganization'
|
||||
>;
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import { router } from '@inertiajs/vue3';
|
||||
import { initializeStores } from '@/utils/init';
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import type {
|
||||
Organization,
|
||||
OrganizationResponse,
|
||||
UpdateOrganizationBody,
|
||||
} from '@/utils/api';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { api } from '../../../openapi.json.client';
|
||||
|
||||
export function switchOrganization(organizationId: string) {
|
||||
router.put(
|
||||
@@ -15,3 +25,49 @@ export function switchOrganization(organizationId: string) {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const useOrganizationStore = defineStore('organization', () => {
|
||||
const organizationResponse = ref<OrganizationResponse | null>(null);
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
|
||||
async function fetchOrganization() {
|
||||
const organization = getCurrentOrganizationId();
|
||||
if (organization) {
|
||||
organizationResponse.value = await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.getOrganization({
|
||||
params: {
|
||||
organization: organization,
|
||||
},
|
||||
}),
|
||||
undefined,
|
||||
'Failed to fetch organization'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function updateOrganization(
|
||||
organizationBody: UpdateOrganizationBody
|
||||
) {
|
||||
const organization = getCurrentOrganizationId();
|
||||
if (organization) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.updateOrganization(organizationBody, {
|
||||
params: {
|
||||
organization: organization,
|
||||
},
|
||||
}),
|
||||
'Organization updated successfully',
|
||||
'Failed to update organization'
|
||||
);
|
||||
await fetchOrganization();
|
||||
}
|
||||
}
|
||||
|
||||
const organization = computed<Organization | null>(() => {
|
||||
return organizationResponse.value?.data || null;
|
||||
});
|
||||
|
||||
return { organization, fetchOrganization, updateOrganization };
|
||||
});
|
||||
|
||||
@@ -10,6 +10,8 @@ import type {
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
|
||||
export type BillableKey = 'non-billable' | 'default-rate' | 'custom-rate';
|
||||
|
||||
export const useProjectsStore = defineStore('projects', () => {
|
||||
const projectResponse = ref<ProjectResponse | null>(null);
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
|
||||
Reference in New Issue
Block a user