feat: add CartButton component for consistent cart access across views

- Introduced a new CartButton component to encapsulate cart summary functionality, improving code reusability and maintainability.
- Updated MarketPage.vue and StallView.vue to utilize the CartButton component, enhancing user navigation to the cart.
- Removed redundant cart summary code from both views, streamlining the component structure.

These changes provide a unified and consistent user experience for accessing the cart across different market views.
This commit is contained in:
padreug 2025-09-27 00:07:37 +02:00
parent 688bf5e105
commit da5c4d6de1
5 changed files with 515 additions and 24 deletions

View file

@ -130,14 +130,10 @@
@add-to-cart="handleAddToCart"
/>
<!-- Cart Summary -->
<div v-if="marketStore.totalCartItems > 0" class="fixed bottom-4 right-4">
<Button @click="viewCart" class="shadow-lg">
<ShoppingCart class="w-5 h-5 mr-2" />
Cart ({{ marketStore.totalCartItems }})
</Button>
</div>
</div>
<!-- Cart Summary -->
<CartButton />
</template>
<script setup lang="ts">
@ -154,9 +150,10 @@ import {
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
import { ArrowLeft, Store, X, ShoppingCart } from 'lucide-vue-next'
import { ArrowLeft, Store, X } from 'lucide-vue-next'
import FuzzySearch from '@/components/ui/fuzzy-search/FuzzySearch.vue'
import ProductGrid from '../components/ProductGrid.vue'
import CartButton from '../components/CartButton.vue'
import type { Product, Stall } from '../types/market'
import type { FuzzySearchOptions } from '@/composables/useFuzzySearch'
@ -280,10 +277,6 @@ const handleAddToCart = (product: Product, quantity?: number) => {
marketStore.addToStallCart(product, quantity || 1)
}
const viewCart = () => {
router.push('/cart')
}
const viewStall = (otherStallId: string) => {
if (otherStallId !== stallId.value) {