Maj smtp, reset password, et ajout afroshine
All checks were successful
Build and Push App / build (push) Successful in 10m29s
All checks were successful
Build and Push App / build (push) Successful in 10m29s
This commit is contained in:
@@ -44,7 +44,7 @@ export async function setFeaturedBusiness(id: string, data: {
|
|||||||
return { success: true };
|
return { success: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to set featured business:", error);
|
console.error("Failed to set featured business:", error);
|
||||||
return { success: false, error: "Erreur lors de la mise à jour de l'entrepreneur du mois" };
|
return { success: false, error: "Erreur lors de la mise à jour de l'Afroshine" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default function FeaturedModal({ business }: Props) {
|
|||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
const result = await setFeaturedBusiness(business.id, data);
|
const result = await setFeaturedBusiness(business.id, data);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
toast.success("Entrepreneur du mois mis à jour !");
|
toast.success("Afroshine mis à jour !");
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
} else {
|
} else {
|
||||||
toast.error(result.error || "Une erreur est survenue");
|
toast.error(result.error || "Une erreur est survenue");
|
||||||
@@ -41,7 +41,7 @@ export default function FeaturedModal({ business }: Props) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRemove = async () => {
|
const handleRemove = async () => {
|
||||||
if (confirm("Retirer cet entrepreneur du titre 'Entrepreneur du mois' ?")) {
|
if (confirm("Retirer cet entrepreneur du titre 'Afroshine' ?")) {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
const result = await removeFeaturedBusiness(business.id);
|
const result = await removeFeaturedBusiness(business.id);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -79,7 +79,7 @@ export default function FeaturedModal({ business }: Props) {
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<h2 className="text-2xl font-bold text-white mb-2">💰 Entrepreneur du Mois</h2>
|
<h2 className="text-2xl font-bold text-white mb-2">💰 Afroshine</h2>
|
||||||
<p className="text-slate-400">Configurez les détails pour {business.name}.</p>
|
<p className="text-slate-400">Configurez les détails pour {business.name}.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ export default function FeaturedModal({ business }: Props) {
|
|||||||
className="w-full bg-amber-500 hover:bg-amber-600 text-slate-900 font-bold py-3 rounded-lg flex items-center justify-center gap-2 transition-colors"
|
className="w-full bg-amber-500 hover:bg-amber-600 text-slate-900 font-bold py-3 rounded-lg flex items-center justify-center gap-2 transition-colors"
|
||||||
>
|
>
|
||||||
{isPending ? <Loader2 className="w-5 h-5 animate-spin" /> : <Save className="w-5 h-5" />}
|
{isPending ? <Loader2 className="w-5 h-5 animate-spin" /> : <Save className="w-5 h-5" />}
|
||||||
Définir comme Entrepreneur du Mois
|
Définir comme Afroshine
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{business.isFeatured && (
|
{business.isFeatured && (
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ const BusinessDetailPage = () => {
|
|||||||
<div className="w-32 h-32 md:w-40 md:h-40 rounded-xl bg-white p-1 shadow-md -mt-16 md:-mt-24 border border-gray-100 flex-shrink-0 relative z-20">
|
<div className="w-32 h-32 md:w-40 md:h-40 rounded-xl bg-white p-1 shadow-md -mt-16 md:-mt-24 border border-gray-100 flex-shrink-0 relative z-20">
|
||||||
<img src={business.logoUrl} alt={business.name} className="w-full h-full object-cover rounded-lg bg-gray-50" />
|
<img src={business.logoUrl} alt={business.name} className="w-full h-full object-cover rounded-lg bg-gray-50" />
|
||||||
{business.isFeatured && (
|
{business.isFeatured && (
|
||||||
<div className="absolute -top-3 -right-3 bg-yellow-400 text-yellow-900 rounded-full p-2 shadow-md" title="Entrepreneur du Mois">
|
<div className="absolute -top-3 -right-3 bg-yellow-400 text-yellow-900 rounded-full p-2 shadow-md" title="Afroshine">
|
||||||
<Award className="w-6 h-6" />
|
<Award className="w-6 h-6" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -458,7 +458,7 @@ const BusinessDetailPage = () => {
|
|||||||
<div className="text-brand-600 font-medium mt-1 uppercase tracking-wide text-sm">{business.category}</div>
|
<div className="text-brand-600 font-medium mt-1 uppercase tracking-wide text-sm">{business.category}</div>
|
||||||
{business.isFeatured && (
|
{business.isFeatured && (
|
||||||
<div className="inline-flex items-center px-2 py-1 rounded bg-yellow-100 text-yellow-800 text-xs font-bold mt-2">
|
<div className="inline-flex items-center px-2 py-1 rounded bg-yellow-100 text-yellow-800 text-xs font-bold mt-2">
|
||||||
<Award className="w-3 h-3 mr-1" /> ENTREPRENEUR DU MOIS
|
<Award className="w-3 h-3 mr-1" /> AFROSHINE
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
60
app/api/auth/forgot-password/route.ts
Normal file
60
app/api/auth/forgot-password/route.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
import prisma from '@/lib/prisma';
|
||||||
|
import { sendEmail } from '@/lib/mail';
|
||||||
|
import crypto from 'crypto';
|
||||||
|
|
||||||
|
export async function POST(req: Request) {
|
||||||
|
try {
|
||||||
|
const { email } = await req.json();
|
||||||
|
|
||||||
|
if (!email) {
|
||||||
|
return NextResponse.json({ error: 'Email est requis' }, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await prisma.user.findUnique({
|
||||||
|
where: { email },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
// Pour des raisons de sécurité, on ne dit pas si l'utilisateur existe ou non
|
||||||
|
return NextResponse.json({ message: 'Si un compte existe pour cet email, un lien de réinitialisation a été envoyé.' });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Générer un token
|
||||||
|
const token = crypto.randomBytes(32).toString('hex');
|
||||||
|
const expiry = new Date(Date.now() + 3600000); // 1 heure
|
||||||
|
|
||||||
|
await prisma.user.update({
|
||||||
|
where: { id: user.id },
|
||||||
|
data: {
|
||||||
|
resetToken: token,
|
||||||
|
resetTokenExpiry: expiry,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const resetUrl = `${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/reset-password?token=${token}`;
|
||||||
|
|
||||||
|
await sendEmail({
|
||||||
|
to: email,
|
||||||
|
subject: 'Réinitialisation de votre mot de passe - Afrohub',
|
||||||
|
html: `
|
||||||
|
<div style="font-family: sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #e5e7eb; rounded-lg">
|
||||||
|
<h2 style="color: #0d9488; text-align: center;">Afrohub</h2>
|
||||||
|
<p>Bonjour ${user.name},</p>
|
||||||
|
<p>Vous avez demandé la réinitialisation de votre mot de passe. Cliquez sur le bouton ci-dessous pour choisir un nouveau mot de passe :</p>
|
||||||
|
<div style="text-align: center; margin: 30px 0;">
|
||||||
|
<a href="${resetUrl}" style="background-color: #0d9488; color: white; padding: 12px 24px; text-decoration: none; border-radius: 6px; font-weight: bold;">Réinitialiser mon mot de passe</a>
|
||||||
|
</div>
|
||||||
|
<p>Ce lien expirera dans 1 heure. Si vous n'avez pas demandé cette réinitialisation, vous pouvez ignorer cet email.</p>
|
||||||
|
<hr style="border: 0; border-top: 1px solid #e5e7eb; margin: 20px 0;">
|
||||||
|
<p style="font-size: 12px; color: #6b7280; text-align: center;">© 2025 Afrohub. Tous droits réservés.</p>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json({ message: 'Si un compte existe pour cet email, un lien de réinitialisation a été envoyé.' });
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('Error in forgot-password:', error);
|
||||||
|
return NextResponse.json({ error: 'Une erreur est survenue lors de la demande' }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
42
app/api/auth/reset-password/route.ts
Normal file
42
app/api/auth/reset-password/route.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
import prisma from '@/lib/prisma';
|
||||||
|
import bcrypt from 'bcryptjs';
|
||||||
|
|
||||||
|
export async function POST(req: Request) {
|
||||||
|
try {
|
||||||
|
const { token, password } = await req.json();
|
||||||
|
|
||||||
|
if (!token || !password) {
|
||||||
|
return NextResponse.json({ error: 'Token et mot de passe sont requis' }, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await prisma.user.findFirst({
|
||||||
|
where: {
|
||||||
|
resetToken: token,
|
||||||
|
resetTokenExpiry: {
|
||||||
|
gt: new Date(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return NextResponse.json({ error: 'Token invalide ou expiré' }, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const hashedPassword = await bcrypt.hash(password, 10);
|
||||||
|
|
||||||
|
await prisma.user.update({
|
||||||
|
where: { id: user.id },
|
||||||
|
data: {
|
||||||
|
password: hashedPassword,
|
||||||
|
resetToken: null,
|
||||||
|
resetTokenExpiry: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json({ message: 'Votre mot de passe a été mis à jour avec succès' });
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('Error in reset-password:', error);
|
||||||
|
return NextResponse.json({ error: 'Une erreur est survenue lors de la réinitialisation' }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
100
app/forgot-password/page.tsx
Normal file
100
app/forgot-password/page.tsx
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { useUser } from '@/components/UserProvider';
|
||||||
|
|
||||||
|
const ForgotPasswordPage = () => {
|
||||||
|
const { settings } = useUser();
|
||||||
|
const siteName = settings?.siteName || "Afrohub";
|
||||||
|
const [email, setEmail] = useState('');
|
||||||
|
const [message, setMessage] = useState('');
|
||||||
|
const [error, setError] = useState('');
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setLoading(true);
|
||||||
|
setError('');
|
||||||
|
setMessage('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/auth/forgot-password', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ email }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(data.error || 'Une erreur est survenue');
|
||||||
|
}
|
||||||
|
|
||||||
|
setMessage(data.message);
|
||||||
|
} catch (err: any) {
|
||||||
|
setError(err.message);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-[80vh] flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
|
||||||
|
<div className="max-w-md w-full space-y-8">
|
||||||
|
<div className="text-center">
|
||||||
|
<div className="mx-auto h-12 w-12 bg-brand-600 rounded-lg flex items-center justify-center text-white font-bold text-2xl">
|
||||||
|
{siteName.charAt(0)}
|
||||||
|
</div>
|
||||||
|
<h2 className="mt-6 text-3xl font-extrabold text-gray-900 font-serif">Mot de passe oublié</h2>
|
||||||
|
<p className="mt-2 text-sm text-gray-600">
|
||||||
|
Entrez votre adresse email pour recevoir un lien de réinitialisation
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{message ? (
|
||||||
|
<div className="bg-green-50 border-l-4 border-green-500 p-4 rounded text-green-700 text-sm">
|
||||||
|
{message}
|
||||||
|
<div className="mt-4">
|
||||||
|
<Link href="/login" className="font-medium text-brand-600 hover:text-brand-500"> Retourner à la connexion</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<form className="mt-8 space-y-6" onSubmit={handleSubmit}>
|
||||||
|
{error && (
|
||||||
|
<div className="bg-red-50 border-l-4 border-red-500 p-4 rounded text-red-700 text-sm">
|
||||||
|
{error}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="rounded-md shadow-sm -space-y-px">
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
type="email"
|
||||||
|
required
|
||||||
|
className="appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-brand-500 focus:border-brand-500 focus:z-10 sm:text-sm"
|
||||||
|
placeholder="Adresse email"
|
||||||
|
value={email}
|
||||||
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={loading}
|
||||||
|
className="group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-brand-600 hover:bg-brand-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500 disabled:opacity-70"
|
||||||
|
>
|
||||||
|
{loading ? 'Envoi...' : 'Envoyer le lien'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="text-center">
|
||||||
|
<Link href="/login" className="font-medium text-brand-600 hover:text-brand-500 text-sm"> Retourner à la connexion</Link>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ForgotPasswordPage;
|
||||||
@@ -83,6 +83,13 @@ const LoginPage = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center justify-end">
|
||||||
|
<div className="text-sm">
|
||||||
|
<Link href="/forgot-password" title="Réinitialiser votre mot de passe" className="font-medium text-brand-600 hover:text-brand-500">
|
||||||
|
Mot de passe oublié ?
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|||||||
138
app/reset-password/page.tsx
Normal file
138
app/reset-password/page.tsx
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { useState, useEffect, Suspense } from 'react';
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { useUser } from '@/components/UserProvider';
|
||||||
|
|
||||||
|
const ResetPasswordForm = () => {
|
||||||
|
const { settings } = useUser();
|
||||||
|
const siteName = settings?.siteName || "Afrohub";
|
||||||
|
const [password, setPassword] = useState('');
|
||||||
|
const [confirmPassword, setConfirmPassword] = useState('');
|
||||||
|
const [message, setMessage] = useState('');
|
||||||
|
const [error, setError] = useState('');
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const token = searchParams.get('token');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!token) {
|
||||||
|
setError("Le lien de réinitialisation est invalide ou manquant.");
|
||||||
|
}
|
||||||
|
}, [token]);
|
||||||
|
|
||||||
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (password !== confirmPassword) {
|
||||||
|
setError("Les mots de passe ne correspondent pas.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password.length < 6) {
|
||||||
|
setError("Le mot de passe doit faire au moins 6 caractères.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
setError('');
|
||||||
|
setMessage('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/auth/reset-password', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ token, password }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(data.error || 'Une erreur est survenue');
|
||||||
|
}
|
||||||
|
|
||||||
|
setMessage(data.message);
|
||||||
|
setTimeout(() => {
|
||||||
|
router.push('/login');
|
||||||
|
}, 3000);
|
||||||
|
} catch (err: any) {
|
||||||
|
setError(err.message);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-[80vh] flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
|
||||||
|
<div className="max-w-md w-full space-y-8">
|
||||||
|
<div className="text-center">
|
||||||
|
<div className="mx-auto h-12 w-12 bg-brand-600 rounded-lg flex items-center justify-center text-white font-bold text-2xl">
|
||||||
|
{siteName.charAt(0)}
|
||||||
|
</div>
|
||||||
|
<h2 className="mt-6 text-3xl font-extrabold text-gray-900 font-serif">Nouveau mot de passe</h2>
|
||||||
|
<p className="mt-2 text-sm text-gray-600">
|
||||||
|
Choisissez votre nouveau mot de passe
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{message ? (
|
||||||
|
<div className="bg-green-50 border-l-4 border-green-500 p-4 rounded text-green-700 text-sm">
|
||||||
|
{message}
|
||||||
|
<p className="mt-2">Redirection vers la page de connexion...</p>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<form className="mt-8 space-y-6" onSubmit={handleSubmit}>
|
||||||
|
{error && (
|
||||||
|
<div className="bg-red-50 border-l-4 border-red-500 p-4 rounded text-red-700 text-sm">
|
||||||
|
{error}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="rounded-md shadow-sm space-y-2">
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
required
|
||||||
|
className="appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-brand-500 focus:border-brand-500 focus:z-10 sm:text-sm"
|
||||||
|
placeholder="Nouveau mot de passe"
|
||||||
|
value={password}
|
||||||
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
required
|
||||||
|
className="appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-brand-500 focus:border-brand-500 focus:z-10 sm:text-sm"
|
||||||
|
placeholder="Confirmer le mot de passe"
|
||||||
|
value={confirmPassword}
|
||||||
|
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={loading || !token}
|
||||||
|
className="group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-brand-600 hover:bg-brand-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500 disabled:opacity-70"
|
||||||
|
>
|
||||||
|
{loading ? 'Mise à jour...' : 'Mettre à jour le mot de passe'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ResetPasswordPage = () => {
|
||||||
|
return (
|
||||||
|
<Suspense fallback={<div>Chargement...</div>}>
|
||||||
|
<ResetPasswordForm />
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ResetPasswordPage;
|
||||||
@@ -72,7 +72,19 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|||||||
priority: 0.7,
|
priority: 0.7,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return [...staticRoutes, ...businessRoutes, ...blogRoutes];
|
// 4. Fetch all Afro Life (Interviews)
|
||||||
|
const interviews = await prisma.interview.findMany({
|
||||||
|
select: { id: true, slug: true, updatedAt: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
const afroLifeRoutes = interviews.map((interview) => ({
|
||||||
|
url: `${baseUrl}/afrolife/${interview.slug || interview.id}`,
|
||||||
|
lastModified: interview.updatedAt,
|
||||||
|
changeFrequency: 'monthly' as const,
|
||||||
|
priority: 0.7,
|
||||||
|
}));
|
||||||
|
|
||||||
|
return [...staticRoutes, ...businessRoutes, ...blogRoutes, ...afroLifeRoutes];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error generating sitemap:", error);
|
console.error("Error generating sitemap:", error);
|
||||||
// Fallback to only static routes if DB connection fails
|
// Fallback to only static routes if DB connection fails
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const AnnuaireHero = ({ featuredBusiness }: { featuredBusiness: Business }) => {
|
|||||||
<div className="md:w-3/5 p-8 md:p-12 flex flex-col justify-center">
|
<div className="md:w-3/5 p-8 md:p-12 flex flex-col justify-center">
|
||||||
<div className="flex items-center space-x-2 mb-4">
|
<div className="flex items-center space-x-2 mb-4">
|
||||||
<span className="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-yellow-100 text-yellow-800 uppercase tracking-wider">
|
<span className="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-yellow-100 text-yellow-800 uppercase tracking-wider">
|
||||||
<Award className="w-3 h-3 mr-1" /> Entrepreneur du mois
|
<Award className="w-3 h-3 mr-1" /> Afroshine
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ const AnnuaireHero = ({ featuredBusiness }: { featuredBusiness: Business }) => {
|
|||||||
Voir la fiche complète
|
Voir la fiche complète
|
||||||
</Link>
|
</Link>
|
||||||
<button className="inline-flex items-center justify-center px-6 py-3 border-2 border-gray-200 text-base font-medium rounded-md text-gray-600 bg-transparent hover:border-brand-300 hover:text-brand-600 transition-colors">
|
<button className="inline-flex items-center justify-center px-6 py-3 border-2 border-gray-200 text-base font-medium rounded-md text-gray-600 bg-transparent hover:border-brand-300 hover:text-brand-600 transition-colors">
|
||||||
Devenir l'entrepreneur du mois <ArrowRight className="w-4 h-4 ml-2"/>
|
Devenir l'Afroshine <ArrowRight className="w-4 h-4 ml-2"/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
29
lib/mail.ts
Normal file
29
lib/mail.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import nodemailer from 'nodemailer';
|
||||||
|
|
||||||
|
const transporter = nodemailer.createTransport({
|
||||||
|
host: process.env.SMTP_HOST,
|
||||||
|
port: parseInt(process.env.SMTP_PORT || '587'),
|
||||||
|
secure: process.env.SMTP_SECURE === 'true',
|
||||||
|
auth: {
|
||||||
|
user: process.env.SMTP_USER,
|
||||||
|
pass: process.env.SMTP_PASS,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const sendEmail = async ({ to, subject, html }: { to: string; subject: string; html: string }) => {
|
||||||
|
const mailOptions = {
|
||||||
|
from: process.env.SMTP_FROM || '"Afrohub" <noreply@afrohub.com>',
|
||||||
|
to,
|
||||||
|
subject,
|
||||||
|
html,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const info = await transporter.sendMail(mailOptions);
|
||||||
|
console.log('Email sent: ' + info.response);
|
||||||
|
return info;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error sending email:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
2
next-env.d.ts
vendored
2
next-env.d.ts
vendored
@@ -1,6 +1,6 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
import "./.next/types/routes.d.ts";
|
import "./.next/dev/types/routes.d.ts";
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
// NOTE: This file should not be edited
|
||||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||||
|
|||||||
21
package-lock.json
generated
21
package-lock.json
generated
@@ -23,6 +23,7 @@
|
|||||||
"jiti": "^2.6.1",
|
"jiti": "^2.6.1",
|
||||||
"lucide-react": "^0.554.0",
|
"lucide-react": "^0.554.0",
|
||||||
"next": "^16.1.6",
|
"next": "^16.1.6",
|
||||||
|
"nodemailer": "^8.0.6",
|
||||||
"pg": "^8.19.0",
|
"pg": "^8.19.0",
|
||||||
"postcss": "^8.5.10",
|
"postcss": "^8.5.10",
|
||||||
"prisma": "6.19.3",
|
"prisma": "6.19.3",
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
"typescript": "~5.8.2"
|
"typescript": "~5.8.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/nodemailer": "^8.0.0",
|
||||||
"concurrently": "^9.2.1"
|
"concurrently": "^9.2.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -1713,6 +1715,16 @@
|
|||||||
"undici-types": "~6.21.0"
|
"undici-types": "~6.21.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/nodemailer": {
|
||||||
|
"version": "8.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-8.0.0.tgz",
|
||||||
|
"integrity": "sha512-fyf8jWULsCo0d0BuoQ75i6IeoHs47qcqxWc7yUdUcV0pOZGjUTTOvwdG1PRXUDqN/8A64yQdQdnA2pZgcdi+cA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/pg": {
|
"node_modules/@types/pg": {
|
||||||
"version": "8.20.0",
|
"version": "8.20.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.20.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.20.0.tgz",
|
||||||
@@ -3139,6 +3151,15 @@
|
|||||||
"integrity": "sha512-3qT/88Y3FbH/Kx4szpQQ4HzUbVrHPKTLVpVocKiLfoYvw9XSGOX2FmD2d6DrXbVYyAQTF2HeF6My8jmzx7/CRw==",
|
"integrity": "sha512-3qT/88Y3FbH/Kx4szpQQ4HzUbVrHPKTLVpVocKiLfoYvw9XSGOX2FmD2d6DrXbVYyAQTF2HeF6My8jmzx7/CRw==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/nodemailer": {
|
||||||
|
"version": "8.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-8.0.6.tgz",
|
||||||
|
"integrity": "sha512-Nm2XeuDwwy2wi5A+8jPWwQwNzcjNjhWdE3pVLoXEusxJqCnAPAgnBGkSmiLknbnWuOF9qraRpYZjfxqtKZ4tPw==",
|
||||||
|
"license": "MIT-0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/nypm": {
|
"node_modules/nypm": {
|
||||||
"version": "0.6.6",
|
"version": "0.6.6",
|
||||||
"resolved": "https://registry.npmjs.org/nypm/-/nypm-0.6.6.tgz",
|
"resolved": "https://registry.npmjs.org/nypm/-/nypm-0.6.6.tgz",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"jiti": "^2.6.1",
|
"jiti": "^2.6.1",
|
||||||
"lucide-react": "^0.554.0",
|
"lucide-react": "^0.554.0",
|
||||||
"next": "^16.1.6",
|
"next": "^16.1.6",
|
||||||
|
"nodemailer": "^8.0.6",
|
||||||
"pg": "^8.19.0",
|
"pg": "^8.19.0",
|
||||||
"postcss": "^8.5.10",
|
"postcss": "^8.5.10",
|
||||||
"prisma": "6.19.3",
|
"prisma": "6.19.3",
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
"typescript": "~5.8.2"
|
"typescript": "~5.8.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/nodemailer": "^8.0.0",
|
||||||
"concurrently": "^9.2.1"
|
"concurrently": "^9.2.1"
|
||||||
},
|
},
|
||||||
"prisma": {
|
"prisma": {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ model User {
|
|||||||
password String
|
password String
|
||||||
role UserRole @default(VISITOR)
|
role UserRole @default(VISITOR)
|
||||||
avatar String?
|
avatar String?
|
||||||
|
resetToken String? @unique
|
||||||
|
resetTokenExpiry DateTime?
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
bio String?
|
bio String?
|
||||||
|
|||||||
Reference in New Issue
Block a user