chore: build
This commit is contained in:
@@ -443,59 +443,106 @@ body {
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
Notification panel
|
||||
Notification bottom-sheet modal
|
||||
============================================================ */
|
||||
.notif-panel {
|
||||
position: absolute;
|
||||
top: calc(var(--topbar-h) - 4px);
|
||||
right: 0;
|
||||
width: 300px;
|
||||
max-height: 380px;
|
||||
.notif-modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1100;
|
||||
background: rgba(0, 0, 0, 0.55);
|
||||
backdrop-filter: blur(3px);
|
||||
-webkit-backdrop-filter: blur(3px);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
animation: fadeIn 0.18s ease;
|
||||
}
|
||||
|
||||
.notif-modal {
|
||||
width: 100%;
|
||||
max-width: 640px;
|
||||
height: 70vh;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
|
||||
border-top-left-radius: 20px;
|
||||
border-top-right-radius: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
animation: slideDown 0.18s ease;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
|
||||
animation: slideUp 0.26s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
@keyframes slideDown {
|
||||
from { opacity: 0; transform: translateY(-6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
@keyframes slideUp {
|
||||
from { transform: translateY(100%); }
|
||||
to { transform: translateY(0); }
|
||||
}
|
||||
|
||||
.notif-panel-header {
|
||||
padding: 0.7rem 1rem;
|
||||
.notif-modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 1.1rem 1.25rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
color: var(--text);
|
||||
font-weight: 600;
|
||||
font-size: 0.85rem;
|
||||
letter-spacing: 0.02em;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.notif-modal-title {
|
||||
color: var(--text);
|
||||
font-size: 1.05rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.notif-modal-close {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
}
|
||||
|
||||
.notif-modal-close:hover {
|
||||
background: var(--surface-2);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.notif-modal-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border) transparent;
|
||||
}
|
||||
|
||||
.notif-modal-body::-webkit-scrollbar { width: 4px; }
|
||||
.notif-modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
|
||||
|
||||
.notif-empty {
|
||||
padding: 1.5rem;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 3rem 1.5rem;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.85rem;
|
||||
font-size: 0.9rem;
|
||||
gap: 0.5rem;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.notif-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow-y: auto;
|
||||
max-height: 320px;
|
||||
}
|
||||
.notif-empty p { margin: 0; }
|
||||
|
||||
.notif-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2rem;
|
||||
padding: 0.7rem 1rem;
|
||||
gap: 0.3rem;
|
||||
padding: 0.9rem 1.25rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
border-left: 3px solid transparent;
|
||||
transition: background var(--transition);
|
||||
}
|
||||
|
||||
@@ -503,20 +550,22 @@ body {
|
||||
|
||||
.notif-unread {
|
||||
background: var(--primary-soft);
|
||||
border-left: 3px solid var(--primary);
|
||||
border-left-color: var(--primary);
|
||||
}
|
||||
|
||||
.notif-read { opacity: 0.55; }
|
||||
.notif-read {
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.notif-message {
|
||||
color: var(--text);
|
||||
font-size: 0.83rem;
|
||||
line-height: 1.45;
|
||||
font-size: 0.88rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.notif-time {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.72rem;
|
||||
font-size: 0.74rem;
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
|
||||
@@ -31,6 +31,22 @@ interface MenuItem {
|
||||
path: string;
|
||||
}
|
||||
|
||||
function formatNotifDate(dateStr: string): string {
|
||||
try {
|
||||
const diffMs = Date.now() - new Date(dateStr).getTime();
|
||||
const diffMin = Math.floor(diffMs / 60000);
|
||||
if (diffMin < 1) return "À l'instant";
|
||||
if (diffMin < 60) return `Il y a ${diffMin} min`;
|
||||
const diffH = Math.floor(diffMin / 60);
|
||||
if (diffH < 24) return `Il y a ${diffH}h`;
|
||||
const diffD = Math.floor(diffH / 24);
|
||||
if (diffD === 1) return "Hier";
|
||||
return `Il y a ${diffD} jours`;
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function Navbar() {
|
||||
const { theme, toggleTheme } = useTheme();
|
||||
const [isMenuOpen, setIsMenuOpen] = useState<boolean>(false);
|
||||
@@ -39,9 +55,9 @@ function Navbar() {
|
||||
const [unreadCount, setUnreadCount] = useState(0);
|
||||
const [showNotifPanel, setShowNotifPanel] = useState(false);
|
||||
const [referralEnabled, setReferralEnabled] = useState(true);
|
||||
const [shopName, setShopName] = useState("Milieu-Nantais");
|
||||
const seenKeysRef = useRef<Set<string>>(new Set());
|
||||
const isFirstLoadRef = useRef(true);
|
||||
const notifPanelRef = useRef<HTMLDivElement>(null);
|
||||
const { cartCount } = useCart();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
@@ -74,28 +90,23 @@ function Navbar() {
|
||||
}, [fetchNotifications]);
|
||||
|
||||
useEffect(() => {
|
||||
getPublicSettings().then((s) => setReferralEnabled(s.referral_enabled));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (e: MouseEvent) => {
|
||||
if (notifPanelRef.current && !notifPanelRef.current.contains(e.target as Node)) {
|
||||
setShowNotifPanel(false);
|
||||
}
|
||||
};
|
||||
document.addEventListener("mousedown", handleClickOutside);
|
||||
return () => document.removeEventListener("mousedown", handleClickOutside);
|
||||
getPublicSettings().then((s) => {
|
||||
setReferralEnabled(s.referral_enabled);
|
||||
if (s.shop_name) setShopName(s.shop_name);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleNotifBellClick = async () => {
|
||||
setShowNotifPanel((prev) => !prev);
|
||||
if (!showNotifPanel && unreadCount > 0) {
|
||||
setShowNotifPanel(true);
|
||||
if (unreadCount > 0) {
|
||||
await markNotificationsRead();
|
||||
setUnreadCount(0);
|
||||
setNotifications((prev) => prev.map((n) => ({ ...n, read: true })));
|
||||
}
|
||||
};
|
||||
|
||||
const closeNotifPanel = () => setShowNotifPanel(false);
|
||||
|
||||
const menuItems: MenuItem[] = [
|
||||
{ id: "accueil", label: "Accueil", icon: faHome, path: "/user/accueil" },
|
||||
{ id: "produits", label: "Nos Produits", icon: faBox, path: "/user/nos-produits" },
|
||||
@@ -156,7 +167,7 @@ function Navbar() {
|
||||
<FontAwesomeIcon icon={isMenuOpen ? faTimes : faBars} />
|
||||
</button>
|
||||
|
||||
<span className="topbar-brand">Milieu‑Nantais</span>
|
||||
<span className="topbar-brand">{shopName}</span>
|
||||
|
||||
<div className="topbar-actions">
|
||||
{/* Theme toggle */}
|
||||
@@ -169,46 +180,18 @@ function Navbar() {
|
||||
</button>
|
||||
|
||||
{/* Notifications */}
|
||||
<div className="notif-wrapper" ref={notifPanelRef}>
|
||||
<button
|
||||
className="topbar-icon-btn"
|
||||
onClick={handleNotifBellClick}
|
||||
aria-label="Notifications"
|
||||
>
|
||||
<FontAwesomeIcon icon={faBell} />
|
||||
{unreadCount > 0 && (
|
||||
<span className="topbar-badge">
|
||||
{unreadCount > 99 ? "99+" : unreadCount}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{showNotifPanel && (
|
||||
<div className="notif-panel">
|
||||
<div className="notif-panel-header">Notifications</div>
|
||||
{notifications.length === 0 ? (
|
||||
<div className="notif-empty">Aucune notification</div>
|
||||
) : (
|
||||
<ul className="notif-list">
|
||||
{notifications.map((n, i) => (
|
||||
<li
|
||||
key={i}
|
||||
className={`notif-item ${n.read ? "notif-read" : "notif-unread"}`}
|
||||
>
|
||||
<span className="notif-message">{n.message}</span>
|
||||
<span className="notif-time">
|
||||
{new Date(n.created_at).toLocaleTimeString("fr-FR", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
})}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
className="topbar-icon-btn"
|
||||
onClick={handleNotifBellClick}
|
||||
aria-label="Notifications"
|
||||
>
|
||||
<FontAwesomeIcon icon={faBell} />
|
||||
{unreadCount > 0 && (
|
||||
<span className="topbar-badge">
|
||||
{unreadCount > 99 ? "99+" : unreadCount}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
|
||||
{/* Panier */}
|
||||
<button
|
||||
@@ -224,6 +207,38 @@ function Navbar() {
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* ── Notifications modal ─────────────────────── */}
|
||||
{showNotifPanel && (
|
||||
<div className="notif-modal-overlay" onClick={closeNotifPanel}>
|
||||
<div className="notif-modal" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="notif-modal-header">
|
||||
<span className="notif-modal-title">Notifications</span>
|
||||
<button className="notif-modal-close" onClick={closeNotifPanel} aria-label="Fermer">
|
||||
<FontAwesomeIcon icon={faTimes} />
|
||||
</button>
|
||||
</div>
|
||||
<div className="notif-modal-body">
|
||||
{notifications.length === 0 ? (
|
||||
<div className="notif-empty">
|
||||
<FontAwesomeIcon icon={faBell} style={{ fontSize: "2rem", marginBottom: "0.75rem", opacity: 0.3 }} />
|
||||
<p>Aucune notification</p>
|
||||
</div>
|
||||
) : (
|
||||
notifications.map((n, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className={`notif-item ${n.read ? "notif-read" : "notif-unread"}`}
|
||||
>
|
||||
<span className="notif-message">{n.message}</span>
|
||||
<span className="notif-time">{formatNotifDate(n.created_at)}</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Overlay ─────────────────────────────────── */}
|
||||
{isMenuOpen && <div className="sidebar-overlay" onClick={closeMenu} />}
|
||||
|
||||
@@ -235,7 +250,7 @@ function Navbar() {
|
||||
<FontAwesomeIcon icon={faShoppingCart} />
|
||||
</div>
|
||||
<div>
|
||||
<p className="sidebar-brand-name">Milieu-Nantais</p>
|
||||
<p className="sidebar-brand-name">{shopName}</p>
|
||||
<p className="sidebar-brand-sub">Mon espace</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
.product-card:hover {
|
||||
transform: scale(1.08);
|
||||
box-shadow: 0 8px 25px color-mix(in srgb, var(--category-color, white) 40%, transparent);
|
||||
box-shadow: 0 8px 25px
|
||||
color-mix(in srgb, var(--category-color, white) 40%, transparent);
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
@@ -62,6 +63,29 @@
|
||||
0 0 10px rgba(255, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.coming-soon-overlay {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%) rotate(-15deg);
|
||||
text-align: center;
|
||||
z-index: 5;
|
||||
pointer-events: none;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
color: rgba(34, 197, 94, 0.95);
|
||||
border: 6px solid rgba(34, 197, 94, 0.95);
|
||||
padding: clamp(0.5rem, 2vw, 0.8rem) clamp(1.5rem, 5vw, 2.5rem);
|
||||
font-size: clamp(1.1rem, 4.5vw, 1.8rem);
|
||||
font-weight: 900;
|
||||
letter-spacing: 3px;
|
||||
text-transform: uppercase;
|
||||
white-space: nowrap;
|
||||
box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
|
||||
text-shadow:
|
||||
2px 2px 6px rgba(0, 0, 0, 0.9),
|
||||
-2px -2px 6px rgba(0, 0, 0, 0.9);
|
||||
}
|
||||
|
||||
.product-card.out-of-stock {
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,13 @@ import "./ProductCard.css";
|
||||
|
||||
function getTextColor(hex: string): string {
|
||||
const h = hex.replace("#", "");
|
||||
const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
|
||||
const full =
|
||||
h.length === 3
|
||||
? h
|
||||
.split("")
|
||||
.map((c) => c + c)
|
||||
.join("")
|
||||
: h;
|
||||
const r = parseInt(full.slice(0, 2), 16);
|
||||
const g = parseInt(full.slice(2, 4), 16);
|
||||
const b = parseInt(full.slice(4, 6), 16);
|
||||
@@ -22,10 +28,11 @@ interface ProductCardProps {
|
||||
image: string;
|
||||
stock: number;
|
||||
category: string;
|
||||
prices?: Array<{ quantity: number; price: number }>;
|
||||
prices?: Array<{ quantity: number; price: number; active_price?: boolean }>;
|
||||
hasVideo?: boolean;
|
||||
videoUrl?: string; // ✨ Nouveau prop pour l'URL de la vidéo
|
||||
categoryColor?: string;
|
||||
coming_soon?: boolean;
|
||||
}
|
||||
|
||||
function ProductCard({
|
||||
@@ -40,6 +47,7 @@ function ProductCard({
|
||||
hasVideo = false,
|
||||
videoUrl,
|
||||
categoryColor,
|
||||
coming_soon,
|
||||
}: ProductCardProps) {
|
||||
const navigate = useNavigate();
|
||||
const { addToCart } = useCart();
|
||||
@@ -52,6 +60,7 @@ function ProductCard({
|
||||
const [showVideo, setShowVideo] = useState(false); // ✨ État pour afficher/masquer la vidéo
|
||||
|
||||
const isOutOfStock = stock === 0;
|
||||
const isComingSoon = coming_soon === true;
|
||||
const normalizedCategory = (category || "autre").toLowerCase().trim();
|
||||
|
||||
const handleDetailsClick = (e: React.MouseEvent) => {
|
||||
@@ -156,6 +165,9 @@ function ProductCard({
|
||||
{isOutOfStock && (
|
||||
<div className="sold-out-overlay">SOLD OUT</div>
|
||||
)}
|
||||
{isComingSoon && (
|
||||
<div className="coming-soon-overlay">COMMING SOON</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="product-info">
|
||||
@@ -177,18 +189,23 @@ function ProductCard({
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
className={`quick-add-btn ${isOutOfStock ? "disabled" : ""}`}
|
||||
className={`quick-add-btn ${isOutOfStock || isComingSoon ? "disabled" : ""}`}
|
||||
onClick={handleQuickAddClick}
|
||||
disabled={isOutOfStock}
|
||||
disabled={isOutOfStock || isComingSoon}
|
||||
style={
|
||||
categoryColor && !isOutOfStock
|
||||
? { background: categoryColor, color: getTextColor(categoryColor) }
|
||||
categoryColor && !isOutOfStock && !isComingSoon
|
||||
? {
|
||||
background: categoryColor,
|
||||
color: getTextColor(categoryColor),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{isOutOfStock
|
||||
? "Rupture de stock"
|
||||
: "Ajouter rapidement"}
|
||||
: isComingSoon
|
||||
? "BIENTÔT DISPONIBLE"
|
||||
: "Ajouter rapidement"}
|
||||
</button>
|
||||
|
||||
{showQuantitySelect && prices && prices.length > 0 && (
|
||||
@@ -209,8 +226,9 @@ function ProductCard({
|
||||
key={priceOption.quantity}
|
||||
value={priceOption.quantity}
|
||||
>
|
||||
{priceOption.quantity}{unit} -{" "}
|
||||
{priceOption.price.toFixed(2)} €
|
||||
{priceOption.quantity}
|
||||
{unit} - {priceOption.price.toFixed(2)}{" "}
|
||||
€
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -220,32 +238,34 @@ function ProductCard({
|
||||
</div>
|
||||
|
||||
{/* ✨ Modal vidéo — rendu via Portal pour éviter le clipping du transform:scale sur .product-card */}
|
||||
{showVideo && videoUrl && createPortal(
|
||||
<div className="video-modal" onClick={handleCloseVideo}>
|
||||
<div
|
||||
className="video-modal-content"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<button
|
||||
className="video-close-btn"
|
||||
onClick={handleCloseVideo}
|
||||
aria-label="Fermer la vidéo"
|
||||
{showVideo &&
|
||||
videoUrl &&
|
||||
createPortal(
|
||||
<div className="video-modal" onClick={handleCloseVideo}>
|
||||
<div
|
||||
className="video-modal-content"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<X size={18} />
|
||||
</button>
|
||||
<video
|
||||
src={videoUrl}
|
||||
controls
|
||||
autoPlay
|
||||
className="video-player"
|
||||
>
|
||||
Votre navigateur ne supporte pas la lecture de
|
||||
vidéos.
|
||||
</video>
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
)}
|
||||
<button
|
||||
className="video-close-btn"
|
||||
onClick={handleCloseVideo}
|
||||
aria-label="Fermer la vidéo"
|
||||
>
|
||||
<X size={18} />
|
||||
</button>
|
||||
<video
|
||||
src={videoUrl}
|
||||
controls
|
||||
autoPlay
|
||||
className="video-player"
|
||||
>
|
||||
Votre navigateur ne supporte pas la lecture de
|
||||
vidéos.
|
||||
</video>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user