mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-13 18:52:14 +01:00
add edit modal for tasks and clients, fixes ST-233
This commit is contained in:
@@ -64,6 +64,7 @@ export type ProjectMember = ProjectMemberResponse['data'][0];
|
||||
export type CreateTaskBody = ZodiosBodyByAlias<SolidTimeApi, 'createTask'>;
|
||||
|
||||
export type CreateClientBody = ZodiosBodyByAlias<SolidTimeApi, 'createClient'>;
|
||||
export type UpdateClientBody = ZodiosBodyByAlias<SolidTimeApi, 'updateClient'>;
|
||||
|
||||
export type TagIndexResponse = ZodiosResponseByAlias<SolidTimeApi, 'getTags'>;
|
||||
export type Tag = TagIndexResponse['data'][0];
|
||||
@@ -71,6 +72,8 @@ export type Tag = TagIndexResponse['data'][0];
|
||||
export type TaskIndexResponse = ZodiosResponseByAlias<SolidTimeApi, 'getTasks'>;
|
||||
export type Task = TaskIndexResponse['data'][0];
|
||||
|
||||
export type UpdateTaskBody = ZodiosBodyByAlias<SolidTimeApi, 'updateTask'>;
|
||||
|
||||
export type ClientIndexResponse = ZodiosResponseByAlias<
|
||||
SolidTimeApi,
|
||||
'getClients'
|
||||
|
||||
@@ -41,6 +41,10 @@ export function canCreateTasks() {
|
||||
return currentUserHasPermission('tasks:create');
|
||||
}
|
||||
|
||||
export function canUpdateTasks() {
|
||||
return currentUserHasPermission('tasks:update');
|
||||
}
|
||||
|
||||
export function canDeleteTasks() {
|
||||
return currentUserHasPermission('tasks:delete');
|
||||
}
|
||||
@@ -49,6 +53,10 @@ export function canCreateClients() {
|
||||
return currentUserHasPermission('clients:create');
|
||||
}
|
||||
|
||||
export function canUpdateClients() {
|
||||
return currentUserHasPermission('clients:update');
|
||||
}
|
||||
|
||||
export function canDeleteClients() {
|
||||
return currentUserHasPermission('clients:delete');
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
CreateClientBody,
|
||||
ClientIndexResponse,
|
||||
Client,
|
||||
UpdateClientBody,
|
||||
} from '@/utils/api';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
@@ -49,6 +50,27 @@ export const useClientsStore = defineStore('clients', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateClient(
|
||||
clientId: string,
|
||||
clientBody: UpdateClientBody
|
||||
) {
|
||||
const organization = getCurrentOrganizationId();
|
||||
if (organization) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.updateClient(clientBody, {
|
||||
params: {
|
||||
organization: organization,
|
||||
client: clientId,
|
||||
},
|
||||
}),
|
||||
'Client updated successfully',
|
||||
'Failed to update client'
|
||||
);
|
||||
await fetchClients();
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteClient(clientId: string) {
|
||||
const organization = getCurrentOrganizationId();
|
||||
if (organization) {
|
||||
@@ -74,5 +96,5 @@ export const useClientsStore = defineStore('clients', () => {
|
||||
return clientResponse.value?.data || [];
|
||||
});
|
||||
|
||||
return { clients, fetchClients, createClient, deleteClient };
|
||||
return { clients, fetchClients, createClient, deleteClient, updateClient };
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
import { api } from '../../../openapi.json.client';
|
||||
import { reactive, ref } from 'vue';
|
||||
import type { CreateTaskBody, Task } from '@/utils/api';
|
||||
import type { CreateTaskBody, Task, UpdateTaskBody } from '@/utils/api';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
|
||||
export const useTasksStore = defineStore('tasks', () => {
|
||||
@@ -25,20 +25,21 @@ export const useTasksStore = defineStore('tasks', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateTask(task: Task) {
|
||||
async function updateTask(taskId: string, taskBody: UpdateTaskBody) {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
() =>
|
||||
api.updateTask(task, {
|
||||
api.updateTask(taskBody, {
|
||||
params: {
|
||||
task: taskId,
|
||||
organization: organizationId,
|
||||
task: task.id,
|
||||
},
|
||||
}),
|
||||
'Task updated successfully',
|
||||
'Failed to update task'
|
||||
);
|
||||
await fetchTasks();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user