fix: add page Product list and fix page Cart

This commit is contained in:
2026-03-19 15:46:18 +01:00
parent 1ea50af96a
commit 99fe11fbeb
17 changed files with 168 additions and 97 deletions

View File

@@ -1,8 +1,8 @@
<template>
<div class="container mx-auto mt-10">
<div class="flex flex-col mb-6">
<div class="flex flex-col gap-5 mb-6">
<h1 class="text-2xl font-bold text-black dark:text-white">{{ t('Addresses') }}</h1>
<div class="flex justify-between items-center">
<div class="flex md:flex-row flex-col justify-between items-start md:items-center gap-5 md:gap-0">
<div class="flex gap-2 items-center">
<UInput v-model="searchQuery" type="text" :placeholder="t('Search address')"
class="bg-white dark:bg-gray-800 text-black dark:text-white absolute" />
@@ -16,7 +16,6 @@
</UButton>
</div>
</div>
<div v-if="paginatedAddresses.length" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
<div v-for="address in paginatedAddresses" :key="address.id"
class="border border-(--border-light) dark:border-(--border-dark) rounded-md p-4 bg-(--second-light) dark:bg-(--main-dark) hover:shadow-md transition-shadow">
@@ -35,11 +34,9 @@
</div>
</div>
<div v-else class="text-center py-8 text-gray-500 dark:text-gray-400">{{ t('No addresses found') }}</div>
<div class="mt-6 flex justify-center">
<UPagination v-model:page="page" :total="totalItems" :page-size="pageSize" />
</div>
<UModal v-model:open="showModal" :overlay="true" class="max-w-md mx-auto">
<template #content>
<div class="p-6 flex flex-col gap-6">
@@ -74,7 +71,6 @@
</div>
</template>
</UModal>
<UModal v-model:open="showDeleteConfirm" :overlay="true" class="max-w-md mx-auto">
<template #content>
<div class="p-6 flex flex-col gap-3">
@@ -106,7 +102,6 @@ import { useI18n } from 'vue-i18n'
const addressStore = useAddressStore()
const { t } = useI18n()
const searchQuery = ref('')
const showModal = ref(false)
const isEditing = ref(false)
@@ -122,17 +117,14 @@ const totalItems = computed(() => addressStore.totalItems)
const pageSize = addressStore.pageSize
watch(page, (newPage) => addressStore.setPage(newPage))
watch(searchQuery, (val) => {
addressStore.setSearchQuery(val)
})
function openCreateModal() {
resetForm()
isEditing.value = false
showModal.value = true
}
function openEditModal(address: any) {
formData.value = {
street: address.street,
@@ -144,17 +136,14 @@ function openEditModal(address: any) {
editingAddressId.value = address.id
showModal.value = true
}
function resetForm() {
formData.value = { street: '', zipCode: '', city: '', country: '' }
editingAddressId.value = null
}
function closeModal() {
showModal.value = false
resetForm()
}
function validate() {
const errors = []
if (!formData.value.street) errors.push({ name: 'street', message: 'Street required' })
@@ -163,7 +152,6 @@ function validate() {
if (!formData.value.country) errors.push({ name: 'country', message: 'Country required' })
return errors.length ? errors : null
}
function saveAddress() {
if (validate()) return
if (isEditing.value && editingAddressId.value) {
@@ -173,12 +161,18 @@ function saveAddress() {
}
closeModal()
}
// const Lera = ref('')
// function run (){
// if(Lera.value==='lera'){
// console.log('Leraa okokok')
// }else{
// console.log('LEra nonono')
// }
// }
function confirmDelete(id: number) {
addressToDelete.value = id
showDeleteConfirm.value = true
}
function deleteAddress() {
if (addressToDelete.value) {
addressStore.deleteAddress(addressToDelete.value)