fix: default lang

This commit is contained in:
2026-04-01 10:52:34 +02:00
parent 980fb1543b
commit b48a143b40
4 changed files with 54 additions and 91 deletions

View File

@@ -1,3 +1,4 @@
import { useSettingsStore } from '../stores/settings'
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { useFetchJson } from '@/composable/useFetchJson'
@@ -28,6 +29,9 @@ export const useProductStore = defineStore('product', () => {
const currentProduct = ref<Product | null>(null)
const loading = ref(false)
const error = ref<string | null>(null)
const settingsStore = useSettingsStore()
const defaultLangId = settingsStore.shopDefaultLanguage
async function getProductDescription(langId = 1, productID: number) {
loading.value = true
@@ -45,17 +49,6 @@ export const useProductStore = defineStore('product', () => {
}
}
async function getDefaultProductDescription(langId: number, productID: number) {
try {
const response = await useFetchJson<ProductDescription>(
`/api/v1/restricted/product-translation/get-product-description?productID=${productID}&productLangID=${langId}`
)
defaultProductDescription.value = response.items
} catch (e: unknown) {
console.error('Failed to load default product description:', e)
}
}
async function saveProductDescription(productID?: number, langId?: number, shopId = 1) {
const id = productID || 1
try {
@@ -83,7 +76,7 @@ export const useProductStore = defineStore('product', () => {
error.value = null
try {
const response = await useFetchJson<ProductDescription>(`/api/v1/restricted/product-description/translate-product-description?productID=${productID}&productShopID=1&productFromLangID=${fromLangId}&productToLangID=${toLangId}&model=OpenAI`)
const response = await useFetchJson<ProductDescription>(`/api/v1/restricted/product-description/translate-product-description?productID=${productID}&productShopID=1&productFromLangID=${fromLangId}&productToLangID=${defaultLangId}&model=OpenAI`)
productDescription.value = response.items
return response.items
} catch (e: any) {
@@ -104,8 +97,8 @@ export const useProductStore = defineStore('product', () => {
currentProduct,
loading,
error,
defaultLangId,
getProductDescription,
getDefaultProductDescription,
clearCurrentProduct,
saveProductDescription,
translateProductDescription,