2024-09-10 08:49:09 +02:00
|
|
|
import { defineStore } from "pinia";
|
|
|
|
|
import { useApiStore } from "./api.js";
|
2024-09-10 09:12:52 +02:00
|
|
|
import { ref, computed } from "vue";
|
2024-09-10 08:49:09 +02:00
|
|
|
|
|
|
|
|
export const useProjectsStore = defineStore("projects", () => {
|
|
|
|
|
const projects = ref([]);
|
|
|
|
|
|
2024-09-10 09:12:52 +02:00
|
|
|
const currentProjects = computed(() => {
|
|
|
|
|
return projects.value.filter((project) => project.status === "listed");
|
|
|
|
|
});
|
|
|
|
|
const archivedProjects = computed(() => {
|
|
|
|
|
return projects.value.filter((project) => project.status === "unlisted");
|
|
|
|
|
});
|
|
|
|
|
|
2024-09-10 08:49:09 +02:00
|
|
|
const api = useApiStore();
|
2024-09-10 09:12:52 +02:00
|
|
|
api
|
2024-10-28 15:33:52 +01:00
|
|
|
.fetchData("projects")
|
|
|
|
|
.then((json) => (projects.value = json.page.children));
|
2024-09-10 08:49:09 +02:00
|
|
|
|
2024-09-10 09:12:52 +02:00
|
|
|
return { projects, currentProjects, archivedProjects };
|
2024-09-10 08:49:09 +02:00
|
|
|
});
|