chore: update

This commit is contained in:
2026-03-11 19:57:34 +01:00
parent f6b3948839
commit 375aa38454
62 changed files with 2714 additions and 1981 deletions
@@ -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>
)}