Benjamin Kornblum пре 8 месеци
родитељ
комит
6e1a9b74fb
4 измењених фајлова са 66 додато и 28 уклоњено
  1. 10 10
      src/router/index.ts
  2. 18 14
      src/stores/footer-content-pages.ts
  3. 4 4
      src/stores/pages.ts
  4. 34 0
      src/stores/timeline.ts

+ 10 - 10
src/router/index.ts

@@ -4,29 +4,29 @@ import PageView from '@/views/PageView.vue'
 import { usePageStore } from '@/stores/pages'
 import axios from 'axios'
 
-let locale:String = (localStorage.getItem('lang') || 'de')
+let locale:string = (localStorage.getItem('lang') || 'de')
 let pages = [] as Array<any>
-let addPages = [] as Array<any>
+const addPages = [] as Array<any>
 
 
-export async function loadDynamicPages(newLocale:String){
+export async function loadDynamicPages(newLocale:string){
   locale = newLocale
   const response = await axios.get('https://strapi.kornblum.one/api/pages?locale='+locale, {
     headers: {
-      Authorization: "Bearer 28f1084766b4010f8a295faf9fdbf83bc35b48fd0c678c09468e503a1ac474b49b03c5c8d2fbb98e1876427ace5f9d58180e3c79afa6d172c97738056e28c7adecff2bb9dfdac40fe6716c743a437b70dbaa8924262b3fa5d5b50258fcf6a163ada089cc5c76b34b3bcd4ec148594b3db5f12888c8bca941898b8ae542d923e5",
+      Authorization: "Bearer c1f8dac9ec1b803aa0902dced56958c91115acbbc216832757f95457d25bde1682863bb6144d574297560f3139f0e8610d05509a4d37ec19b96d0366f4b3ccdd246c97cdff0d877eb12ec3272b58d3203fd050267c5d089b68b9e8198534d74ded49564a6a5bd64e3825b617b0f0a6fe07fdada4ae941f15b6b144abdc89d804",
     },
   })
   pages = response.data.data
-  for (let page of addPages){
+  for (const page of addPages){
     router.removeRoute(page.Title)
   }
-  for (let page of pages){
+  for (const page of pages){
     addPages.push(page)
     router.addRoute({path: page.path, name: page.Title, sensitive: false, component: PageView})
-  
+
   }
-  
-   let pageStore = await usePageStore()
+
+   const pageStore = await usePageStore()
    pageStore.pages = pages
 }
 
@@ -42,7 +42,7 @@ const router = createRouter({
 })
 
 router.beforeResolve( o => {
-    let pageStore = usePageStore()
+    const pageStore = usePageStore()
     pageStore.pages = pages
 })
 

+ 18 - 14
src/stores/footer-content-pages.ts

@@ -4,28 +4,32 @@ import axios from 'axios'
 
 
 export const useFooterLinksStore = defineStore('footerLinks',{
-  state: () => ({ 
-                token: "28f1084766b4010f8a295faf9fdbf83bc35b48fd0c678c09468e503a1ac474b49b03c5c8d2fbb98e1876427ace5f9d58180e3c79afa6d172c97738056e28c7adecff2bb9dfdac40fe6716c743a437b70dbaa8924262b3fa5d5b50258fcf6a163ada089cc5c76b34b3bcd4ec148594b3db5f12888c8bca941898b8ae542d923e5",
-                locale:  "" as String,
-                links: [] 
+  state: () => ({
+                token: "c1f8dac9ec1b803aa0902dced56958c91115acbbc216832757f95457d25bde1682863bb6144d574297560f3139f0e8610d05509a4d37ec19b96d0366f4b3ccdd246c97cdff0d877eb12ec3272b58d3203fd050267c5d089b68b9e8198534d74ded49564a6a5bd64e3825b617b0f0a6fe07fdada4ae941f15b6b144abdc89d804",
+                locale:  (localStorage.getItem('lang') || 'de'),
+                links: []
               }),
-   
+
    actions: {
-    async getLinks(locale:String){
-       if (this.locale != locale){
-        this.locale = locale
-        await this.fetchLinks()
-       }
+    async getLinks(locale:string){
+      await this.setLocale(locale)
       return this.links
 
     },
-    setLocale(locale:String){
+    getLinkByLabel(oldLabel:string){
+      return this.links.find((link) => link.Label == oldLabel)
+
+    },
+
+    async setLocale(locale:string){
+      if (this.links.length == 0 || this.locale != locale){
         this.locale = locale
-        this.fetchLinks()
+        await this.fetchLinks()
+      }
     },
 
       async fetchLinks(){
-            const response = await axios.get('https://strapi.kornblum.one/api/footer-content-pages?populate=page&locale='+this.locale, {
+            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,
             },
@@ -33,4 +37,4 @@ export const useFooterLinksStore = defineStore('footerLinks',{
             this.links = response.data.data
         },
     }
- })
+ })

+ 4 - 4
src/stores/pages.ts

@@ -4,15 +4,15 @@ import { defineStore } from 'pinia'
 
 export const usePageStore = defineStore('pages',{
   state: () => ({ pages: [] as Array<any> }),
- 
+
    actions: {
     getPages(){
       return this.pages
 
     },
-    getPageByTitle (title: String) {
+    getPageByTitle (title: string) {
       return this.pages.find((page) => page.Title === title)
     },
-    
+
    }
- })
+ })

+ 34 - 0
src/stores/timeline.ts

@@ -0,0 +1,34 @@
+import { defineStore } from 'pinia'
+import axios from 'axios'
+
+
+export const useTimelineStore = defineStore('timelines',{
+  state: () => ({
+    token : "c1f8dac9ec1b803aa0902dced56958c91115acbbc216832757f95457d25bde1682863bb6144d574297560f3139f0e8610d05509a4d37ec19b96d0366f4b3ccdd246c97cdff0d877eb12ec3272b58d3203fd050267c5d089b68b9e8198534d74ded49564a6a5bd64e3825b617b0f0a6fe07fdada4ae941f15b6b144abdc89d804",
+    timelines: [] as Array<any>,
+    locale: (localStorage.getItem('lang') || 'de')
+  }),
+  actions: {
+    async getTimelines(locale: string){
+      await this.setLocale(locale)
+      return this.timelines
+
+    },
+
+    async setLocale(locale: string){
+      if(this.timelines.length == 0 || this.locale != locale ){
+        this.locale = locale
+        await this.fetchTimelines()
+      }
+    },
+
+    async fetchTimelines(){
+      const response = await axios.get('https://strapi.kornblum.one/api/timelines?locale='+this.locale, {
+      headers: {
+          Authorization: "Bearer "+this.token,
+      },
+      })
+      this.timelines = response.data.data
+    },
+  }
+})