This commit is contained in:
2026-05-15 16:45:56 +02:00
parent 921c861311
commit 04671637d2
8 changed files with 70 additions and 25 deletions
+1
View File
@@ -356,6 +356,7 @@ export interface TrackingResponse {
export interface ProductPrice {
quantity: number;
price: number;
active_price?: boolean;
}
export interface Product {
id: number;
+3 -2
View File
@@ -48,7 +48,8 @@ export default function ProductCard({ product, onPress, categoryColor }: Product
const { addToCart } = useCart();
const catColor = categoryColor ?? colors.accent;
const isSoldOut = product.stock <= 0;
const firstPrice = product.prices?.[0]?.price ?? null;
const activePrices = product.prices?.filter((p) => p.active_price !== false) ?? [];
const firstPrice = activePrices[0]?.price ?? null;
const imageMedia = product.media?.find((m) => m.type === "image");
const videoMedia = product.media?.find((m) => m.type === "video");
@@ -267,7 +268,7 @@ export default function ProductCard({ product, onPress, categoryColor }: Product
style={styles.pickerScroll}
showsVerticalScrollIndicator={false}
>
{product.prices?.map((p) => (
{activePrices.map((p) => (
<TouchableOpacity
key={p.quantity}
style={[
@@ -56,10 +56,13 @@ export default function ProductDetailScreen() {
const fixedProduct = {
...p,
prices:
p.prices?.map((pr: any) => ({
quantity: parseFloat(String(pr.quantity)),
price: parseFloat(String(pr.price)),
})) || [],
p.prices
?.filter((pr: any) => pr.active_price !== false)
.map((pr: any) => ({
quantity: parseFloat(String(pr.quantity)),
price: parseFloat(String(pr.price)),
active_price: pr.active_price,
})) || [],
};
setProduct(fixedProduct);
if (fixedProduct.prices.length > 0) {