|
|
@@ -2,34 +2,30 @@ import { defineStore } from 'pinia'
|
|
|
import axios from 'axios'
|
|
|
import type { Component } from '../types/component'
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-export const useComponentStore = defineStore('components',{
|
|
|
+export const useComponentStore = defineStore('components', {
|
|
|
state: () => ({
|
|
|
components: [] as Array<Component>,
|
|
|
locale: (localStorage.getItem('lang') || 'de')
|
|
|
}),
|
|
|
actions: {
|
|
|
- async getComponents(locale: string){
|
|
|
+ async getComponents(locale: string) {
|
|
|
await this.setLocale(locale)
|
|
|
return this.components
|
|
|
|
|
|
},
|
|
|
|
|
|
- async setLocale(locale: string){
|
|
|
- if(this.components.length == 0 || this.locale != locale ){
|
|
|
+ async setLocale(locale: string) {
|
|
|
+ if (this.components.length == 0 || this.locale != locale) {
|
|
|
this.locale = locale
|
|
|
await this.fetchComponents()
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- async fetchComponents(){
|
|
|
- const response = await axios.get('https://strapi.kornblum.one/api/components?locale='+this.locale, {
|
|
|
- headers: {
|
|
|
- Authorization: "Bearer "+ import.meta.env.VITE_STRAPI_TOKEN,
|
|
|
- },
|
|
|
+ async fetchComponents() {
|
|
|
+ const response = await axios.get(import.meta.env.VITE_STRAPI_URL + '/api/components?locale=' + this.locale, {
|
|
|
+ headers: {
|
|
|
+ Authorization: "Bearer " + import.meta.env.VITE_STRAPI_TOKEN,
|
|
|
+ },
|
|
|
})
|
|
|
this.components = response.data.data
|
|
|
},
|