mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-14 11:12:16 +01:00
improve error handling for 401 requests and fetch
This commit is contained in:
@@ -12,7 +12,7 @@ export const useTasksStore = defineStore('tasks', () => {
|
||||
async function fetchTasks() {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (organizationId) {
|
||||
const tasksResponse = await handleApiRequestNotifications(
|
||||
const tasksResponse = await handleApiRequestNotifications(() =>
|
||||
api.getTasks({
|
||||
params: {
|
||||
organization: organizationId,
|
||||
@@ -29,12 +29,13 @@ export const useTasksStore = defineStore('tasks', () => {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
api.updateTask(task, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
task: task.id,
|
||||
},
|
||||
}),
|
||||
() =>
|
||||
api.updateTask(task, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
task: task.id,
|
||||
},
|
||||
}),
|
||||
'Task updated successfully',
|
||||
'Failed to update task'
|
||||
);
|
||||
@@ -45,11 +46,12 @@ export const useTasksStore = defineStore('tasks', () => {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
api.createTask(task, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
},
|
||||
}),
|
||||
() =>
|
||||
api.createTask(task, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
},
|
||||
}),
|
||||
'Task created successfully',
|
||||
'Failed to create task'
|
||||
);
|
||||
@@ -61,15 +63,16 @@ export const useTasksStore = defineStore('tasks', () => {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (organizationId) {
|
||||
await handleApiRequestNotifications(
|
||||
api.deleteTask(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organizationId,
|
||||
task: taskId,
|
||||
},
|
||||
}
|
||||
),
|
||||
() =>
|
||||
api.deleteTask(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organizationId,
|
||||
task: taskId,
|
||||
},
|
||||
}
|
||||
),
|
||||
'Task deleted successfully',
|
||||
'Failed to delete task'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user