Ajout paramètre message bas de page personnalisable
This commit is contained in:
@@ -78,7 +78,7 @@ export default function AddPropositionModal({ isOpen, onClose, onSuccess, campai
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={handleClose}>
|
||||
<DialogContent className="sm:max-w-[500px]">
|
||||
<DialogContent className="sm:max-w-[500px] max-h-[90vh] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Ajouter une proposition</DialogTitle>
|
||||
<DialogDescription>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, D
|
||||
import { AlertTriangle } from 'lucide-react';
|
||||
import { campaignService } from '@/lib/services';
|
||||
import { Campaign } from '@/types';
|
||||
import { MarkdownContent } from '@/components/MarkdownContent';
|
||||
|
||||
interface DeleteCampaignModalProps {
|
||||
isOpen: boolean;
|
||||
@@ -64,7 +65,7 @@ export default function DeleteCampaignModal({ isOpen, onClose, onSuccess, campai
|
||||
<strong>Titre :</strong> {campaign.title}
|
||||
</p>
|
||||
<p className="text-sm text-slate-600 dark:text-slate-300">
|
||||
<strong>Description :</strong> {campaign.description}
|
||||
<strong>Description :</strong> <MarkdownContent content={campaign.description} />
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ export default function EditPropositionModal({ isOpen, onClose, onSuccess, propo
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent className="sm:max-w-[500px]">
|
||||
<DialogContent className="sm:max-w-[500px] max-h-[90vh] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Modifier la proposition</DialogTitle>
|
||||
<DialogDescription>
|
||||
|
||||
100
src/components/Footer.tsx
Normal file
100
src/components/Footer.tsx
Normal file
@@ -0,0 +1,100 @@
|
||||
'use client';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { PROJECT_CONFIG } from '@/lib/project.config';
|
||||
import { settingsService } from '@/lib/services';
|
||||
import { parseFooterMessage } from '@/lib/utils';
|
||||
|
||||
interface FooterProps {
|
||||
className?: string;
|
||||
variant?: 'home' | 'public';
|
||||
}
|
||||
|
||||
export default function Footer({ className = '', variant = 'public' }: FooterProps) {
|
||||
const [footerMessage, setFooterMessage] = useState('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const loadFooterMessage = async () => {
|
||||
try {
|
||||
const message = await settingsService.getStringValue(
|
||||
'footer_message',
|
||||
'Développé avec ❤️ pour faciliter la démocratie participative - [Logiciel libre et open source](GITURL) et transparent pour tous'
|
||||
);
|
||||
setFooterMessage(message);
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du chargement du message du bas de page:', error);
|
||||
// Utiliser le message par défaut en cas d'erreur
|
||||
setFooterMessage('Développé avec ❤️ pour faciliter la démocratie participative - [Logiciel libre et open source](GITURL) et transparent pour tous');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
loadFooterMessage();
|
||||
}, []);
|
||||
|
||||
if (loading) {
|
||||
return null; // Ne pas afficher le bas de page pendant le chargement
|
||||
}
|
||||
|
||||
const { text: processedText, links } = parseFooterMessage(footerMessage, PROJECT_CONFIG.repository.url);
|
||||
|
||||
// Pour la page d'accueil, utiliser un style plus simple
|
||||
if (variant === 'home') {
|
||||
return (
|
||||
<div className={`text-center mt-16 pb-8 ${className}`}>
|
||||
<p className="text-slate-600 dark:text-slate-400 text-lg">
|
||||
{processedText}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Pour les pages publiques, utiliser un style plus discret avec liens
|
||||
const renderFooterText = () => {
|
||||
if (links.length === 0) {
|
||||
return processedText;
|
||||
}
|
||||
|
||||
// Créer un tableau d'éléments avec les liens
|
||||
const elements: React.ReactNode[] = [];
|
||||
let lastIndex = 0;
|
||||
|
||||
links.forEach((link, index) => {
|
||||
// Ajouter le texte avant le lien
|
||||
if (link.start > lastIndex) {
|
||||
elements.push(processedText.slice(lastIndex, link.start));
|
||||
}
|
||||
|
||||
// Ajouter le lien
|
||||
elements.push(
|
||||
<a
|
||||
key={`link-${index}`}
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-gray-500 hover:text-gray-700 underline"
|
||||
>
|
||||
{link.text}
|
||||
</a>
|
||||
);
|
||||
|
||||
lastIndex = link.end;
|
||||
});
|
||||
|
||||
// Ajouter le texte restant
|
||||
if (lastIndex < processedText.length) {
|
||||
elements.push(processedText.slice(lastIndex));
|
||||
}
|
||||
|
||||
return elements;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`text-center mt-16 pb-20 ${className}`}>
|
||||
<p className="text-gray-400 text-sm">
|
||||
{renderFooterText()}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3,9 +3,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Eye, Edit3, AlertCircle, HelpCircle } from 'lucide-react';
|
||||
import { previewMarkdown, validateMarkdown } from '@/lib/markdown';
|
||||
|
||||
@@ -51,89 +49,116 @@ export function MarkdownEditor({
|
||||
{label}
|
||||
</Label>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
<button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setShowHelp(!showHelp)}
|
||||
className="h-6 px-2 text-xs text-muted-foreground hover:text-foreground"
|
||||
className="h-6 px-2 text-xs text-muted-foreground hover:text-foreground rounded border-0 bg-transparent cursor-pointer flex items-center gap-1"
|
||||
tabIndex={-1}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
setShowHelp(!showHelp);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<HelpCircle className="h-3 w-3 mr-1" />
|
||||
<HelpCircle className="h-3 w-3" />
|
||||
Aide Markdown
|
||||
</Button>
|
||||
</button>
|
||||
<span className="text-sm text-muted-foreground">{value.length}/{maxLength}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Tabs value={activeTab} onValueChange={(value) => setActiveTab(value as 'edit' | 'preview')}>
|
||||
<TabsList className="grid w-full grid-cols-2">
|
||||
<TabsTrigger value="edit" className="flex items-center gap-2">
|
||||
<div className="flex items-center justify-center mb-4">
|
||||
<div className="flex rounded-lg border bg-muted p-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setActiveTab('edit')}
|
||||
className={`px-3 py-1.5 text-sm font-medium rounded-md transition-colors flex items-center gap-2 ${
|
||||
activeTab === 'edit'
|
||||
? 'bg-background text-foreground shadow-sm'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
}`}
|
||||
tabIndex={-1}
|
||||
>
|
||||
<Edit3 className="h-4 w-4" />
|
||||
Éditer
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="preview" className="flex items-center gap-2">
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setActiveTab('preview')}
|
||||
className={`px-3 py-1.5 text-sm font-medium rounded-md transition-colors flex items-center gap-2 ${
|
||||
activeTab === 'preview'
|
||||
? 'bg-background text-foreground shadow-sm'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
}`}
|
||||
tabIndex={-1}
|
||||
>
|
||||
<Eye className="h-4 w-4" />
|
||||
Prévisualiser
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TabsContent value="edit" className="space-y-4">
|
||||
<Textarea
|
||||
id="markdown-editor"
|
||||
value={value}
|
||||
onChange={(e) => handleChange(e.target.value)}
|
||||
placeholder={placeholder}
|
||||
className="min-h-[200px] font-mono text-sm"
|
||||
/>
|
||||
|
||||
{/* Aide markdown (affichée conditionnellement) */}
|
||||
{showHelp && (
|
||||
<div className="rounded-lg border bg-muted/50 p-4 animate-in fade-in duration-200">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<h4 className="text-sm font-medium">Syntaxe Markdown supportée</h4>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setShowHelp(false)}
|
||||
className="h-6 px-2 text-xs"
|
||||
>
|
||||
×
|
||||
</Button>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4 text-xs text-muted-foreground">
|
||||
<div>
|
||||
<p><strong>**gras**</strong> → <strong>gras</strong></p>
|
||||
<p><em>*italique*</em> → <em>italique</em></p>
|
||||
<p><u>__souligné__</u> → <u>souligné</u></p>
|
||||
<p><del>~~barré~~</del> → <del>barré</del></p>
|
||||
{activeTab === 'edit' && (
|
||||
<div className="space-y-4">
|
||||
<Textarea
|
||||
id="markdown-editor"
|
||||
value={value}
|
||||
onChange={(e) => handleChange(e.target.value)}
|
||||
placeholder={placeholder}
|
||||
className="min-h-[200px] max-h-[300px] font-mono text-sm overflow-y-auto"
|
||||
tabIndex={0}
|
||||
/>
|
||||
|
||||
{/* Aide markdown (affichée conditionnellement) */}
|
||||
{showHelp && (
|
||||
<div className="rounded-lg border bg-muted/50 p-4 animate-in fade-in duration-200">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<h4 className="text-sm font-medium">Syntaxe Markdown supportée</h4>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowHelp(false)}
|
||||
className="h-6 px-2 text-xs rounded border-0 bg-transparent cursor-pointer hover:bg-muted"
|
||||
tabIndex={-1}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<p># Titre 1</p>
|
||||
<p>## Titre 2</p>
|
||||
<p>- Liste à puces</p>
|
||||
<p>[Lien](https://exemple.com)</p>
|
||||
<div className="grid grid-cols-2 gap-4 text-xs text-muted-foreground">
|
||||
<div>
|
||||
<p><strong>**gras**</strong> → <strong>gras</strong></p>
|
||||
<p><em>*italique*</em> → <em>italique</em></p>
|
||||
<p><u>__souligné__</u> → <u>souligné</u></p>
|
||||
<p><del>~~barré~~</del> → <del>barré</del></p>
|
||||
</div>
|
||||
<div>
|
||||
<p># Titre 1</p>
|
||||
<p>## Titre 2</p>
|
||||
<p>- Liste à puces</p>
|
||||
<p>[Lien](https://exemple.com)</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="preview" className="space-y-4">
|
||||
<div className="min-h-[200px] rounded-lg border bg-background p-4">
|
||||
{value ? (
|
||||
<div
|
||||
className="prose prose-sm max-w-none"
|
||||
dangerouslySetInnerHTML={{ __html: previewContent }}
|
||||
/>
|
||||
) : (
|
||||
<p className="text-muted-foreground italic">
|
||||
Aucun contenu à prévisualiser
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
)}
|
||||
|
||||
{activeTab === 'preview' && (
|
||||
<div className="space-y-4">
|
||||
<div className="min-h-[200px] max-h-[300px] rounded-lg border bg-background p-4 overflow-y-auto">
|
||||
{value ? (
|
||||
<div
|
||||
className="prose prose-sm max-w-none [&_ul]:space-y-1 [&_ol]:space-y-1 [&_li]:my-0"
|
||||
dangerouslySetInnerHTML={{ __html: previewContent }}
|
||||
/>
|
||||
) : (
|
||||
<p className="text-muted-foreground italic">
|
||||
Aucun contenu à prévisualiser
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Messages d'erreur */}
|
||||
{!validation.isValid && (
|
||||
|
||||
Reference in New Issue
Block a user