chore: update
This commit is contained in:
@@ -2,8 +2,6 @@ import React from "react";
|
||||
import { TouchableOpacity, Text, StyleSheet } from "react-native";
|
||||
import { spacing, borderRadius, fontSize, fontWeight } from "../theme";
|
||||
import { useTheme } from "../context/ThemeContext";
|
||||
import { getCategoryColor } from "../utils/constants";
|
||||
|
||||
interface CategoryPillProps {
|
||||
label: string;
|
||||
active: boolean;
|
||||
@@ -18,7 +16,7 @@ export default function CategoryPill({
|
||||
color,
|
||||
}: CategoryPillProps) {
|
||||
const { colors } = useTheme();
|
||||
const catColor = color || getCategoryColor(label, colors);
|
||||
const catColor = color || colors.accent;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
onPress={onPress}
|
||||
|
||||
@@ -14,7 +14,6 @@ import { Ionicons } from "@expo/vector-icons";
|
||||
import { Video, ResizeMode } from "expo-av";
|
||||
import { spacing, borderRadius, fontSize, fontWeight } from "../theme";
|
||||
import { useTheme } from "../context/ThemeContext";
|
||||
import { getCategoryColor } from "../utils/constants";
|
||||
import { API_BASE_URL } from "../api/client";
|
||||
import { useCart } from "../context/CartContext";
|
||||
|
||||
@@ -38,7 +37,7 @@ interface ProductCardProps {
|
||||
export default function ProductCard({ product, onPress, categoryColor }: ProductCardProps) {
|
||||
const { colors } = useTheme();
|
||||
const { addToCart } = useCart();
|
||||
const catColor = categoryColor ?? getCategoryColor(product.category, colors);
|
||||
const catColor = categoryColor ?? colors.accent;
|
||||
const isSoldOut = product.stock <= 0;
|
||||
const firstPrice = product.prices?.[0]?.price ?? null;
|
||||
|
||||
|
||||
@@ -555,19 +555,6 @@ export default function CheckoutScreen() {
|
||||
<Text style={styles.confirmInfoText}>Livreur</Text>
|
||||
</View>
|
||||
)}
|
||||
{confirmationData?.queue_info && (
|
||||
<View style={styles.confirmInfo}>
|
||||
<Ionicons
|
||||
name="time-outline"
|
||||
size={16}
|
||||
color={colors.warning}
|
||||
/>
|
||||
<Text style={styles.confirmInfoText}>
|
||||
Position: {confirmationData.queue_info.position}{" "}
|
||||
- {confirmationData.queue_info.estimated_wait}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
<Button
|
||||
title="Voir mes commandes"
|
||||
onPress={handleConfirmClose}
|
||||
|
||||
@@ -14,7 +14,7 @@ import { useRoute, useNavigation } from "@react-navigation/native";
|
||||
import type { RouteProp } from "@react-navigation/native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { Video, ResizeMode } from "expo-av";
|
||||
import { getProductById } from "../../api/api";
|
||||
import { getProductById, getCategories } from "../../api/api";
|
||||
import { useCart } from "../../context/CartContext";
|
||||
import type { Product } from "../../api/api_types";
|
||||
import type { ClientStackParamList } from "../../navigation/types";
|
||||
@@ -22,7 +22,6 @@ import LoadingSpinner from "../../components/ui/LoadingSpinner";
|
||||
import Toast from "../../components/ui/Toast";
|
||||
import { useTheme } from "../../context/ThemeContext";
|
||||
import { spacing, borderRadius, fontSize, fontWeight } from "../../theme";
|
||||
import { getCategoryColor } from "../../utils/constants";
|
||||
import { API_BASE_URL } from "../../api/client";
|
||||
|
||||
type Route = RouteProp<ClientStackParamList, "ProductDetail">;
|
||||
@@ -43,11 +42,15 @@ export default function ProductDetailScreen() {
|
||||
const [showSuccess, setShowSuccess] = useState(false);
|
||||
const [showQuantityPicker, setShowQuantityPicker] = useState(false);
|
||||
const [showVideo, setShowVideo] = useState(false);
|
||||
const [catColor, setCatColor] = useState<string>("#7c3aed");
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const res = await getProductById(params.productId);
|
||||
const [res, categories] = await Promise.all([
|
||||
getProductById(params.productId),
|
||||
getCategories(),
|
||||
]);
|
||||
const p = res?.data || res?.product || res;
|
||||
if (p && p.id) {
|
||||
const fixedProduct = {
|
||||
@@ -63,6 +66,10 @@ export default function ProductDetailScreen() {
|
||||
setSelectedGrams(fixedProduct.prices[0].quantity);
|
||||
setSelectedPrice(fixedProduct.prices[0].price);
|
||||
}
|
||||
const matched = categories.find(
|
||||
(c) => c.name.toLowerCase() === (p.category || "").toLowerCase(),
|
||||
);
|
||||
if (matched?.color) setCatColor(matched.color);
|
||||
} else {
|
||||
setError("Produit introuvable");
|
||||
}
|
||||
@@ -231,7 +238,7 @@ export default function ProductDetailScreen() {
|
||||
borderWidth: 1,
|
||||
borderColor: overlayBorder,
|
||||
borderLeftWidth: 3,
|
||||
borderLeftColor: "#7c3aed",
|
||||
borderLeftColor: catColor,
|
||||
borderRadius: 12,
|
||||
padding: spacing.xl,
|
||||
},
|
||||
@@ -278,11 +285,11 @@ export default function ProductDetailScreen() {
|
||||
fontWeight: fontWeight.semibold,
|
||||
},
|
||||
addToCartBtn: {
|
||||
backgroundColor: "#7c3aed",
|
||||
backgroundColor: catColor,
|
||||
borderRadius: 12,
|
||||
paddingVertical: 18,
|
||||
alignItems: "center",
|
||||
shadowColor: "#7c3aed",
|
||||
shadowColor: catColor,
|
||||
shadowOffset: { width: 0, height: 0 },
|
||||
shadowOpacity: 0.4,
|
||||
shadowRadius: 30,
|
||||
@@ -318,7 +325,7 @@ export default function ProductDetailScreen() {
|
||||
borderWidth: 1,
|
||||
borderColor: overlayBorder,
|
||||
overflow: "hidden",
|
||||
shadowColor: "#7c3aed",
|
||||
shadowColor: catColor,
|
||||
shadowOffset: { width: 0, height: 0 },
|
||||
shadowOpacity: 0.15,
|
||||
shadowRadius: 30,
|
||||
@@ -326,7 +333,7 @@ export default function ProductDetailScreen() {
|
||||
},
|
||||
pickerAccentBar: {
|
||||
height: 3,
|
||||
backgroundColor: "#7c3aed",
|
||||
backgroundColor: catColor,
|
||||
marginHorizontal: -spacing.xl,
|
||||
marginBottom: spacing.l,
|
||||
},
|
||||
@@ -340,7 +347,7 @@ export default function ProductDetailScreen() {
|
||||
width: 36,
|
||||
height: 36,
|
||||
borderRadius: 18,
|
||||
backgroundColor: "rgba(124,58,237,0.15)",
|
||||
backgroundColor: catColor + "26",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
@@ -399,7 +406,7 @@ export default function ProductDetailScreen() {
|
||||
overflow: "hidden",
|
||||
borderWidth: 1,
|
||||
borderColor: overlayBorder,
|
||||
shadowColor: "#7c3aed",
|
||||
shadowColor: catColor,
|
||||
shadowOffset: { width: 0, height: 0 },
|
||||
shadowOpacity: 0.15,
|
||||
shadowRadius: 30,
|
||||
@@ -435,7 +442,7 @@ export default function ProductDetailScreen() {
|
||||
},
|
||||
videoPlayer: { width: "100%", height: 300 },
|
||||
}),
|
||||
[colors, isDark],
|
||||
[colors, isDark, catColor],
|
||||
);
|
||||
|
||||
if (loading) return <LoadingSpinner message="Chargement du produit..." />;
|
||||
@@ -458,7 +465,6 @@ export default function ProductDetailScreen() {
|
||||
|
||||
const isOutOfStock = product.stock === 0;
|
||||
const hasValidPrices = product.prices && product.prices.length > 0;
|
||||
const catColor = getCategoryColor(product.category, colors);
|
||||
const imageMedia = product.media?.find((m) => m.type === "image");
|
||||
const videoMedia = product.media?.find((m) => m.type === "video");
|
||||
const imageUri = imageMedia ? `${API_BASE_URL}${imageMedia.url}` : null;
|
||||
|
||||
@@ -34,13 +34,3 @@ export const getStatusColors = (colors: Colors): Record<string, string> => ({
|
||||
offline: colors.textMuted,
|
||||
});
|
||||
|
||||
export const getCategoryColor = (category: string, colors: Colors): string => {
|
||||
const map: Record<string, string> = {
|
||||
"weed&hash": colors.categoryWeedHash,
|
||||
tous: colors.categoryTous,
|
||||
"zipette&co": colors.categoryZipette,
|
||||
"gros&semi": colors.categoryGros,
|
||||
};
|
||||
const key = category?.toLowerCase().trim();
|
||||
return map[key] || colors.accent;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user