Whole site refactor. Added pinia stores and authentication capability.

This commit is contained in:
2024-06-27 09:24:47 +02:00
parent 93c015fcb7
commit 87c8579e9e
18 changed files with 717 additions and 258 deletions

View File

@@ -0,0 +1,27 @@
import { defineStore } from 'pinia'
import type { Category } from '@/main'
import { ref } from 'vue'
import { axiosInstance } from '@/main'
export const useCategoriesStore = defineStore('categories', () => {
const categories = ref<Array<Category>>([]);
async function fetchCategories() {
const response = await axiosInstance.get('/towary', {withCredentials: true});
categories.value = response.data;
if(categories.value != undefined) {
for (const category of categories.value) {
for (const product of category.Towary) {
product.Options = new Array(product.Twr_JM);
product.ChosenOption = product.Twr_JM;
if (product.Twr_JMZ != null) {
product.Options.push(product.Twr_JMZ);
}
}
}
}
}
return {categories, fetchCategories}
})