interaktivna Tablica radnih sati, db
Some checks failed
ERP CI/CD Pipeline / test (push) Has been cancelled
ERP CI/CD Pipeline / Deploy (server git pull + compose) (push) Has been cancelled

This commit is contained in:
mariomitte
2026-07-13 00:36:28 +02:00
parent 70151f1225
commit 3ad536a23e
22 changed files with 1629 additions and 174 deletions

View File

@@ -1,14 +1,17 @@
// src/stores/taskStore.js
// src/stores/taskStore.js
import { atom } from 'nanostores';
import { api } from '../services/apiClient';
import { showToast } from './toastStore';
export const $tasks = atom([]);
export const $tasksLoading = atom(false);
export const $taskTemplates = atom([]);
export const $taskTemplatesLoading = atom(false);
const STATUS_LABELS = {
aktivan: 'Aktivan',
servis: 'U tijeku',
zavrsen: 'Završen',
neaktivan: 'Otkazano',
};
@@ -35,6 +38,23 @@ export async function fetchTasks() {
}
}
export async function fetchTaskTemplates() {
$taskTemplatesLoading.set(true);
try {
const data = await api.get('tasks/tasks/templates/');
const templates = Array.isArray(data) ? data : (data?.results ?? []);
$taskTemplates.set(templates);
return templates;
} catch (error) {
if (error?.status !== 401) {
showToast('Greška pri dohvatu predložaka zadataka.', 'error');
}
throw error;
} finally {
$taskTemplatesLoading.set(false);
}
}
export async function createTask(data) {
const response = await api.post('tasks/tasks/', data);
$tasks.set([response, ...$tasks.get()]);