fine tune pages public de dépot de proposition
This commit is contained in:
@@ -5,8 +5,13 @@ import { useParams } from 'next/navigation';
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { Campaign } from '@/types';
|
import { Campaign } from '@/types';
|
||||||
import { campaignService, propositionService } from '@/lib/services';
|
import { campaignService, propositionService } from '@/lib/services';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { ArrowLeft, FileText, User, Mail, CheckCircle, AlertCircle } from 'lucide-react';
|
||||||
|
|
||||||
// Force dynamic rendering to avoid SSR issues with Supabase
|
|
||||||
export const dynamic = 'force-dynamic';
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
export default function PublicProposePage() {
|
export default function PublicProposePage() {
|
||||||
@@ -64,7 +69,6 @@ export default function PublicProposePage() {
|
|||||||
setError('');
|
setError('');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Créer la proposition avec les informations de l'auteur
|
|
||||||
await propositionService.create({
|
await propositionService.create({
|
||||||
campaign_id: campaignId,
|
campaign_id: campaignId,
|
||||||
title: formData.title,
|
title: formData.title,
|
||||||
@@ -100,10 +104,10 @@ export default function PublicProposePage() {
|
|||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gray-50 flex items-center justify-center">
|
<div className="min-h-screen bg-slate-50 dark:bg-slate-900 flex items-center justify-center">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600 mx-auto"></div>
|
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-slate-900 dark:border-slate-100 mx-auto mb-4"></div>
|
||||||
<p className="mt-4 text-gray-600">Chargement de la campagne...</p>
|
<p className="text-slate-600 dark:text-slate-300">Chargement de la campagne...</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -111,21 +115,20 @@ export default function PublicProposePage() {
|
|||||||
|
|
||||||
if (error && !campaign) {
|
if (error && !campaign) {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gray-50 flex items-center justify-center">
|
<div className="min-h-screen bg-slate-50 dark:bg-slate-900 flex items-center justify-center">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="bg-white rounded-lg shadow-lg p-8 max-w-md mx-auto">
|
<Card className="max-w-md mx-auto">
|
||||||
<svg className="mx-auto h-12 w-12 text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<CardContent className="p-8">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z" />
|
<div className="w-16 h-16 bg-red-100 dark:bg-red-900 rounded-full flex items-center justify-center mx-auto mb-4">
|
||||||
</svg>
|
<AlertCircle className="w-8 h-8 text-red-600 dark:text-red-400" />
|
||||||
<h2 className="mt-4 text-lg font-medium text-gray-900">Erreur</h2>
|
|
||||||
<p className="mt-2 text-sm text-gray-600">{error}</p>
|
|
||||||
<Link
|
|
||||||
href="/"
|
|
||||||
className="mt-4 inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700"
|
|
||||||
>
|
|
||||||
Retour à l'accueil
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
|
<h2 className="text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2">Erreur</h2>
|
||||||
|
<p className="text-slate-600 dark:text-slate-300 mb-6">{error}</p>
|
||||||
|
<Button asChild>
|
||||||
|
<Link href="/">Retour à l'accueil</Link>
|
||||||
|
</Button>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -133,54 +136,44 @@ export default function PublicProposePage() {
|
|||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gray-50 flex items-center justify-center">
|
<div className="min-h-screen bg-slate-50 dark:bg-slate-900 flex items-center justify-center">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="bg-white rounded-lg shadow-lg p-8 max-w-md mx-auto">
|
<Card className="max-w-md mx-auto">
|
||||||
<svg className="mx-auto h-12 w-12 text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<CardContent className="p-8">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
<div className="w-16 h-16 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center mx-auto mb-4">
|
||||||
</svg>
|
<CheckCircle className="w-8 h-8 text-green-600 dark:text-green-400" />
|
||||||
<h2 className="mt-4 text-lg font-medium text-gray-900">Proposition soumise !</h2>
|
</div>
|
||||||
<p className="mt-2 text-sm text-gray-600">
|
<h2 className="text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2">Proposition soumise !</h2>
|
||||||
|
<p className="text-slate-600 dark:text-slate-300 mb-6">
|
||||||
Votre proposition a été soumise avec succès. Merci pour votre participation !
|
Votre proposition a été soumise avec succès. Merci pour votre participation !
|
||||||
</p>
|
</p>
|
||||||
<div className="mt-6 space-y-3">
|
<div className="space-y-3">
|
||||||
<button
|
<Button
|
||||||
onClick={() => setSuccess(false)}
|
onClick={() => setSuccess(false)}
|
||||||
className="w-full inline-flex justify-center items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700"
|
className="w-full"
|
||||||
>
|
>
|
||||||
Soumettre une autre proposition
|
Soumettre une autre proposition
|
||||||
</button>
|
</Button>
|
||||||
<Link
|
<Button asChild variant="outline" className="w-full">
|
||||||
href="/"
|
<Link href="/">Retour à l'accueil</Link>
|
||||||
className="w-full inline-flex justify-center items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50"
|
</Button>
|
||||||
>
|
|
||||||
Retour à l'accueil
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gray-50">
|
<div className="min-h-screen bg-slate-50 dark:bg-slate-900">
|
||||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
<div className="container mx-auto px-4 py-8">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="mb-8">
|
<div className="mb-8">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
||||||
<div>
|
<div>
|
||||||
<Link
|
<h1 className="text-3xl font-bold text-slate-900 dark:text-slate-100">Déposer une proposition</h1>
|
||||||
href="/"
|
<p className="text-slate-600 dark:text-slate-300 mt-2">
|
||||||
className="inline-flex items-center text-sm text-indigo-600 hover:text-indigo-500 mb-4"
|
|
||||||
>
|
|
||||||
<svg className="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 19l-7-7m0 0l7-7m-7 7h18" />
|
|
||||||
</svg>
|
|
||||||
Retour à l'accueil
|
|
||||||
</Link>
|
|
||||||
<h1 className="text-3xl font-bold text-gray-900">Déposer une proposition</h1>
|
|
||||||
<p className="mt-2 text-gray-600">
|
|
||||||
Campagne : <span className="font-medium">{campaign?.title}</span>
|
Campagne : <span className="font-medium">{campaign?.title}</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -188,143 +181,130 @@ export default function PublicProposePage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Campaign Info */}
|
{/* Campaign Info */}
|
||||||
<div className="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-8">
|
<Card className="mb-8">
|
||||||
<h2 className="text-lg font-medium text-gray-900 mb-4">Informations sur la campagne</h2>
|
<CardHeader>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<CardTitle className="flex items-center gap-2">
|
||||||
|
<FileText className="w-5 h-5" />
|
||||||
|
Informations sur la campagne
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<h3 className="text-sm font-medium text-gray-500">Description</h3>
|
<h3 className="text-sm font-medium text-slate-600 dark:text-slate-300 mb-2">Description</h3>
|
||||||
<p className="mt-1 text-sm text-gray-900">{campaign?.description}</p>
|
<p className="text-slate-900 dark:text-slate-100">{campaign?.description}</p>
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-medium text-gray-500">Budget par participant</h3>
|
|
||||||
<p className="mt-1 text-sm text-gray-900">{campaign?.budget_per_user}€</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-medium text-gray-500">Paliers de dépenses</h3>
|
|
||||||
<p className="mt-1 text-sm text-gray-900">{campaign?.spending_tiers}</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-medium text-gray-500">Statut</h3>
|
|
||||||
<span className="mt-1 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
|
||||||
Dépôt de propositions
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
{/* Form */}
|
{/* Form */}
|
||||||
<div className="bg-white rounded-lg shadow-sm border border-gray-200">
|
<Card>
|
||||||
<div className="px-6 py-4 border-b border-gray-200">
|
<CardHeader>
|
||||||
<h2 className="text-lg font-medium text-gray-900">Votre proposition</h2>
|
<CardTitle>Votre proposition</CardTitle>
|
||||||
<p className="mt-1 text-sm text-gray-600">
|
<CardDescription>
|
||||||
Remplissez le formulaire ci-dessous pour soumettre votre proposition.
|
Remplissez le formulaire ci-dessous pour soumettre votre proposition.
|
||||||
</p>
|
</CardDescription>
|
||||||
</div>
|
</CardHeader>
|
||||||
|
|
||||||
<form onSubmit={handleSubmit} className="p-6 space-y-6">
|
<CardContent>
|
||||||
|
<form onSubmit={handleSubmit} className="space-y-6">
|
||||||
{error && (
|
{error && (
|
||||||
<div className="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-md">
|
<div className="p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg">
|
||||||
{error}
|
<p className="text-sm text-red-600 dark:text-red-400">{error}</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div>
|
<div className="space-y-2">
|
||||||
<label htmlFor="title" className="block text-sm font-medium text-gray-700 mb-1">
|
<label htmlFor="title" className="text-sm font-medium text-slate-700 dark:text-slate-300">
|
||||||
Titre de la proposition *
|
Titre de la proposition *
|
||||||
</label>
|
</label>
|
||||||
<input
|
<Input
|
||||||
type="text"
|
|
||||||
id="title"
|
id="title"
|
||||||
name="title"
|
name="title"
|
||||||
value={formData.title}
|
value={formData.title}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
required
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
|
|
||||||
placeholder="Titre de votre proposition"
|
placeholder="Titre de votre proposition"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div className="space-y-2">
|
||||||
<label htmlFor="description" className="block text-sm font-medium text-gray-700 mb-1">
|
<label htmlFor="description" className="text-sm font-medium text-slate-700 dark:text-slate-300">
|
||||||
Description *
|
Description *
|
||||||
</label>
|
</label>
|
||||||
<textarea
|
<Textarea
|
||||||
id="description"
|
id="description"
|
||||||
name="description"
|
name="description"
|
||||||
value={formData.description}
|
value={formData.description}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
required
|
|
||||||
rows={6}
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
|
|
||||||
placeholder="Décrivez votre proposition en détail..."
|
placeholder="Décrivez votre proposition en détail..."
|
||||||
|
rows={6}
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="border-t border-gray-200 pt-6">
|
<div className="border-t border-slate-200 dark:border-slate-700 pt-6">
|
||||||
<h3 className="text-lg font-medium text-gray-900 mb-4">Vos informations</h3>
|
<h3 className="text-lg font-medium text-slate-900 dark:text-slate-100 mb-4 flex items-center gap-2">
|
||||||
|
<User className="w-5 h-5" />
|
||||||
|
Vos informations
|
||||||
|
</h3>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
<div>
|
<div className="space-y-2">
|
||||||
<label htmlFor="author_first_name" className="block text-sm font-medium text-gray-700 mb-1">
|
<label htmlFor="author_first_name" className="text-sm font-medium text-slate-700 dark:text-slate-300">
|
||||||
Prénom *
|
Prénom *
|
||||||
</label>
|
</label>
|
||||||
<input
|
<Input
|
||||||
type="text"
|
|
||||||
id="author_first_name"
|
id="author_first_name"
|
||||||
name="author_first_name"
|
name="author_first_name"
|
||||||
value={formData.author_first_name}
|
value={formData.author_first_name}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
required
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
|
|
||||||
placeholder="Votre prénom"
|
placeholder="Votre prénom"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div className="space-y-2">
|
||||||
<label htmlFor="author_last_name" className="block text-sm font-medium text-gray-700 mb-1">
|
<label htmlFor="author_last_name" className="text-sm font-medium text-slate-700 dark:text-slate-300">
|
||||||
Nom *
|
Nom *
|
||||||
</label>
|
</label>
|
||||||
<input
|
<Input
|
||||||
type="text"
|
|
||||||
id="author_last_name"
|
id="author_last_name"
|
||||||
name="author_last_name"
|
name="author_last_name"
|
||||||
value={formData.author_last_name}
|
value={formData.author_last_name}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
required
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
|
|
||||||
placeholder="Votre nom"
|
placeholder="Votre nom"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-4">
|
<div className="space-y-2 mt-4">
|
||||||
<label htmlFor="author_email" className="block text-sm font-medium text-gray-700 mb-1">
|
<label htmlFor="author_email" className="text-sm font-medium text-slate-700 dark:text-slate-300 flex items-center gap-2">
|
||||||
|
<Mail className="w-4 h-4" />
|
||||||
Email *
|
Email *
|
||||||
</label>
|
</label>
|
||||||
<input
|
<Input
|
||||||
type="email"
|
|
||||||
id="author_email"
|
id="author_email"
|
||||||
name="author_email"
|
name="author_email"
|
||||||
|
type="email"
|
||||||
value={formData.author_email}
|
value={formData.author_email}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
required
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
|
|
||||||
placeholder="votre.email@exemple.com"
|
placeholder="votre.email@exemple.com"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-end pt-6">
|
<div className="flex items-center justify-end pt-6">
|
||||||
<button
|
<Button type="submit" disabled={submitting} size="lg">
|
||||||
type="submit"
|
|
||||||
disabled={submitting}
|
|
||||||
className="px-6 py-3 text-sm font-medium text-white bg-indigo-600 border border-transparent rounded-md hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
||||||
>
|
|
||||||
{submitting ? 'Soumission...' : 'Soumettre la proposition'}
|
{submitting ? 'Soumission...' : 'Soumettre la proposition'}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</CardContent>
|
||||||
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user