mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-12 15:53:19 +01:00
refactor timetracker to seperate data and ui logic
This commit is contained in:
@@ -128,6 +128,13 @@ export type UpdateOrganizationBody = ZodiosBodyByAlias<
|
||||
'updateOrganization'
|
||||
>;
|
||||
|
||||
export type MyMemberships = ZodiosResponseByAlias<
|
||||
SolidTimeApi,
|
||||
'getMyMemberships'
|
||||
>['data'];
|
||||
|
||||
export type MyMembership = MyMemberships[0];
|
||||
|
||||
export async function fetchToken() {
|
||||
return new Promise((resolve) => {
|
||||
router.reload({
|
||||
|
||||
@@ -90,7 +90,7 @@ export const useNotificationsStore = defineStore('notifications', () => {
|
||||
);
|
||||
}
|
||||
}
|
||||
throw new Error('Failed to handle API request', { cause: error });
|
||||
throw new Error('Failed to handle API request');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,15 +76,12 @@ export const useClientsStore = defineStore('clients', () => {
|
||||
if (organization) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.deleteClient(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organization,
|
||||
client: clientId,
|
||||
},
|
||||
}
|
||||
),
|
||||
api.deleteClient(undefined, {
|
||||
params: {
|
||||
organization: organization,
|
||||
client: clientId,
|
||||
},
|
||||
}),
|
||||
'Client deleted successfully',
|
||||
'Failed to delete client'
|
||||
);
|
||||
|
||||
@@ -36,15 +36,12 @@ export const useMembersStore = defineStore('members', () => {
|
||||
if (organization) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.removeMember(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organization,
|
||||
member: membershipId,
|
||||
},
|
||||
}
|
||||
),
|
||||
api.removeMember(undefined, {
|
||||
params: {
|
||||
organization: organization,
|
||||
member: membershipId,
|
||||
},
|
||||
}),
|
||||
'Member deleted successfully',
|
||||
'Failed to delete member'
|
||||
);
|
||||
|
||||
@@ -81,15 +81,12 @@ export const useProjectMembersStore = defineStore('project-members', () => {
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.deleteProjectMember(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organizationId,
|
||||
projectMember: projectMemberId,
|
||||
},
|
||||
}
|
||||
),
|
||||
api.deleteProjectMember(undefined, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
projectMember: projectMemberId,
|
||||
},
|
||||
}),
|
||||
'Project member removed successfully',
|
||||
'Failed to remove project member'
|
||||
);
|
||||
|
||||
@@ -37,7 +37,7 @@ export const useProjectsStore = defineStore('projects', () => {
|
||||
async function createProject(projectBody: CreateProjectBody) {
|
||||
const organization = getCurrentOrganizationId();
|
||||
if (organization) {
|
||||
await handleApiRequestNotifications(
|
||||
const response = await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.createProject(projectBody, {
|
||||
params: {
|
||||
@@ -49,6 +49,7 @@ export const useProjectsStore = defineStore('projects', () => {
|
||||
);
|
||||
|
||||
await fetchProjects();
|
||||
return response['data'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,15 +58,12 @@ export const useProjectsStore = defineStore('projects', () => {
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.deleteProject(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organizationId,
|
||||
project: projectId,
|
||||
},
|
||||
}
|
||||
),
|
||||
api.deleteProject(undefined, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
project: projectId,
|
||||
},
|
||||
}),
|
||||
'Project deleted successfully',
|
||||
'Failed to delete project'
|
||||
);
|
||||
|
||||
@@ -36,15 +36,12 @@ export const useTagsStore = defineStore('tags', () => {
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.deleteTag(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organizationId,
|
||||
tag: tagId,
|
||||
},
|
||||
}
|
||||
),
|
||||
api.deleteTag(undefined, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
tag: tagId,
|
||||
},
|
||||
}),
|
||||
'Tag deleted successfully',
|
||||
'Failed to delete tag'
|
||||
);
|
||||
|
||||
@@ -68,15 +68,12 @@ export const useTasksStore = defineStore('tasks', () => {
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.deleteTask(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organizationId,
|
||||
task: taskId,
|
||||
},
|
||||
}
|
||||
),
|
||||
api.deleteTask(undefined, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
task: taskId,
|
||||
},
|
||||
}),
|
||||
'Task deleted successfully',
|
||||
'Failed to delete task'
|
||||
);
|
||||
|
||||
@@ -9,8 +9,6 @@ import type { CreateTimeEntryBody, TimeEntry } from '@/utils/api';
|
||||
import dayjs from 'dayjs';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
|
||||
export type TimeEntriesGroupedByType = TimeEntry & { timeEntries: TimeEntry[] };
|
||||
|
||||
export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
||||
const timeEntries = ref<TimeEntry[]>(reactive([]));
|
||||
|
||||
@@ -124,15 +122,12 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.deleteTimeEntry(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organizationId,
|
||||
timeEntry: timeEntryId,
|
||||
},
|
||||
}
|
||||
),
|
||||
api.deleteTimeEntry(undefined, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
timeEntry: timeEntryId,
|
||||
},
|
||||
}),
|
||||
'Time entry deleted successfully',
|
||||
'Failed to delete time entry'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user