ajout envoi smtp (paramètres, test envois, envoi à 1 participant). protège vue mot de passe
- ajout filtre page statistiques
This commit is contained in:
@@ -4,7 +4,7 @@ import { useState, useEffect } from 'react';
|
||||
import { useParams, useRouter } from 'next/navigation';
|
||||
import Link from 'next/link';
|
||||
import { Campaign, Proposition, Participant, Vote, PropositionWithVote } from '@/types';
|
||||
import { campaignService, participantService, propositionService, voteService } from '@/lib/services';
|
||||
import { campaignService, participantService, propositionService, voteService, settingsService } from '@/lib/services';
|
||||
|
||||
// Force dynamic rendering to avoid SSR issues with Supabase
|
||||
export const dynamic = 'force-dynamic';
|
||||
@@ -26,6 +26,7 @@ export default function PublicVotePage() {
|
||||
// Votes temporaires stockés localement
|
||||
const [localVotes, setLocalVotes] = useState<Record<string, number>>({});
|
||||
const [totalVoted, setTotalVoted] = useState(0);
|
||||
const [isRandomOrder, setIsRandomOrder] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (campaignId && participantId) {
|
||||
@@ -73,11 +74,20 @@ export default function PublicVotePage() {
|
||||
const votes = await voteService.getByParticipant(campaignId, participantId);
|
||||
|
||||
// Combiner les propositions avec leurs votes
|
||||
const propositionsWithVotes = propositionsData.map(proposition => ({
|
||||
let propositionsWithVotes = propositionsData.map(proposition => ({
|
||||
...proposition,
|
||||
vote: votes.find(vote => vote.proposition_id === proposition.id)
|
||||
}));
|
||||
|
||||
// Vérifier si l'ordre aléatoire est activé
|
||||
const randomizePropositions = await settingsService.getBooleanValue('randomize_propositions', false);
|
||||
|
||||
if (randomizePropositions) {
|
||||
// Mélanger les propositions de manière aléatoire
|
||||
propositionsWithVotes = propositionsWithVotes.sort(() => Math.random() - 0.5);
|
||||
setIsRandomOrder(true);
|
||||
}
|
||||
|
||||
setPropositions(propositionsWithVotes);
|
||||
|
||||
// Initialiser les votes locaux avec les votes existants
|
||||
@@ -278,6 +288,14 @@ export default function PublicVotePage() {
|
||||
<div>
|
||||
<h3 className="text-sm font-medium text-gray-500">Description</h3>
|
||||
<p className="mt-1 text-sm text-gray-900">{campaign?.description}</p>
|
||||
{isRandomOrder && (
|
||||
<div className="mt-3 p-2 bg-blue-50 border border-blue-200 rounded-md">
|
||||
<p className="text-xs text-blue-700 flex items-center gap-1">
|
||||
<span className="text-blue-500">ℹ️</span>
|
||||
Les propositions sont affichées dans un ordre aléatoire pour éviter les biais liés à l'ordre de présentation.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user