mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-15 03:32:15 +01:00
add project edit modal
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { api } from '../../../openapi.json.client';
|
||||
import { computed, ref } from 'vue';
|
||||
import type { CreateProjectBody, Project, ProjectResponse } from '@/utils/api';
|
||||
import type {
|
||||
CreateProjectBody,
|
||||
Project,
|
||||
ProjectResponse,
|
||||
UpdateProjectBody,
|
||||
} from '@/utils/api';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
|
||||
@@ -60,9 +65,35 @@ export const useProjectsStore = defineStore('projects', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateProject(
|
||||
projectId: string,
|
||||
updateProjectBody: UpdateProjectBody
|
||||
) {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
api.updateProject(updateProjectBody, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
project: projectId,
|
||||
},
|
||||
}),
|
||||
'Project deleted successfully',
|
||||
'Failed to delete project'
|
||||
);
|
||||
await fetchProjects();
|
||||
}
|
||||
}
|
||||
|
||||
const projects = computed<Project[]>(
|
||||
() => projectResponse.value?.data || []
|
||||
);
|
||||
|
||||
return { projects, fetchProjects, createProject, deleteProject };
|
||||
return {
|
||||
projects,
|
||||
fetchProjects,
|
||||
createProject,
|
||||
deleteProject,
|
||||
updateProject,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user