This repository has been archived on 2025-06-10. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
server/qa/ui/src/lib/stores/exercices.js

39 lines
678 B
JavaScript

import { writable, derived } from 'svelte/store';
import { getExercices } from '$lib/exercices'
function createExercicesStore() {
const { subscribe, set, update } = writable([]);
return {
subscribe,
set: (v) => {
update((m) => Object.assign(m, v));
},
update,
refresh: async () => {
const list = await getExercices();
update((m) => list);
return list;
},
};
}
export const exercices = createExercicesStore();
export const exercicesIdx = derived(
exercices,
$exercices => {
const exercices_idx = { };
for (const e of $exercices) {
exercices_idx[e.id] = e;
}
return exercices_idx;
},
);