refactor: update ProductCard, ProductGrid, and MarketPage components for improved product handling and internal state management
- Removed direct store dependency from ProductCard.vue, replacing it with event emission for adding products to the cart. - Enhanced ProductGrid.vue to manage product detail dialog internally, improving user interaction and state handling. - Streamlined MarketPage.vue by removing redundant product detail dialog logic, focusing on cleaner component structure. - Updated event handling for adding products to the cart with quantity support, enhancing flexibility in product management. These changes improve the modularity and maintainability of the market components, providing a better user experience when interacting with products.
This commit is contained in:
parent
3f47d2ff26
commit
56bcb8ec04
4 changed files with 53 additions and 68 deletions
|
|
@ -101,7 +101,6 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useMarketStore } from '@/modules/market/stores/market'
|
||||
import { Card, CardContent, CardFooter, CardTitle } from '@/components/ui/card'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
|
|
@ -114,16 +113,16 @@ interface Props {
|
|||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
// const emit = defineEmits<{
|
||||
// 'view-details': [product: Product]
|
||||
// 'view-stall': [stallId: string]
|
||||
// }>()
|
||||
const emit = defineEmits<{
|
||||
'add-to-cart': [product: Product]
|
||||
'view-details': [product: Product]
|
||||
'view-stall': [stallId: string]
|
||||
}>()
|
||||
|
||||
const marketStore = useMarketStore()
|
||||
const imageError = ref(false)
|
||||
|
||||
const addToCart = () => {
|
||||
marketStore.addToStallCart(props.product, 1)
|
||||
emit('add-to-cart', props.product)
|
||||
}
|
||||
|
||||
const handleImageError = () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue