test #10

Merged
yakovenko_valeriia merged 8 commits from test into main 2026-03-19 08:28:37 +00:00
2 changed files with 91 additions and 39 deletions
Showing only changes of commit 7388d0f828 - Show all commits

View File

@@ -1,14 +1,15 @@
<template> <template>
<div class="container my-10 "> <div class="container my-10 ">
<div 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"> <div
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">
<div class="flex items-end gap-3"> <div class="flex items-end gap-3">
<USelect v-model="selectedLanguage" :items="availableLangs" variant="outline" class="w-40!" <USelect v-model="selectedLanguage" :items="availableLangs" variant="outline" class="w-40!" valueKey="iso_code">
valueKey="iso_code">
<template #default="{ modelValue }"> <template #default="{ modelValue }">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<span class="text-md">{{ availableLangs.find(x => x.iso_code == modelValue)?.flag }}</span> <span class="text-md">{{availableLangs.find(x => x.iso_code == modelValue)?.flag}}</span>
<span class="font-medium dark:text-white text-black">{{ availableLangs.find(x => x.iso_code == modelValue)?.name }}</span> <span class="font-medium dark:text-white text-black">{{availableLangs.find(x => x.iso_code ==
modelValue)?.name}}</span>
</div> </div>
</template> </template>
<template #item-leading="{ item }"> <template #item-leading="{ item }">
@@ -19,7 +20,8 @@
</template> </template>
</USelect> </USelect>
</div> </div>
<UButton @click="translateToSelectedLanguage" color="primary" :loading="translating" class="text-white bg-(--accent-blue-light) dark:bg-(--accent-blue-dark) px-12!"> <UButton @click="translateToSelectedLanguage" color="primary" :loading="translating"
class="text-white bg-(--accent-blue-light) dark:bg-(--accent-blue-dark) px-12!">
Translate Translate
</UButton> </UButton>
</div> </div>
@@ -33,23 +35,24 @@
</div> </div>
<div class="flex items-start gap-30"> <div class="flex items-start gap-30">
<div class="flex flex-col gap-10"> <p class="p-80 bg-(--second-light)">img</p>
<p class="p-60 bg-yellow-300">img</p>
</div>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<p class="text-[25px] font-bold dark:text-white text-black">{{ productStore.productDescription.name }}</p> <p class="text-[25px] font-bold text-black dark:text-white">
<p v-html="productStore.productDescription.description_short" class="dark:text-white text-black"></p> {{ productStore.productDescription.name }}
</p>
<p v-html="productStore.productDescription.description_short" class="text-black dark:text-white"></p>
<div class="space-[10px]"> <div class="space-y-[10px]">
<div class="flex gap-1 items-center"> <div class="flex items-center gap-1">
<UIcon name="lets-icons:done-ring-round-fill" class="text-[20px] text-green-600" /> <UIcon name="lets-icons:done-ring-round-fill" class="text-[20px] text-green-600" />
<p class=" gap-1text-[16px] font-bold text-(--accent-blue-light) dark:text-(--accent-blue-dark)">{{ <p class="text-[16px] font-bold text-(--accent-blue-light) dark:text-(--accent-blue-dark)">
productStore.productDescription.available_now }}</p> {{ productStore.productDescription.available_now }}
</p>
</div> </div>
<div class="flex gap-1 items-center"> <div class="flex items-center gap-1">
<UIcon name="marketeq:car-shipping" class="text-[25px] text-green-600" /> <UIcon name="marketeq:car-shipping" class="text-[25px] text-green-600" />
<p class="text-[18px] font-bold dark:text-white text-black">{{ productStore.productDescription.delivery_in_stock }}</p> <p class="text-[18px] font-bold text-black dark:text-white">
{{ productStore.productDescription.delivery_in_stock }}
</p>
</div> </div>
</div> </div>
</div> </div>
@@ -70,30 +73,39 @@
</UButton> </UButton>
</div> </div>
<div v-if="activeTab === 'usage'" class="px-8 py-4 border border-(--border-light) dark:border-(--border-dark) rounded-md bg-(--second-light) dark:bg-(--main-dark)"> <div v-if="activeTab === 'usage'"
<div class="flex justify-end items-center gap-3 mb-4"> class="px-8 py-4 border border-(--border-light) dark:border-(--border-dark) rounded-md bg-(--second-light) dark:bg-(--main-dark)">
<UButton @click="usageEdit.enableEdit()" class="flex items-center gap-2 m-2 cursor-pointer bg-(--accent-blue-light)! dark:bg-(--accent-blue-dark)!">
<p class="text-white ">Change Text</p>
<UIcon name="material-symbols-light:stylus-note-sharp" class="text-[30px] text-white!" />
</UButton>
<UButton @click="save" color="neutral" variant="outline" class="p-2.5 cursor-pointer">
<p class="dark:text-white text-black ">Save the edited text</p>
</UButton>
</div>
<p ref="usageRef" v-html="productStore.productDescription.usage"
class="flex flex-col justify-center w-full text-start dark:text-white text-black">
</p>
</div>
<div v-if="activeTab === 'description'" class="px-8 py-4 border border-(--border-light) dark:border-(--border-dark) rounded-md bg-(--second-light) dark:bg-(--main-dark)"> <div class="flex justify-end items-center gap-3 mb-4">
<div class="flex items-center justify-end gap-3 mb-4"> <UButton v-if="!isEditing" @click="enableEdit"
<UButton @click="descriptionEdit.enableEdit()" class="flex items-center gap-2 m-2 cursor-pointer bg-(--accent-blue-light)! dark:bg-(--accent-blue-dark)!"> class="flex items-center gap-2 m-2 cursor-pointer bg-(--accent-blue-light)! dark:bg-(--accent-blue-dark)!">
<p class="text-white">Change Text</p> <p class="text-white">Change Text</p>
<UIcon name="material-symbols-light:stylus-note-sharp" class="text-[30px] text-white!" /> <UIcon name="material-symbols-light:stylus-note-sharp" class="text-[30px] text-white!" />
</UButton> </UButton>
<UButton @click="save" color="neutral" variant="outline" class="p-2.5 cursor-pointer"> <UButton v-if="isEditing" @click="saveText" color="neutral" variant="outline" class="p-2.5 cursor-pointer">
<p class="dark:text-white text-black">Save the edited text</p>
</UButton>
<UButton v-if="isEditing" @click="cancelEdit" color="neutral" variant="outline" class="p-2.5 cursor-pointer">
Cancel
</UButton>
</div>
<p ref="usageRef" v-html="productStore.productDescription.usage"
class="flex flex-col justify-center w-full text-start dark:text-white! text-black!"></p>
</div>
<div v-if="activeTab === 'description'"
class="px-8 py-4 border border-(--border-light) dark:border-(--border-dark) rounded-md bg-(--second-light) dark:bg-(--main-dark)">
<div class="flex items-center justify-end gap-3 mb-4">
<UButton v-if="!descriptionEdit.isEditing.value" @click="enableDescriptionEdit"
class="flex items-center gap-2 m-2 cursor-pointer bg-(--accent-blue-light)! dark:bg-(--accent-blue-dark)!">
<p class="text-white">Change Text</p>
<UIcon name="material-symbols-light:stylus-note-sharp" class="text-[30px] text-white!" />
</UButton>
<UButton v-if="descriptionEdit.isEditing.value" @click="saveDescription" color="neutral" variant="outline" class="p-2.5 cursor-pointer">
<p class="dark:text-white text-black ">Save the edited text</p> <p class="dark:text-white text-black ">Save the edited text</p>
</UButton> </UButton>
<UButton v-if="descriptionEdit.isEditing.value" @click="cancelDescriptionEdit" color="neutral" variant="outline" class="p-2.5 cursor-pointer">Cancel</UButton>
</div> </div>
<div ref="descriptionRef" v-html="productStore.productDescription.description" <div ref="descriptionRef" v-html="productStore.productDescription.description"
class="flex flex-col justify-center dark:text-white text-black"> class="flex flex-col justify-center dark:text-white text-black">
@@ -118,6 +130,8 @@ const translating = ref(false)
// return langs.filter((l: Language) => ['cs', 'pl', 'der'].includes(l.iso_code)) // return langs.filter((l: Language) => ['cs', 'pl', 'der'].includes(l.iso_code))
// }) // })
const isEditing = ref(false)
const availableLangs = computed(() => langs) const availableLangs = computed(() => langs)
const selectedLanguage = ref('pl') const selectedLanguage = ref('pl')
@@ -152,12 +166,50 @@ const usageRef = ref<HTMLElement | null>(null)
const descriptionEdit = useEditable(descriptionRef) const descriptionEdit = useEditable(descriptionRef)
const usageEdit = useEditable(usageRef) const usageEdit = useEditable(usageRef)
const save = async () => { const originalDescription = ref('')
const originalUsage = ref('')
const saveDescription = async () => {
descriptionEdit.disableEdit() descriptionEdit.disableEdit()
usageEdit.disableEdit()
await productStore.saveProductDescription() await productStore.saveProductDescription()
} }
const cancelDescriptionEdit = () => {
if (descriptionRef.value) {
descriptionRef.value.innerHTML = originalDescription.value
}
descriptionEdit.disableEdit()
}
const enableDescriptionEdit = () => {
if (descriptionRef.value) {
originalDescription.value = descriptionRef.value.innerHTML
}
descriptionEdit.enableEdit()
}
const enableEdit = () => {
if (usageRef.value) {
originalUsage.value = usageRef.value.innerHTML
}
isEditing.value = true
usageEdit.enableEdit()
}
const saveText = () => {
usageEdit.disableEdit()
isEditing.value = false
productStore.saveProductDescription()
}
const cancelEdit = () => {
if (usageRef.value) {
usageRef.value.innerHTML = originalUsage.value
}
usageEdit.disableEdit()
isEditing.value = false
}
</script> </script>
<style> <style>