| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { defineStore } from 'pinia'
- import axios from 'axios'
- export const useFooterLinksStore = defineStore('footerLinks',{
- state: () => ({
- token: "c1f8dac9ec1b803aa0902dced56958c91115acbbc216832757f95457d25bde1682863bb6144d574297560f3139f0e8610d05509a4d37ec19b96d0366f4b3ccdd246c97cdff0d877eb12ec3272b58d3203fd050267c5d089b68b9e8198534d74ded49564a6a5bd64e3825b617b0f0a6fe07fdada4ae941f15b6b144abdc89d804",
- locale: (localStorage.getItem('lang') || 'de'),
- links: []
- }),
- actions: {
- async getLinks(locale:string){
- await this.setLocale(locale)
- return this.links
- },
- getLinkByLabel(oldLabel:string){
- return this.links.find((link:any) => (link.Label as string) == oldLabel)
- },
- async setLocale(locale:string){
- if (this.links.length == 0 || this.locale != locale){
- this.locale = locale
- await this.fetchLinks()
- }
- },
- async fetchLinks(){
- const response = await axios.get('https://strapi.kornblum.one/api/footer-content-pages?&populate[localizations][fields][0]=Label&populate[page][fields][1]=path&locale='+this.locale, {
- headers: {
- Authorization: "Bearer "+this.token,
- },
- })
- this.links = response.data.data
- },
- }
- })
|