feat: implement home page, business directory, and administrative management features with updated schema and API routes
Some checks failed
Build and Push App / build (push) Failing after 51s
Some checks failed
Build and Push App / build (push) Failing after 51s
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import React, { useState, useEffect, useMemo, Suspense } from 'react';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { Search, Loader2 } from 'lucide-react';
|
||||
import { CATEGORIES, Business, Country } from '../../types';
|
||||
import { Business, Country } from '../../types';
|
||||
import BusinessCard from '../../components/BusinessCard';
|
||||
import AnnuaireHero from '../../components/AnnuaireHero';
|
||||
|
||||
@@ -12,22 +12,28 @@ const AnnuairePageContent = () => {
|
||||
const [businesses, setBusinesses] = useState<Business[]>([]);
|
||||
const [featuredBusiness, setFeaturedBusiness] = useState<Business | null>(null);
|
||||
const [countries, setCountries] = useState<Country[]>([]);
|
||||
const [categories, setCategories] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [filterCategory, setFilterCategory] = useState('All');
|
||||
const [filterCountry, setFilterCountry] = useState('All');
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
// 1. Fetch Countries
|
||||
// 1. Fetch Metadata (Countries & Categories)
|
||||
useEffect(() => {
|
||||
const fetchCountries = async () => {
|
||||
const fetchMetadata = async () => {
|
||||
try {
|
||||
const res = await fetch('/api/countries');
|
||||
const data = await res.json();
|
||||
if (Array.isArray(data)) setCountries(data);
|
||||
const [cRes, catRes] = await Promise.all([
|
||||
fetch('/api/countries'),
|
||||
fetch('/api/categories')
|
||||
]);
|
||||
const cData = await cRes.json();
|
||||
const catData = await catRes.json();
|
||||
if (Array.isArray(cData)) setCountries(cData);
|
||||
if (Array.isArray(catData)) setCategories(catData);
|
||||
} catch (e) {}
|
||||
};
|
||||
fetchCountries();
|
||||
fetchMetadata();
|
||||
}, []);
|
||||
|
||||
// 2. Fetch Featured Headliner once
|
||||
@@ -139,17 +145,17 @@ const AnnuairePageContent = () => {
|
||||
/>
|
||||
<label htmlFor="cat-all" className="ml-3 text-sm text-gray-600">Toutes</label>
|
||||
</div>
|
||||
{CATEGORIES.map(cat => (
|
||||
<div key={cat} className="flex items-center">
|
||||
{categories.map(cat => (
|
||||
<div key={cat.id} className="flex items-center">
|
||||
<input
|
||||
id={`cat-${cat}`}
|
||||
id={`cat-${cat.id}`}
|
||||
name="category"
|
||||
type="radio"
|
||||
checked={filterCategory === cat}
|
||||
onChange={() => setFilterCategory(cat)}
|
||||
checked={filterCategory === cat.id || filterCategory === cat.name}
|
||||
onChange={() => setFilterCategory(cat.id)}
|
||||
className="focus:ring-brand-500 h-4 w-4 text-brand-600 border-gray-300"
|
||||
/>
|
||||
<label htmlFor={`cat-${cat}`} className="ml-3 text-sm text-gray-600 truncate" title={cat}>{cat}</label>
|
||||
<label htmlFor={`cat-${cat.id}`} className="ml-3 text-sm text-gray-600 truncate" title={cat.name}>{cat.name}</label>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user