-
-
-
Translate from Polish to
-
-
-
-
- Select language
-
-
- {{availableLangs.find(x => x.id === modelValue)?.flag}}
-
- {{availableLangs.find(x => x.id === modelValue)?.name}}
-
-
-
-
-
-
- {{ item.flag }}
- {{ item.name }}
-
-
-
-
-
-
-
{
- fetchForLanguage(toLangId)
- isShowProductView = true
- }" color="primary" v-if="isTranslations === false"
- class="text-white bg-(--accent-blue-light) dark:bg-(--accent-blue-dark) px-12!">
- Show product
-
-
- Translate
-
-
- {
- toLangId = settingStore.shopDefaultLanguage
- isTranslations = false
- }" color="primary" class="text-white bg-(--accent-blue-light) dark:bg-(--accent-blue-dark) px-12!">
- Cancel
-
-
- Save
-
-
-
+ class="flex items-end justify-between gap-4 mb-6 bg-(--second-light) dark:bg-(--main-dark) border border-(--border-light) dark:border-(--border-dark) p-4 rounded-md">
+
+
Translate from Polish to
+
+
+ {{ modelValue }}
+
+
+
+ {{ item.flag }}
+ {{ item.name }}
+
+
+
langs.filter(item => item.id !== settingStore.shopDefaultLanguage))
const productID = ref(0)
@@ -232,8 +194,8 @@ const translateToSelectedLanguage = async () => {
}
}
-const fetchForLanguage = async (langId: number) => {
- if (langId && productID.value) {
+const fetchForLanguage = async (langId: number | null) => {
+ if (productID.value) {
await productStore.getProductDescription(langId, productID.value)
}
}
diff --git a/bo/src/stores/product.ts b/bo/src/stores/product.ts
index 2283b4b..a400bd2 100644
--- a/bo/src/stores/product.ts
+++ b/bo/src/stores/product.ts
@@ -29,15 +29,15 @@ export const useProductStore = defineStore('product', () => {
const error = ref(null)
const productDescription = ref()
- async function getProductDescription(langId: number, productID: number) {
+ async function getProductDescription(langId: number | null, productID: number) {
loading.value = true
error.value = null
try {
const response = await useFetchJson(
- `/api/v1/restricted/product-translation/get-product-description?productID=${productID}&productLangID=${langId}`
+ `/api/v1/restricted/product-translation/get-product-description?productID=${productID}&productLangID=${langId ? langId : settingStore.shopDefaultLanguage}`
)
productDescription.value = response.items
-
+
} catch (e: unknown) {
error.value = e instanceof Error ? e.message : 'Failed to load product description'
} finally {