chore: update
This commit is contained in:
@@ -12,6 +12,7 @@ import ProductDetail from "./pages/User/ProductDetail";
|
||||
import Cart from "./pages/User/Cart";
|
||||
import Checkout from "./pages/User/Checkout";
|
||||
import OrderDetails from "./pages/User/OrderDetails";
|
||||
import Parrainage from "./pages/User/Parrainage";
|
||||
|
||||
// Pages Login
|
||||
import LoginClient from "./pages/LoginClient/Login";
|
||||
@@ -71,6 +72,10 @@ function App() {
|
||||
path="/user/commande/:orderId"
|
||||
element={<OrderDetails />}
|
||||
/>
|
||||
<Route
|
||||
path="/user/parrainage"
|
||||
element={<Parrainage />}
|
||||
/>
|
||||
</Routes>
|
||||
</CartProvider>
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// ✅ loginUser et registerUser retournent AuthResponse
|
||||
// ✅ sessionStorage (pas localStorage)
|
||||
|
||||
const API_URL = "https://uber-stup.club/api/v1";
|
||||
const BACKEND_URL = "https://uber-stup.club";
|
||||
const API_URL = "http://5.181.0.112/api/v1";
|
||||
const BACKEND_URL = "http://5.181.0.112";
|
||||
|
||||
export function getMediaUrl(url: string): string {
|
||||
if (!url) return "";
|
||||
@@ -683,7 +683,10 @@ export const createCheckout = async (checkoutData: CheckoutData) => {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify(checkoutData),
|
||||
body: JSON.stringify({
|
||||
...checkoutData,
|
||||
use_referral_balance: checkoutData.use_referral_balance ?? false,
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
@@ -783,6 +786,24 @@ export interface Product {
|
||||
media?: MediaItem[]; // ✅ CHANGÉ: string[] → MediaItem[]
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
id: number;
|
||||
name: string;
|
||||
color: string;
|
||||
is_coming_soon: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export const getCategories = async (): Promise<Category[]> => {
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/categories`);
|
||||
const data = await response.json();
|
||||
return data.categories || [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export const getAllProducts = async () => {
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/products`);
|
||||
@@ -968,8 +989,9 @@ export const getOrderETA = async (commandId: number): Promise<ETAResponse> => {
|
||||
success: true,
|
||||
command_id: data.id || commandId,
|
||||
eta_minutes: data.eta_minutes || 0,
|
||||
estimated_arrival: data.estimated_arrival || "N/A",
|
||||
estimated_arrival: data.estimated_arrival || "",
|
||||
status: data.status || "pending",
|
||||
eta_available: data.eta_available === true,
|
||||
livreur_distance: data.livreur_distance,
|
||||
message: "ETA récupéré",
|
||||
};
|
||||
@@ -1805,3 +1827,50 @@ export const markNotificationsRead = async (): Promise<{
|
||||
return { success: false };
|
||||
}
|
||||
};
|
||||
|
||||
export interface PublicSettings {
|
||||
penalties_enabled: boolean;
|
||||
show_amende_score: boolean;
|
||||
points_enabled: boolean;
|
||||
points_separated: boolean;
|
||||
referral_enabled: boolean;
|
||||
}
|
||||
|
||||
export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
const defaults: PublicSettings = { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: true };
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/app-settings`);
|
||||
if (!response.ok) return defaults;
|
||||
const data = await response.json();
|
||||
return {
|
||||
penalties_enabled: data.penalties_enabled ?? true,
|
||||
show_amende_score: data.show_amende_score ?? true,
|
||||
points_enabled: data.points_enabled ?? true,
|
||||
points_separated: data.points_separated ?? true,
|
||||
referral_enabled: data.referral_enabled ?? true,
|
||||
};
|
||||
} catch {
|
||||
return defaults;
|
||||
}
|
||||
};
|
||||
|
||||
export interface ReferralBalanceResponse {
|
||||
success: boolean;
|
||||
balance: number;
|
||||
referral_enabled?: boolean;
|
||||
}
|
||||
|
||||
export const getReferralBalance = async (): Promise<ReferralBalanceResponse> => {
|
||||
const token = getAuthToken();
|
||||
if (!token) return { success: false, balance: 0 };
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/referral/balance`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (!response.ok) return { success: false, balance: 0 };
|
||||
const data = await response.json();
|
||||
return { success: true, balance: data.balance ?? 0, referral_enabled: data.referral_enabled };
|
||||
} catch {
|
||||
return { success: false, balance: 0 };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -202,6 +202,7 @@ export interface CheckoutData {
|
||||
last_name?: string;
|
||||
phone?: string;
|
||||
payment_method?: string;
|
||||
use_referral_balance?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -598,6 +599,7 @@ export interface ETAResponse {
|
||||
eta_minutes: number;
|
||||
estimated_arrival: string;
|
||||
status: string;
|
||||
eta_available?: boolean;
|
||||
livreur_distance?: number;
|
||||
message?: string;
|
||||
[key: string]: any;
|
||||
@@ -731,6 +733,8 @@ export interface CheckoutCartResponse {
|
||||
message: string;
|
||||
command_id?: number;
|
||||
delivery_address?: string;
|
||||
referral_used?: number;
|
||||
referral_balance?: number;
|
||||
command?: {
|
||||
id: number;
|
||||
status: string;
|
||||
@@ -754,8 +758,9 @@ export interface ConfirmReceptionResponse {
|
||||
success: boolean;
|
||||
message: string;
|
||||
points_earned?: number;
|
||||
category?: string; // 'total', 'zipette&co', 'weed&hash', 'mixed'
|
||||
data?: {
|
||||
category?: string; // ✅ Catégorie de points ('zipette&co', 'weed&hash', etc.)
|
||||
category?: string;
|
||||
points_earned?: number;
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
faBars,
|
||||
faTimes,
|
||||
faBell,
|
||||
faGift,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { faTelegram } from "@fortawesome/free-brands-svg-icons";
|
||||
import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
|
||||
@@ -91,6 +92,7 @@ function Navbar() {
|
||||
{ id: "panier", label: "Mon Panier", icon: faShoppingCart, path: "/user/panier" },
|
||||
{ id: "suivi", label: "Suivi Livraison", icon: faTruck, path: "/user/suivi-livraison" },
|
||||
{ id: "historique", label: "Historique", icon: faClockRotateLeft, path: "/user/consultation-historique" },
|
||||
{ id: "parrainage", label: "Parrainage", icon: faGift, path: "/user/parrainage" },
|
||||
];
|
||||
|
||||
const toggleMenu = () => setIsMenuOpen((v) => !v);
|
||||
|
||||
@@ -14,6 +14,7 @@ interface ProductCardProps {
|
||||
prices?: Array<{ quantity: number; price: number }>;
|
||||
hasVideo?: boolean;
|
||||
videoUrl?: string; // ✨ Nouveau prop pour l'URL de la vidéo
|
||||
categoryColor?: string;
|
||||
}
|
||||
|
||||
function ProductCard({
|
||||
@@ -27,6 +28,7 @@ function ProductCard({
|
||||
prices,
|
||||
hasVideo = false,
|
||||
videoUrl,
|
||||
categoryColor,
|
||||
}: ProductCardProps) {
|
||||
const navigate = useNavigate();
|
||||
const { addToCart } = useCart();
|
||||
@@ -162,6 +164,11 @@ function ProductCard({
|
||||
className={`quick-add-btn ${isOutOfStock ? "disabled" : ""}`}
|
||||
onClick={handleQuickAddClick}
|
||||
disabled={isOutOfStock}
|
||||
style={
|
||||
categoryColor && !isOutOfStock
|
||||
? { background: categoryColor }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{isOutOfStock
|
||||
? "Rupture de stock"
|
||||
@@ -174,6 +181,11 @@ function ProductCard({
|
||||
value={selectedQuantity ?? ""}
|
||||
onChange={handleQuantitySelect}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
style={
|
||||
categoryColor
|
||||
? { borderColor: categoryColor }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<option value="">Choisir une quantité</option>
|
||||
{prices.map((priceOption) => (
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import ProductCard from "../../components/ProductCard";
|
||||
import Navbar from "../../components/Navbar";
|
||||
import { getAllProducts, getProductsByCategory, getMediaUrl } from "../../api/api";
|
||||
import type { Product } from "../../api/api";
|
||||
import { getAllProducts, getProductsByCategory, getMediaUrl, getCategories } from "../../api/api";
|
||||
import type { Product, Category } from "../../api/api";
|
||||
import "./UserAccueil.css";
|
||||
|
||||
function UserAccueil() {
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>("tous");
|
||||
const [categories, setCategories] = useState<Category[]>([]);
|
||||
const [products, setProducts] = useState<Product[]>([]);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const categories = [
|
||||
{ label: "Tous", value: "tous" },
|
||||
{ label: "Weed&Hash", value: "weed&hash" },
|
||||
{ label: "Zipette&Co", value: "zipette&co" },
|
||||
{ label: "Gros&Semi", value: "gros&semi" },
|
||||
];
|
||||
|
||||
const categoryTitles: Record<string, string> = {
|
||||
tous: "Tous les produits",
|
||||
"weed&hash": "Weed & Hash",
|
||||
"zipette&co": "Zipette & Co",
|
||||
"gros&semi": "Gros & Semi",
|
||||
};
|
||||
useEffect(() => {
|
||||
getCategories().then(setCategories);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const catObj = categories.find((c) => c.name === selectedCategory);
|
||||
if (catObj?.is_coming_soon) {
|
||||
setLoading(false);
|
||||
setProducts([]);
|
||||
return;
|
||||
}
|
||||
loadProducts();
|
||||
}, [selectedCategory]);
|
||||
}, [selectedCategory, categories]);
|
||||
|
||||
const loadProducts = async () => {
|
||||
setLoading(true);
|
||||
@@ -107,73 +104,95 @@ function UserAccueil() {
|
||||
return "https://via.placeholder.com/400x400/1a1a1a/ffffff?text=No+Image";
|
||||
};
|
||||
|
||||
const grosSemiStyle =
|
||||
selectedCategory === "gros&semi"
|
||||
? {
|
||||
backgroundImage: `url('/logo-gros-semi.png')`,
|
||||
backgroundRepeat: "no-repeat",
|
||||
backgroundPosition: "center center",
|
||||
backgroundSize: "contain",
|
||||
backgroundAttachment: "local",
|
||||
}
|
||||
: {};
|
||||
const selectedCategoryObj = categories.find((c) => c.name === selectedCategory);
|
||||
const isSelectedComingSoon = selectedCategoryObj?.is_coming_soon ?? false;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
<div className="user-page-container" style={grosSemiStyle}>
|
||||
<div className="user-page-container">
|
||||
<div className="category-filter">
|
||||
{categories.map((category) => (
|
||||
<button
|
||||
key={category.value}
|
||||
className={`category-button ${selectedCategory === category.value ? "active" : ""}`}
|
||||
data-category={category.value}
|
||||
onClick={() => handleCategoryChange(category.value)}
|
||||
>
|
||||
{category.label}
|
||||
</button>
|
||||
))}
|
||||
<button
|
||||
className={`category-button ${selectedCategory === "tous" ? "active" : ""}`}
|
||||
data-category="tous"
|
||||
onClick={() => handleCategoryChange("tous")}
|
||||
>
|
||||
Tous
|
||||
</button>
|
||||
{categories.map((category) => {
|
||||
const isActive = selectedCategory === category.name;
|
||||
const catColor = category.color || "#7c3aed";
|
||||
return (
|
||||
<button
|
||||
key={category.id}
|
||||
className={`category-button ${isActive ? "active" : ""}`}
|
||||
style={
|
||||
isActive
|
||||
? {
|
||||
backgroundColor: catColor,
|
||||
borderColor: catColor,
|
||||
color: "#ffffff",
|
||||
}
|
||||
: { borderColor: `${catColor}66` }
|
||||
}
|
||||
onClick={() => handleCategoryChange(category.name)}
|
||||
>
|
||||
{category.name}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="category-header">
|
||||
<h2 className="category-title">
|
||||
{categoryTitles[selectedCategory]}
|
||||
{selectedCategory === "tous" ? "Tous les produits" : selectedCategory}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
{loading && (
|
||||
<div className="loading-container">
|
||||
<p>Chargement des produits...</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!loading && !error && products.length > 0 && (
|
||||
<div className="products-grid">
|
||||
{products.map((product) => (
|
||||
<div
|
||||
key={product.id}
|
||||
data-category={product.category}
|
||||
>
|
||||
<ProductCard
|
||||
id={product.id}
|
||||
name={product.name}
|
||||
price={getProductPrice(product)}
|
||||
unit={product.unit || "g"}
|
||||
image={getProductImage(product)}
|
||||
stock={product.stock}
|
||||
category={product.category}
|
||||
prices={product.prices}
|
||||
hasVideo={hasProductVideo(product)}
|
||||
videoUrl={getProductVideoUrl(product)} // ✨ Nouveau prop
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{selectedCategory === "gros&semi" && (
|
||||
{isSelectedComingSoon ? (
|
||||
<div className="coming-soon-overlay">
|
||||
<span className="coming-soon-text">Prochainement</span>
|
||||
<p className="coming-soon-desc">
|
||||
Les produits de cette catégorie arrivent bientôt !
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{loading && (
|
||||
<div className="loading-container">
|
||||
<p>Chargement des produits...</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!loading && !error && products.length > 0 && (
|
||||
<div className="products-grid">
|
||||
{products.map((product) => (
|
||||
<div
|
||||
key={product.id}
|
||||
data-category={product.category}
|
||||
>
|
||||
<ProductCard
|
||||
id={product.id}
|
||||
name={product.name}
|
||||
price={getProductPrice(product)}
|
||||
unit={product.unit || "g"}
|
||||
image={getProductImage(product)}
|
||||
stock={product.stock}
|
||||
category={product.category}
|
||||
prices={product.prices}
|
||||
hasVideo={hasProductVideo(product)}
|
||||
videoUrl={getProductVideoUrl(product)}
|
||||
categoryColor={
|
||||
categories.find(
|
||||
(c) => c.name.toLowerCase() === product.category?.toLowerCase(),
|
||||
)?.color
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -890,4 +890,85 @@
|
||||
transform: none;
|
||||
box-shadow: 0 8px 24px rgba(91, 33, 182, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* ============================================
|
||||
TOGGLE PARRAINAGE
|
||||
============================================ */
|
||||
|
||||
.referral-toggle-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: rgba(139, 92, 246, 0.08);
|
||||
border: 1px solid rgba(139, 92, 246, 0.25);
|
||||
border-radius: 12px;
|
||||
padding: 1rem 1.25rem;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.referral-toggle-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.referral-toggle-icon {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.referral-toggle-label {
|
||||
color: #e5e7eb;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
margin: 0 0 0.2rem;
|
||||
}
|
||||
|
||||
.referral-toggle-balance {
|
||||
color: #8b5cf6;
|
||||
font-size: 0.82rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Switch toggle */
|
||||
.referral-switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 48px;
|
||||
height: 26px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.referral-switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.referral-switch-slider {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: #374151;
|
||||
border-radius: 26px;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.referral-switch-slider::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
left: 3px;
|
||||
bottom: 3px;
|
||||
background: #fff;
|
||||
border-radius: 50%;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.referral-switch input:checked + .referral-switch-slider {
|
||||
background: #8b5cf6;
|
||||
}
|
||||
|
||||
.referral-switch input:checked + .referral-switch-slider::before {
|
||||
transform: translateX(22px);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useCart } from '../../context/CartContext';
|
||||
import { createCheckout, clearCart, extractUsernameFromToken, isUserAuthenticated } from '../../api/api';
|
||||
import { createCheckout, clearCart, extractUsernameFromToken, isUserAuthenticated, getReferralBalance, getPublicSettings } from '../../api/api';
|
||||
import type { CheckoutData } from '../../api/api';
|
||||
import Navbar from '../../components/Navbar';
|
||||
import './Checkout.css';
|
||||
@@ -23,6 +23,7 @@ interface ConfirmationData {
|
||||
delivery_address: string;
|
||||
arrivalTime: string;
|
||||
total: number;
|
||||
referral_used?: number;
|
||||
clientInfo: {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
@@ -49,6 +50,11 @@ function Checkout() {
|
||||
|
||||
const total = cartTotal;
|
||||
|
||||
// Parrainage
|
||||
const [referralBalance, setReferralBalance] = useState(0);
|
||||
const [referralEnabled, setReferralEnabled] = useState(false);
|
||||
const [useReferral, setUseReferral] = useState(false);
|
||||
|
||||
// ✅ VÉRIFICATION INITIALE DE L'AUTHENTIFICATION
|
||||
useEffect(() => {
|
||||
const checkAuth = () => {
|
||||
@@ -73,6 +79,18 @@ function Checkout() {
|
||||
return () => clearInterval(authInterval);
|
||||
}, [navigate]);
|
||||
|
||||
// Charger solde parrainage si activé
|
||||
useEffect(() => {
|
||||
getPublicSettings().then((settings) => {
|
||||
if (settings.referral_enabled) {
|
||||
setReferralEnabled(true);
|
||||
getReferralBalance().then((res) => {
|
||||
if (res.success) setReferralBalance(res.balance);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* ✅ Récupérer le username du JWT
|
||||
*/
|
||||
@@ -156,7 +174,8 @@ function Checkout() {
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
phone,
|
||||
payment_method: 'especes'
|
||||
payment_method: 'especes',
|
||||
use_referral_balance: useReferral && referralBalance > 0,
|
||||
};
|
||||
|
||||
console.log('📤 Envoi checkout avec JWT username:', checkoutData);
|
||||
@@ -209,6 +228,7 @@ function Checkout() {
|
||||
delivery_address: delivery_address || address,
|
||||
arrivalTime,
|
||||
total: frontendTotal,
|
||||
referral_used: (response as any).referral_used,
|
||||
clientInfo: {
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
@@ -333,6 +353,28 @@ function Checkout() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Toggle parrainage */}
|
||||
{referralEnabled && referralBalance > 0 && (
|
||||
<div className="referral-toggle-box">
|
||||
<div className="referral-toggle-info">
|
||||
<span className="referral-toggle-icon">🎁</span>
|
||||
<div>
|
||||
<p className="referral-toggle-label">Solde parrainage</p>
|
||||
<p className="referral-toggle-balance">{referralBalance.toFixed(2)} € disponible</p>
|
||||
</div>
|
||||
</div>
|
||||
<label className="referral-switch">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={useReferral}
|
||||
onChange={(e) => setUseReferral(e.target.checked)}
|
||||
disabled={loading}
|
||||
/>
|
||||
<span className="referral-switch-slider" />
|
||||
</label>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="form-actions">
|
||||
<button
|
||||
type="button"
|
||||
@@ -408,6 +450,19 @@ function Checkout() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Parrainage utilisé */}
|
||||
{confirmationData.referral_used != null && confirmationData.referral_used > 0 && (
|
||||
<div className="confirmation-section">
|
||||
<div className="confirmation-section-title">
|
||||
<i className="fas fa-gift icon"></i>
|
||||
Parrainage appliqué
|
||||
</div>
|
||||
<div className="confirmation-detail">
|
||||
<strong>Crédit utilisé:</strong> -{confirmationData.referral_used.toFixed(2)} €
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Total */}
|
||||
<div className="confirmation-total">
|
||||
<div className="confirmation-total-label">
|
||||
|
||||
@@ -222,6 +222,29 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
PARRAINAGE STAT CARD
|
||||
============================================ */
|
||||
|
||||
.stat-card2.referral-stat:hover {
|
||||
border-color: #8b5cf6;
|
||||
box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
|
||||
}
|
||||
|
||||
.stat-icon.icon-referral {
|
||||
background: linear-gradient(135deg, #8b5cf6, #6d28d9);
|
||||
}
|
||||
|
||||
.referral-value-active {
|
||||
color: #8b5cf6 !important;
|
||||
}
|
||||
|
||||
.referral-link-hint {
|
||||
color: #6b7280;
|
||||
font-size: 0.8rem;
|
||||
margin: 0.25rem 0 0;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
LOADING
|
||||
============================================ */
|
||||
|
||||
@@ -8,24 +8,28 @@ import { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import Navbar from '../../components/Navbar';
|
||||
import './ConsultationHistorique.css';
|
||||
import {
|
||||
getMyCompletedOrders,
|
||||
import {
|
||||
getMyCompletedOrders,
|
||||
formatPrice,
|
||||
getOrderAge,
|
||||
getMyPenalties,
|
||||
isUserAuthenticated
|
||||
isUserAuthenticated,
|
||||
getPublicSettings,
|
||||
getReferralBalance,
|
||||
} from '../../api/api';
|
||||
import type { PublicSettings } from '../../api/api';
|
||||
import type { CompletedOrder, ClientStats, PenaltyInfo } from "../../api/api_types";
|
||||
import { Package, MapPin, User, TrendingUp } from 'lucide-react';
|
||||
|
||||
// ✅ Import Font Awesome
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import {
|
||||
import {
|
||||
faCannabis,
|
||||
faWind,
|
||||
faTrophy,
|
||||
faExclamationTriangle,
|
||||
faCheckCircle
|
||||
faCheckCircle,
|
||||
faGift,
|
||||
} from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
function ConsultationHistorique() {
|
||||
@@ -34,6 +38,8 @@ function ConsultationHistorique() {
|
||||
const [orders, setOrders] = useState<CompletedOrder[]>([]);
|
||||
const [clientStats, setClientStats] = useState<ClientStats | null>(null);
|
||||
const [penalties, setPenalties] = useState<PenaltyInfo | null>(null);
|
||||
const [appSettings, setAppSettings] = useState<PublicSettings>({ penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: true });
|
||||
const [referralBalance, setReferralBalance] = useState<number>(0);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [error, setError] = useState<string>('');
|
||||
|
||||
@@ -64,6 +70,12 @@ function ConsultationHistorique() {
|
||||
useEffect(() => {
|
||||
fetchHistory();
|
||||
fetchPenalties();
|
||||
getPublicSettings().then((s) => {
|
||||
setAppSettings(s);
|
||||
if (s.referral_enabled) {
|
||||
getReferralBalance().then((r) => { if (r.success) setReferralBalance(r.balance); });
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
const fetchHistory = async () => {
|
||||
@@ -177,49 +189,68 @@ function ConsultationHistorique() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ✅ Carte 2: Points Weed/Hash - ICÔNE CANNABIS */}
|
||||
<div className="stat-card2 points-weed">
|
||||
<div className="stat-icon icon-weed">
|
||||
<FontAwesomeIcon icon={faCannabis} size="lg" />
|
||||
</div>
|
||||
<div className="stat-content">
|
||||
<p className="stat-label">
|
||||
<FontAwesomeIcon icon={faCannabis} style={{ marginRight: '0.5rem' }} />
|
||||
Points Weed/Hash
|
||||
</p>
|
||||
<p className="stat-value">{clientStats.points || 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
{/* Cartes points - affichées uniquement si le système de points est activé */}
|
||||
{appSettings.points_enabled && (
|
||||
appSettings.points_separated ? (
|
||||
<>
|
||||
<div className="stat-card2 points-weed">
|
||||
<div className="stat-icon icon-weed">
|
||||
<FontAwesomeIcon icon={faCannabis} size="lg" />
|
||||
</div>
|
||||
<div className="stat-content">
|
||||
<p className="stat-label">
|
||||
<FontAwesomeIcon icon={faCannabis} style={{ marginRight: '0.5rem' }} />
|
||||
Points Weed/Hash
|
||||
</p>
|
||||
<p className="stat-value">{clientStats.points || 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ✅ Carte 3: Points Zipette - ICÔNE VENT */}
|
||||
<div className="stat-card2 points-zipette">
|
||||
<div className="stat-icon icon-zipette">
|
||||
<FontAwesomeIcon icon={faWind} size="lg" />
|
||||
</div>
|
||||
<div className="stat-content">
|
||||
<p className="stat-label">
|
||||
<FontAwesomeIcon icon={faWind} style={{ marginRight: '0.5rem' }} />
|
||||
Points Zipette
|
||||
</p>
|
||||
<p className="stat-value">{clientStats.points_zipette || 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="stat-card2 points-zipette">
|
||||
<div className="stat-icon icon-zipette">
|
||||
<FontAwesomeIcon icon={faWind} size="lg" />
|
||||
</div>
|
||||
<div className="stat-content">
|
||||
<p className="stat-label">
|
||||
<FontAwesomeIcon icon={faWind} style={{ marginRight: '0.5rem' }} />
|
||||
Points Zipette
|
||||
</p>
|
||||
<p className="stat-value">{clientStats.points_zipette || 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ✅ Carte 4: Total Points - ICÔNE TROPHÉE */}
|
||||
<div className="stat-card2 points-total">
|
||||
<div className="stat-icon icon-total">
|
||||
<FontAwesomeIcon icon={faTrophy} size="lg" />
|
||||
</div>
|
||||
<div className="stat-content">
|
||||
<p className="stat-label">
|
||||
<FontAwesomeIcon icon={faTrophy} style={{ marginRight: '0.5rem' }} />
|
||||
Total Points
|
||||
</p>
|
||||
<p className="stat-value">
|
||||
{(clientStats.points || 0) + (clientStats.points_zipette || 0)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{(clientStats.points || 0) > 0 && (clientStats.points_zipette || 0) > 0 && (
|
||||
<div className="stat-card2 points-total">
|
||||
<div className="stat-icon icon-total">
|
||||
<FontAwesomeIcon icon={faTrophy} size="lg" />
|
||||
</div>
|
||||
<div className="stat-content">
|
||||
<p className="stat-label">
|
||||
<FontAwesomeIcon icon={faTrophy} style={{ marginRight: '0.5rem' }} />
|
||||
Total Points
|
||||
</p>
|
||||
<p className="stat-value">
|
||||
{(clientStats.points || 0) + (clientStats.points_zipette || 0)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<div className="stat-card2 points-total">
|
||||
<div className="stat-icon icon-total">
|
||||
<FontAwesomeIcon icon={faTrophy} size="lg" />
|
||||
</div>
|
||||
<div className="stat-content">
|
||||
<p className="stat-label">
|
||||
<FontAwesomeIcon icon={faTrophy} style={{ marginRight: '0.5rem' }} />
|
||||
Points
|
||||
</p>
|
||||
<p className="stat-value">{clientStats.points || 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
|
||||
{/* Carte 5: Commandes Livrées */}
|
||||
<div className="stat-card2 completed-orders">
|
||||
@@ -232,8 +263,8 @@ function ConsultationHistorique() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ✅ Carte 6: Pénalités - ICÔNE AVERTISSEMENT */}
|
||||
{penalties && (
|
||||
{/* Carte pénalités - affichée uniquement si le score amendes est activé */}
|
||||
{appSettings.show_amende_score && penalties && (
|
||||
<div className={`stat-card2 penalty-stat ${penalties.total_penalty > 0 ? 'has-penalty' : ''}`}>
|
||||
<div
|
||||
className={`stat-icon ${
|
||||
@@ -267,6 +298,26 @@ function ConsultationHistorique() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Carte parrainage - affichée si le parrainage est activé */}
|
||||
{appSettings.referral_enabled && (
|
||||
<div
|
||||
className="stat-card2 referral-stat"
|
||||
onClick={() => navigate('/user/parrainage')}
|
||||
style={{ cursor: 'pointer' }}
|
||||
>
|
||||
<div className="stat-icon icon-referral">
|
||||
<FontAwesomeIcon icon={faGift} size="lg" />
|
||||
</div>
|
||||
<div className="stat-content">
|
||||
<p className="stat-label">Solde parrainage</p>
|
||||
<p className={`stat-value ${referralBalance > 0 ? 'referral-value-active' : ''}`}>
|
||||
{referralBalance.toFixed(2)} €
|
||||
</p>
|
||||
<p className="referral-link-hint">Voir le programme →</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
/* ============================================
|
||||
Parrainage.css - Programme de parrainage
|
||||
============================================ */
|
||||
|
||||
.parrainage-container {
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
padding: clamp(1rem, 3vw, 2rem);
|
||||
padding-top: calc(60px + clamp(1.5rem, 4vw, 2.5rem));
|
||||
max-width: 900px;
|
||||
margin: 0 auto;
|
||||
background: linear-gradient(to bottom, #0a0a0a, #1a1a1a);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
HERO
|
||||
============================================ */
|
||||
|
||||
.parrainage-hero {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.parrainage-hero-icon {
|
||||
font-size: 3.5rem;
|
||||
margin-bottom: 0.75rem;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.parrainage-title {
|
||||
color: #fff;
|
||||
font-size: clamp(1.8rem, 5vw, 2.4rem);
|
||||
font-weight: 700;
|
||||
margin: 0 0 0.5rem;
|
||||
background: linear-gradient(135deg, #8b5cf6, #a78bfa);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
.parrainage-subtitle {
|
||||
color: #9ca3af;
|
||||
font-size: clamp(0.95rem, 2.5vw, 1.1rem);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
SOLDE CARD
|
||||
============================================ */
|
||||
|
||||
.parrainage-balance-card {
|
||||
background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.05));
|
||||
border: 1px solid rgba(139, 92, 246, 0.3);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.balance-label {
|
||||
color: #9ca3af;
|
||||
font-size: 0.875rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.balance-amount {
|
||||
color: #6b7280;
|
||||
font-size: clamp(2.5rem, 7vw, 3.5rem);
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.balance-amount.has-balance {
|
||||
color: #8b5cf6;
|
||||
}
|
||||
|
||||
.balance-loading {
|
||||
color: #6b7280;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.balance-hint {
|
||||
color: #8b5cf6;
|
||||
font-size: 0.875rem;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
ÉTAPES
|
||||
============================================ */
|
||||
|
||||
.parrainage-section-title {
|
||||
color: #e5e7eb;
|
||||
font-size: 1.2rem;
|
||||
font-weight: 600;
|
||||
margin: 0 0 1.25rem;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
|
||||
.parrainage-steps {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.step-card {
|
||||
background: #111115;
|
||||
border: 1px solid rgba(255, 255, 255, 0.07);
|
||||
border-radius: 12px;
|
||||
padding: 1.25rem 1rem;
|
||||
text-align: center;
|
||||
transition: border-color 0.2s, transform 0.2s;
|
||||
}
|
||||
|
||||
.step-card:hover {
|
||||
border-color: rgba(139, 92, 246, 0.35);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.step-icon {
|
||||
font-size: 2rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.step-num {
|
||||
color: #8b5cf6;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
margin-bottom: 0.35rem;
|
||||
}
|
||||
|
||||
.step-title {
|
||||
color: #f4f4f5;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
|
||||
.step-desc {
|
||||
color: #9ca3af;
|
||||
font-size: 0.82rem;
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
WARNING ZONE MIN
|
||||
============================================ */
|
||||
|
||||
.parrainage-warning-card {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
background: rgba(245, 158, 11, 0.08);
|
||||
border: 1px solid rgba(245, 158, 11, 0.25);
|
||||
border-radius: 12px;
|
||||
padding: 1.25rem 1.5rem;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.warning-icon {
|
||||
font-size: 1.5rem;
|
||||
flex-shrink: 0;
|
||||
margin-top: 0.1rem;
|
||||
}
|
||||
|
||||
.warning-title {
|
||||
color: #f59e0b;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
margin: 0 0 0.4rem;
|
||||
}
|
||||
|
||||
.warning-text {
|
||||
color: #d1d5db;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.55;
|
||||
margin: 0 0 0.75rem;
|
||||
}
|
||||
|
||||
.warning-example {
|
||||
background: rgba(245, 158, 11, 0.1);
|
||||
border-radius: 8px;
|
||||
padding: 0.6rem 0.75rem;
|
||||
font-size: 0.85rem;
|
||||
color: #e5e7eb;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.example-label {
|
||||
color: #f59e0b;
|
||||
font-weight: 600;
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
CTA TELEGRAM
|
||||
============================================ */
|
||||
|
||||
.parrainage-cta {
|
||||
text-align: center;
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
||||
.cta-text {
|
||||
color: #9ca3af;
|
||||
font-size: 0.9rem;
|
||||
margin: 0 0 1.25rem;
|
||||
}
|
||||
|
||||
.telegram-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
background: #229ed9;
|
||||
color: #fff;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
padding: 0.8rem 1.8rem;
|
||||
border-radius: 10px;
|
||||
text-decoration: none;
|
||||
transition: background 0.2s, transform 0.15s;
|
||||
}
|
||||
|
||||
.telegram-btn:hover {
|
||||
background: #1a8bc4;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.telegram-icon {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import Navbar from '../../components/Navbar';
|
||||
import { getReferralBalance, isUserAuthenticated } from '../../api/api';
|
||||
import './Parrainage.css';
|
||||
|
||||
const TELEGRAM_URL = 'https://t.me/';
|
||||
|
||||
const steps = [
|
||||
{
|
||||
num: 1,
|
||||
title: 'Parrainez un ami',
|
||||
desc: 'Recommandez nos services à un proche. Il doit nous contacter directement sur Telegram pour s\'inscrire.',
|
||||
icon: '👥',
|
||||
},
|
||||
{
|
||||
num: 2,
|
||||
title: 'Il passe sa 1ère commande',
|
||||
desc: 'Une fois votre ami inscrit et sa première commande validée, signalez-le nous sur Telegram.',
|
||||
icon: '✅',
|
||||
},
|
||||
{
|
||||
num: 3,
|
||||
title: 'Nous créditons votre compte',
|
||||
desc: 'L\'admin vérifie et crédite manuellement votre solde de parrainage. Vous êtes notifié dès que c\'est fait.',
|
||||
icon: '💰',
|
||||
},
|
||||
{
|
||||
num: 4,
|
||||
title: 'Utilisez votre solde',
|
||||
desc: 'Au moment du checkout, choisissez d\'utiliser votre solde ou de le cumuler pour une prochaine commande.',
|
||||
icon: '🛒',
|
||||
},
|
||||
];
|
||||
|
||||
export default function Parrainage() {
|
||||
const navigate = useNavigate();
|
||||
const [balance, setBalance] = useState<number>(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isUserAuthenticated()) {
|
||||
navigate('/login/client', { replace: true });
|
||||
return;
|
||||
}
|
||||
getReferralBalance().then((res) => {
|
||||
if (res.success) setBalance(res.balance);
|
||||
setLoading(false);
|
||||
});
|
||||
}, [navigate]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
<div className="parrainage-container">
|
||||
{/* En-tête */}
|
||||
<div className="parrainage-hero">
|
||||
<div className="parrainage-hero-icon">🎁</div>
|
||||
<h1 className="parrainage-title">Programme de Parrainage</h1>
|
||||
<p className="parrainage-subtitle">
|
||||
Parrainez vos amis et cumulez du crédit sur votre compte
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Solde actuel */}
|
||||
<div className="parrainage-balance-card">
|
||||
<div className="balance-label">Votre solde parrainage</div>
|
||||
{loading ? (
|
||||
<div className="balance-loading">Chargement...</div>
|
||||
) : (
|
||||
<div className={`balance-amount ${balance > 0 ? 'has-balance' : ''}`}>
|
||||
{balance.toFixed(2)} €
|
||||
</div>
|
||||
)}
|
||||
{balance > 0 && (
|
||||
<p className="balance-hint">
|
||||
Utilisable au prochain checkout ✓
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Étapes */}
|
||||
<div className="parrainage-steps-section">
|
||||
<h2 className="parrainage-section-title">Comment ça marche ?</h2>
|
||||
<div className="parrainage-steps">
|
||||
{steps.map((step) => (
|
||||
<div key={step.num} className="step-card">
|
||||
<div className="step-icon">{step.icon}</div>
|
||||
<div className="step-num">Étape {step.num}</div>
|
||||
<h3 className="step-title">{step.title}</h3>
|
||||
<p className="step-desc">{step.desc}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Règle zone minimum */}
|
||||
<div className="parrainage-warning-card">
|
||||
<div className="warning-icon">⚠️</div>
|
||||
<div className="warning-content">
|
||||
<h3 className="warning-title">Règle du minimum de zone</h3>
|
||||
<p className="warning-text">
|
||||
Même avec un solde parrainage, vous devez atteindre le minimum de
|
||||
commande de votre zone. Votre crédit couvre la différence mais ne
|
||||
remplace pas le minimum requis.
|
||||
</p>
|
||||
<div className="warning-example">
|
||||
<span className="example-label">Exemple :</span>
|
||||
<span>
|
||||
Solde <strong>50 €</strong> + Zone minimum <strong>50 €</strong>{' '}
|
||||
→ Commande totale minimum <strong>100 €</strong> (vous payez{' '}
|
||||
<strong>50 €</strong>)
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Bouton Telegram */}
|
||||
<div className="parrainage-cta">
|
||||
<p className="cta-text">
|
||||
Prêt à parrainer ? Contactez-nous sur Telegram pour enregistrer votre
|
||||
filleul.
|
||||
</p>
|
||||
<a
|
||||
href={TELEGRAM_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="telegram-btn"
|
||||
>
|
||||
<span className="telegram-icon">✈</span>
|
||||
Contacter sur Telegram
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -79,8 +79,8 @@
|
||||
}
|
||||
|
||||
.product-image-section:hover {
|
||||
border-color: rgba(124, 58, 237, 0.3);
|
||||
box-shadow: 0 12px 40px rgba(124, 58, 237, 0.15);
|
||||
border-color: rgba(var(--cat-color-rgb, 124, 58, 237), 0.3);
|
||||
box-shadow: 0 12px 40px rgba(var(--cat-color-rgb, 124, 58, 237), 0.15);
|
||||
}
|
||||
|
||||
.product-detail-image {
|
||||
@@ -177,7 +177,7 @@
|
||||
.product-description {
|
||||
background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-left: 3px solid #7c3aed;
|
||||
border-left: 3px solid var(--cat-color, #7c3aed);
|
||||
border-radius: 12px;
|
||||
padding: clamp(1.25rem, 3vw, 1.75rem);
|
||||
backdrop-filter: blur(8px);
|
||||
@@ -186,8 +186,8 @@
|
||||
}
|
||||
|
||||
.product-description:hover {
|
||||
border-color: rgba(124, 58, 237, 0.3);
|
||||
box-shadow: 0 6px 20px rgba(124, 58, 237, 0.15);
|
||||
border-color: rgba(var(--cat-color-rgb, 124, 58, 237), 0.3);
|
||||
box-shadow: 0 6px 20px rgba(var(--cat-color-rgb, 124, 58, 237), 0.15);
|
||||
}
|
||||
|
||||
.product-description h3 {
|
||||
@@ -258,14 +258,14 @@
|
||||
|
||||
.grams-dropdown:hover {
|
||||
background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
|
||||
border-color: rgba(124, 58, 237, 0.5);
|
||||
box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
|
||||
border-color: rgba(var(--cat-color-rgb, 124, 58, 237), 0.5);
|
||||
box-shadow: 0 4px 12px rgba(var(--cat-color-rgb, 124, 58, 237), 0.2);
|
||||
}
|
||||
|
||||
.grams-dropdown:focus {
|
||||
outline: none;
|
||||
border-color: #7c3aed;
|
||||
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
|
||||
border-color: var(--cat-color, #7c3aed);
|
||||
box-shadow: 0 0 0 3px rgba(var(--cat-color-rgb, 124, 58, 237), 0.2);
|
||||
}
|
||||
|
||||
.grams-dropdown:disabled {
|
||||
@@ -289,8 +289,8 @@
|
||||
}
|
||||
|
||||
.grams-dropdown option:checked {
|
||||
background-color: #7c3aed;
|
||||
background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
|
||||
background-color: var(--cat-color, #7c3aed);
|
||||
background: var(--cat-color, #7c3aed);
|
||||
color: white;
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@
|
||||
/* Add to Cart Button */
|
||||
.add-to-cart-button {
|
||||
width: 100%;
|
||||
background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
|
||||
background: var(--cat-color, #7c3aed);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
@@ -356,7 +356,7 @@
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1.5px;
|
||||
box-shadow: 0 0 30px rgba(124, 58, 237, 0.4);
|
||||
box-shadow: 0 0 30px rgba(var(--cat-color-rgb, 124, 58, 237), 0.4);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -378,7 +378,7 @@
|
||||
|
||||
.add-to-cart-button:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 12px 40px rgba(124, 58, 237, 0.5);
|
||||
box-shadow: 0 12px 40px rgba(var(--cat-color-rgb, 124, 58, 237), 0.5);
|
||||
}
|
||||
|
||||
.add-to-cart-button:active {
|
||||
@@ -514,7 +514,7 @@
|
||||
@media (hover: none) {
|
||||
.add-to-cart-button:hover {
|
||||
transform: none;
|
||||
box-shadow: 0 0 30px rgba(124, 58, 237, 0.4);
|
||||
box-shadow: 0 0 30px rgba(var(--cat-color-rgb, 124, 58, 237), 0.4);
|
||||
}
|
||||
|
||||
.add-to-cart-button:hover::before {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useState, useEffect } from "react";
|
||||
import { getProductById, isUserAuthenticated } from "../../api/api";
|
||||
import { getProductById, getCategories, isUserAuthenticated } from "../../api/api";
|
||||
import type { Product } from "../../api/api";
|
||||
import { useCart } from "../../context/CartContext";
|
||||
import Navbar from "../../components/Navbar";
|
||||
@@ -16,6 +16,8 @@ function ProductDetail() {
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const [catColor, setCatColor] = useState<string>("#7c3aed");
|
||||
|
||||
// floats
|
||||
const [selectedGrams, setSelectedGrams] = useState<number | null>(null);
|
||||
const [selectedPrice, setSelectedPrice] = useState<number>(0.0);
|
||||
@@ -75,7 +77,10 @@ function ProductDetail() {
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const response = await getProductById(productId);
|
||||
const [response, categories] = await Promise.all([
|
||||
getProductById(productId),
|
||||
getCategories(),
|
||||
]);
|
||||
|
||||
if (response.success && response.data) {
|
||||
const fixedProduct = {
|
||||
@@ -96,6 +101,12 @@ function ProductDetail() {
|
||||
setSelectedGrams(fixedProduct.prices[0].quantity);
|
||||
setSelectedPrice(fixedProduct.prices[0].price);
|
||||
}
|
||||
|
||||
// Couleur de la catégorie depuis la DB
|
||||
const matched = categories.find(
|
||||
(c) => c.name.toLowerCase() === (response.data.category || "").toLowerCase(),
|
||||
);
|
||||
if (matched?.color) setCatColor(matched.color);
|
||||
} else {
|
||||
setError(response.message || "Produit non trouvé");
|
||||
}
|
||||
@@ -188,6 +199,15 @@ function ProductDetail() {
|
||||
const isOutOfStock = product.stock === 0;
|
||||
const hasValidPrices = product.prices && product.prices.length > 0;
|
||||
|
||||
// Convertir la couleur hex en valeurs RGB pour les CSS rgba()
|
||||
const hexToRgb = (hex: string) => {
|
||||
const r = parseInt(hex.slice(1, 3), 16);
|
||||
const g = parseInt(hex.slice(3, 5), 16);
|
||||
const b = parseInt(hex.slice(5, 7), 16);
|
||||
return `${r}, ${g}, ${b}`;
|
||||
};
|
||||
const catColorRgb = hexToRgb(catColor);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
@@ -202,7 +222,10 @@ function ProductDetail() {
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="product-detail-container">
|
||||
<div
|
||||
className="product-detail-container"
|
||||
style={{ "--cat-color": catColor, "--cat-color-rgb": catColorRgb } as React.CSSProperties}
|
||||
>
|
||||
<button onClick={() => navigate(-1)} className="back-button">
|
||||
← Retour
|
||||
</button>
|
||||
|
||||
@@ -244,6 +244,38 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.eta-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
padding: 0.35rem 0.75rem;
|
||||
border-radius: 20px;
|
||||
background: linear-gradient(135deg, #065f46 0%, #059669 100%);
|
||||
color: #d1fae5;
|
||||
font-size: clamp(0.75rem, 2vw, 0.85em);
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
box-shadow: 0 2px 8px rgba(5, 150, 105, 0.4);
|
||||
animation: eta-pulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes eta-pulse {
|
||||
0%, 100% { box-shadow: 0 2px 8px rgba(5, 150, 105, 0.4); }
|
||||
50% { box-shadow: 0 2px 16px rgba(5, 150, 105, 0.7); }
|
||||
}
|
||||
|
||||
.eta-badge--preRoute {
|
||||
background: linear-gradient(135deg, #78350f 0%, #d97706 100%);
|
||||
color: #fef3c7;
|
||||
box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
|
||||
animation: eta-pulse-amber 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes eta-pulse-amber {
|
||||
0%, 100% { box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4); }
|
||||
50% { box-shadow: 0 2px 16px rgba(217, 119, 6, 0.7); }
|
||||
}
|
||||
|
||||
.order-header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -118,8 +118,6 @@ const getStatusColor = (status: string): string => {
|
||||
return 'linear-gradient(135deg, #ddd6fe 0%, #a78bfa 50%, #7c3aed 100%)';
|
||||
case 'assigned':
|
||||
return 'linear-gradient(135deg, #fef3c7 0%, #fbbf24 50%, #f59e0b 100%)';
|
||||
case 'support':
|
||||
return 'linear-gradient(135deg, #e9d5ff 0%, #c084fc 50%, #9333ea 100%)';
|
||||
case 'en_route':
|
||||
return 'linear-gradient(135deg, #bfdbfe 0%, #60a5fa 50%, #3b82f6 100%)';
|
||||
case 'arrived':
|
||||
@@ -139,7 +137,6 @@ const getStatusLabel = (status: string): string => {
|
||||
const statusMap: Record<string, string> = {
|
||||
'pending': 'En attente d\'assignation',
|
||||
'assigned': 'Livreur assigné',
|
||||
'support': 'Pris en charge par le livreur',
|
||||
'en_route': 'En route vers vous',
|
||||
'arrived': 'Livreur arrivé',
|
||||
'livre': 'Livré - À confirmer',
|
||||
@@ -154,7 +151,6 @@ const getStatusIcon = (status: string): any => {
|
||||
const iconMap: Record<string, any> = {
|
||||
'pending': faHourglassHalf,
|
||||
'assigned': faBiking,
|
||||
'support': faTruck,
|
||||
'en_route': faTruck,
|
||||
'arrived': faMapMarkerAlt,
|
||||
'livre': faBox,
|
||||
@@ -169,7 +165,6 @@ const getStatusProgress = (status: string): number => {
|
||||
const progressMap: Record<string, number> = {
|
||||
'pending': 0,
|
||||
'assigned': 10,
|
||||
'support': 25,
|
||||
'en_route': 50,
|
||||
'arrived': 80,
|
||||
'livre': 90,
|
||||
@@ -444,14 +439,15 @@ function SuiviLivraison() {
|
||||
|
||||
if (response.success) {
|
||||
const pointsEarned = response.points_earned || selectedOrderPoints;
|
||||
const responseData = (response as any).data || {};
|
||||
const apiCategory = responseData.category || '';
|
||||
|
||||
const apiCategory = response.category || (response as any).data?.category || '';
|
||||
|
||||
let displayCategory = selectedOrderCategoryDisplay;
|
||||
if (apiCategory.toLowerCase().includes('zipette')) {
|
||||
if (apiCategory === 'total') {
|
||||
displayCategory = '🏆 Total';
|
||||
} else if (apiCategory.toLowerCase().includes('zipette')) {
|
||||
displayCategory = '💨 Zipette&Co';
|
||||
} else if (apiCategory.toLowerCase().includes('weed') || apiCategory.toLowerCase().includes('hash')) {
|
||||
displayCategory = '🌿 Weeds&Hash';
|
||||
displayCategory = '🌿 Weed&Hash';
|
||||
}
|
||||
|
||||
showToast(
|
||||
@@ -604,12 +600,21 @@ function SuiviLivraison() {
|
||||
>
|
||||
<div className="order-header-left">
|
||||
<h3>Commande #{order.id}</h3>
|
||||
<div
|
||||
<div
|
||||
className="status-badge"
|
||||
style={{ backgroundImage: getStatusColor(order.status) }}
|
||||
>
|
||||
<FontAwesomeIcon icon={getStatusIcon(order.status)} /> {getStatusLabel(order.status)}
|
||||
</div>
|
||||
{order.eta?.eta_available && order.eta.eta_minutes > 0 && (
|
||||
<div className={`eta-badge${order.status?.toLowerCase() === 'assigned' ? ' eta-badge--preRoute' : ''}`}>
|
||||
<FontAwesomeIcon icon={faClock} />
|
||||
{order.status?.toLowerCase() === 'assigned'
|
||||
? ` Arrivée estimée ~${order.eta.eta_minutes} min`
|
||||
: ` ~${order.eta.eta_minutes} min`}
|
||||
{order.eta.estimated_arrival && ` (${order.eta.estimated_arrival})`}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="order-header-right">
|
||||
@@ -660,12 +665,20 @@ function SuiviLivraison() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{order.eta && (
|
||||
{order.eta?.eta_available && order.eta.eta_minutes > 0 && (
|
||||
<div className="detail-section">
|
||||
<h4><FontAwesomeIcon icon={faClock} /> Heure estimée d'arrivée</h4>
|
||||
<p>{order.eta.estimated_arrival || `${order.eta.eta_minutes} minutes`}</p>
|
||||
{order.eta.updated_at && (
|
||||
<small>Mise à jour: {new Date(order.eta.updated_at * 1000).toLocaleTimeString()}</small>
|
||||
<h4>
|
||||
<FontAwesomeIcon icon={faClock} />
|
||||
{order.status?.toLowerCase() === 'assigned'
|
||||
? ' Temps d\'arrivée estimé'
|
||||
: ' Heure estimée d\'arrivée'}
|
||||
</h4>
|
||||
<p>~{order.eta.eta_minutes} min{order.eta.estimated_arrival ? ` — arrivée vers ${order.eta.estimated_arrival}` : ''}</p>
|
||||
{order.status?.toLowerCase() === 'assigned' && (
|
||||
<small>Le livreur n'a pas encore démarré — estimation basée sur sa position actuelle</small>
|
||||
)}
|
||||
{order.eta.livreur_distance != null && (
|
||||
<small>Distance : {typeof order.eta.livreur_distance === 'number' ? order.eta.livreur_distance.toFixed(1) : order.eta.livreur_distance} km</small>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -19,21 +19,19 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* ===== COMING SOON OVERLAY (Gros&Semi) ===== */
|
||||
/* ===== COMING SOON OVERLAY ===== */
|
||||
.coming-soon-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: flex-end;
|
||||
padding-bottom: 12vh;
|
||||
pointer-events: none;
|
||||
z-index: 10;
|
||||
align-items: center;
|
||||
padding: 80px 24px;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.coming-soon-text {
|
||||
font-family: "Reach fill & Outline", sans-serif;
|
||||
font-size: clamp(1.5rem, 8vw, 0rem);
|
||||
font-size: clamp(1.5rem, 8vw, 4rem);
|
||||
font-weight: 400;
|
||||
color: #8e8fe8;
|
||||
letter-spacing: 4px;
|
||||
@@ -46,6 +44,13 @@
|
||||
animation: pulse-scale 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.coming-soon-desc {
|
||||
color: rgba(142, 143, 232, 0.7);
|
||||
font-size: 1rem;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@keyframes pulse-scale {
|
||||
0%,
|
||||
100% {
|
||||
@@ -95,31 +100,6 @@
|
||||
border-color: white;
|
||||
}
|
||||
|
||||
/* Effets néon par catégorie - BOUTONS */
|
||||
.category-button.active[data-category="tous"] {
|
||||
background-color: #9333ea;
|
||||
color: white;
|
||||
border-color: #9333ea;
|
||||
}
|
||||
|
||||
.category-button.active[data-category="weed&hash"] {
|
||||
background-color: #10b981;
|
||||
color: white;
|
||||
border-color: #10b981;
|
||||
}
|
||||
|
||||
.category-button.active[data-category="zipette&co"] {
|
||||
background-color: #f5f5f0;
|
||||
color: black;
|
||||
border-color: #f5f5f0;
|
||||
}
|
||||
|
||||
.category-button.active[data-category="gros&semi"] {
|
||||
background-color: #3dc2f7;
|
||||
color: white;
|
||||
border-color: #3dc2f7;
|
||||
}
|
||||
|
||||
/* ===== CATEGORY HEADER ===== */
|
||||
.category-header {
|
||||
margin-bottom: clamp(2rem, 5vw, 3rem);
|
||||
@@ -187,48 +167,6 @@
|
||||
scroll-snap-stop: always;
|
||||
}
|
||||
|
||||
/* Effets néon par catégorie - CONTAINERS DE PRODUITS */
|
||||
|
||||
/* Catégorie: tous - VIOLET - Effet néon amélioré */
|
||||
.products-grid > div[data-category="tous"] .product-card {
|
||||
border: 2px solid #9333ea;
|
||||
box-shadow:
|
||||
0 0 20px rgba(147, 51, 234, 0.6),
|
||||
0 0 40px rgba(147, 51, 234, 0.4),
|
||||
0 0 60px rgba(147, 51, 234, 0.2),
|
||||
0 0 80px rgba(147, 51, 234, 0.1);
|
||||
}
|
||||
|
||||
/* Catégorie: weed&hash - VERT - Effet néon amélioré */
|
||||
.products-grid > div[data-category="weed&hash"] .product-card {
|
||||
border: 2px solid #10b981;
|
||||
box-shadow:
|
||||
0 0 20px rgba(16, 185, 129, 0.6),
|
||||
0 0 40px rgba(16, 185, 129, 0.4),
|
||||
0 0 60px rgba(16, 185, 129, 0.2),
|
||||
0 0 80px rgba(16, 185, 129, 0.1);
|
||||
}
|
||||
|
||||
/* Catégorie: zipette&co - BLANC CASSÉ - Effet néon amélioré */
|
||||
.products-grid > div[data-category="zipette&co"] .product-card {
|
||||
border: 2px solid #f5f5f0;
|
||||
box-shadow:
|
||||
0 0 20px rgba(245, 245, 240, 0.6),
|
||||
0 0 40px rgba(245, 245, 240, 0.4),
|
||||
0 0 60px rgba(245, 245, 240, 0.2),
|
||||
0 0 80px rgba(245, 245, 240, 0.1);
|
||||
}
|
||||
|
||||
/* Catégorie: gros&semi - BLEU CIEL - Effet néon amélioré */
|
||||
.products-grid > div[data-category="gros&semi"] .product-card {
|
||||
border: 2px solid #3dc2f7;
|
||||
box-shadow:
|
||||
0 0 20px rgba(61, 194, 247, 0.6),
|
||||
0 0 40px rgba(61, 194, 247, 0.4),
|
||||
0 0 60px rgba(61, 194, 247, 0.2),
|
||||
0 0 80px rgba(61, 194, 247, 0.1);
|
||||
}
|
||||
|
||||
/* Petits téléphones */
|
||||
@media (max-width: 360px) {
|
||||
.products-grid {
|
||||
@@ -295,30 +233,6 @@
|
||||
color: black;
|
||||
}
|
||||
|
||||
.category-button.active[data-category="tous"]:hover {
|
||||
background-color: #9333ea;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.category-button.active[data-category="weed&hash"]:hover {
|
||||
background-color: #10b981;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.category-button.active[data-category="zipette&co"]:hover {
|
||||
background-color: #f5f5f0;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.category-button.active[data-category="gros&semi"]:hover {
|
||||
background-color: #3dc2f7;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.category-button.active[data-category="festif"]:hover {
|
||||
background-color: #9333ea;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-container,
|
||||
|
||||
Reference in New Issue
Block a user