23 lines
650 B
TypeScript
23 lines
650 B
TypeScript
import { defineStore } from 'pinia';
|
|
import { useAccessToken } from '../composables/useAccessToken';
|
|
import { BACKEND_URL } from '../constants';
|
|
import { BuildingListItem } from '../interfaces/building.interfaces';
|
|
import jfetch from '../utils/jfetch';
|
|
|
|
const { authHeader } = useAccessToken();
|
|
export const useBuildingStore = defineStore('building', {
|
|
state: () => {
|
|
return {
|
|
buildings: [] as BuildingListItem[],
|
|
};
|
|
},
|
|
actions: {
|
|
async getBuildings() {
|
|
const { data: buildings } = await jfetch(`${BACKEND_URL}/buildings`, {
|
|
headers: authHeader.value,
|
|
});
|
|
this.buildings = buildings;
|
|
},
|
|
},
|
|
});
|