feat: implement core platform features including business directory, admin dashboard, authentication, and API infrastructure
Some checks failed
Build and Push App / build (push) Failing after 16m2s
Some checks failed
Build and Push App / build (push) Failing after 16m2s
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { PlusCircle, Edit3, Trash2, ShoppingBag, Image as ImageIcon, Loader2 } from 'lucide-react';
|
||||
import { PlusCircle, Edit3, Trash2, ShoppingBag, Image as ImageIcon, Loader2, AlertCircle } from 'lucide-react';
|
||||
import { Offer, OfferType } from '../../types';
|
||||
import { toast } from 'react-hot-toast';
|
||||
|
||||
interface DashboardOffersProps {
|
||||
businessId: string;
|
||||
plan?: string;
|
||||
}
|
||||
|
||||
const DashboardOffers = ({ businessId }: DashboardOffersProps) => {
|
||||
const DashboardOffers = ({ businessId, plan = 'STARTER' }: DashboardOffersProps) => {
|
||||
const [offers, setOffers] = useState<Offer[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
@@ -155,19 +156,42 @@ const DashboardOffers = ({ businessId }: DashboardOffersProps) => {
|
||||
);
|
||||
}
|
||||
|
||||
const offerLimit = plan === 'BOOSTER' ? 10 : (plan === 'EMPIRE' ? 1000 : 1);
|
||||
const isLimitReached = offers.length >= offerLimit;
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex justify-between items-center">
|
||||
<h2 className="text-2xl font-bold font-serif text-gray-900">Mes Offres</h2>
|
||||
<div className="flex flex-col">
|
||||
<h2 className="text-2xl font-bold font-serif text-gray-900">Mes Offres</h2>
|
||||
<p className="text-xs text-gray-500 mt-1">
|
||||
Utilisation : <span className="font-bold">{offers.length} / {offerLimit === 1000 ? 'Illimité' : offerLimit}</span>
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={openAddModal}
|
||||
className="flex items-center bg-brand-600 text-white px-4 py-2 rounded-md hover:bg-brand-700 font-medium text-sm shadow-sm transition-colors active:scale-95"
|
||||
disabled={isLimitReached}
|
||||
className={`flex items-center px-4 py-2 rounded-md font-medium text-sm shadow-sm transition-colors active:scale-95 ${isLimitReached ? 'bg-gray-300 text-gray-500 cursor-not-allowed' : 'bg-brand-600 text-white hover:bg-brand-700'}`}
|
||||
>
|
||||
<PlusCircle className="w-4 h-4 mr-2" />
|
||||
Ajouter une offre
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{isLimitReached && (
|
||||
<div className="bg-orange-50 border border-orange-200 rounded-lg p-3 flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<AlertCircle className="w-5 h-5 text-orange-600" />
|
||||
<p className="text-sm text-orange-800">
|
||||
Vous avez atteint la limite de votre plan <strong>{plan}</strong>.
|
||||
</p>
|
||||
</div>
|
||||
<button className="text-xs font-bold text-brand-600 hover:text-brand-700 uppercase tracking-tight">
|
||||
Passer au plan supérieur →
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* List View */}
|
||||
{offers.length > 0 ? (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
|
||||
Reference in New Issue
Block a user