| 123456789101112131415161718192021222324252627282930 |
- import { defineStore } from "pinia";
- import { Lecturer } from "../api/types/lecturers";
- import { getLecturers } from "../api/modules/lecturers";
- export const useLecturersStore = defineStore("lecturers", {
- state: () => {
- return {
- data: [] as Lecturer[],
- };
- },
- actions: {
- fetchData() {
- getLecturers()
- .then((data) => {
- this.data = data;
- })
- .catch((error) => {
- console.error(error);
- this.data = [];
- });
- },
- fromShort(shorts: string[]): Lecturer[] {
- const r = this.data.filter((el) => {
- return shorts.includes(el.short);
- });
- return r;
- },
- },
- });
|