add isProjectLoadingState
This commit is contained in:
parent
7ce5878898
commit
fd9db75f2a
2 changed files with 30 additions and 27 deletions
|
|
@ -1,24 +1,26 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { useApiStore } from "./api.js";
|
||||
import { ref, computed } from "vue";
|
||||
import { defineStore } from 'pinia';
|
||||
import { useApiStore } from './api.js';
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
export const useProjectsStore = defineStore("projects", () => {
|
||||
export const useProjectsStore = defineStore('projects', () => {
|
||||
const isProjectsLoading = ref(true);
|
||||
const projects = ref([]);
|
||||
|
||||
const currentProjects = computed(() => {
|
||||
return projects.value.filter((project) => project.status === "listed");
|
||||
return projects.value.filter((project) => project.status === 'listed');
|
||||
});
|
||||
const draftProjects = computed(() => {
|
||||
return projects.value.filter((project) => project.status === "draft");
|
||||
return projects.value.filter((project) => project.status === 'draft');
|
||||
});
|
||||
const archivedProjects = computed(() => {
|
||||
return projects.value.filter((project) => project.status === "unlisted");
|
||||
return projects.value.filter((project) => project.status === 'unlisted');
|
||||
});
|
||||
|
||||
const api = useApiStore();
|
||||
api
|
||||
.fetchData("projects")
|
||||
.then((json) => (projects.value = json.page.children));
|
||||
api.fetchData('projects').then((json) => {
|
||||
isProjectsLoading.value = false;
|
||||
projects.value = json.page.children;
|
||||
});
|
||||
|
||||
// Functions
|
||||
function getProjectByUuid(uuid) {
|
||||
|
|
@ -32,5 +34,6 @@ export const useProjectsStore = defineStore("projects", () => {
|
|||
archivedProjects,
|
||||
draftProjects,
|
||||
getProjectByUuid,
|
||||
isProjectsLoading,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue