mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-16 04:02:15 +01:00
add basic crud frontend for clients, tags and projects
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { api } from '../../../openapi.json.client';
|
||||
import { computed, ref } from 'vue';
|
||||
import type { Project, ProjectResponse } from '@/utils/api';
|
||||
import type { CreateProjectBody, Project, ProjectResponse } from '@/utils/api';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
|
||||
export const useProjectsStore = defineStore('projects', () => {
|
||||
@@ -18,9 +18,37 @@ export const useProjectsStore = defineStore('projects', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function createProject(projectBody: CreateProjectBody) {
|
||||
const organization = getCurrentOrganizationId();
|
||||
if (organization) {
|
||||
await api.createProject(projectBody, {
|
||||
params: {
|
||||
organization: organization,
|
||||
},
|
||||
});
|
||||
await fetchProjects();
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteProject(projectId: string) {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (organizationId) {
|
||||
await api.deleteProject(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organizationId,
|
||||
project: projectId,
|
||||
},
|
||||
}
|
||||
);
|
||||
await fetchProjects();
|
||||
}
|
||||
}
|
||||
|
||||
const projects = computed<Project[]>(
|
||||
() => projectResponse.value?.data || []
|
||||
);
|
||||
|
||||
return { projects, fetchProjects };
|
||||
return { projects, fetchProjects, createProject, deleteProject };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user