save avant prochaine modif

This commit is contained in:
2026-04-08 14:46:10 +02:00
parent bb10407e66
commit d88ba7c53c
1747 changed files with 194075 additions and 2433 deletions

38
lib/geminiService.ts Normal file
View File

@@ -0,0 +1,38 @@
// Client-side wrapper that calls the server-side /api/gemini route
export const generateBusinessDescription = async (
name: string,
category: string,
keywords: string
): Promise<string> => {
try {
const res = await fetch('/api/gemini', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'description', name, category, keywords }),
})
if (!res.ok) throw new Error('API error')
const data = await res.json()
return data.text || 'Impossible de générer une description pour le moment.'
} catch (error) {
console.error('Gemini API Error:', error)
return 'Erreur lors de la génération. Veuillez rédiger votre description manuellement.'
}
}
export const generateBusinessIdeas = async (
category: string
): Promise<string[]> => {
try {
const res = await fetch('/api/gemini', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'slogans', category }),
})
if (!res.ok) throw new Error('API error')
const data = await res.json()
return data.slogans || ["L'excellence au service de l'Afrique"]
} catch {
return ['Votre slogan ici']
}
}