-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changelog: * Ajoute l'affichage auteur ect dans les articles du blog [NGC-258] #582 * pkg!: upgrade ngc model to 2.5.1 #581 * fix: add useFixedRegion in MainHooks (NGC-906) #580 * Ajout de score de missing variable pour les mosaiques + refacto everyMosaicChildrenWithParent (NGC-853) #579 * Ajoute l'affichage auteur ect dans les articles du blog [NGC-258] #582 * feat: consider question as md #578 * Cache éléments + retirer url campagne inexistante [NGC-898] #575 * Create pasterze-nouveautes-mai24.mdx #573 * Fix assistance #572 * [Hotfix] Réinitialise le state local de l'orga à chaque essai de connexion [NGC-901] #571 * Passe l'email de l'admin #570 * Ajoute trads manquantes #569 * Modifie la page paramètres d'orga [NGC-805] #568 * Ajoute la page paramètres de campagne [NGC-871] #567 * Ajoute la page campagne [NGC-870] #566 * Ajoute la page de création de campagne [NGC-807] #565 * Improve sorting (NGC-853 NGC-897 NGC-560) #562 * Ajoute la liste de campagnes dans le dashboard orga [NGC-686] #560
- Loading branch information
Showing
165 changed files
with
2,919 additions
and
1,420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
108 changes: 108 additions & 0 deletions
108
...pp/(layout-with-navigation)/(simulation)/organisations/[orgaSlug]/_components/MyPolls.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
'use client' | ||
|
||
import Trans from '@/components/translation/Trans' | ||
import Button from '@/design-system/inputs/Button' | ||
import Select from '@/design-system/inputs/Select' | ||
import Title from '@/design-system/layout/Title' | ||
import { OrganisationPoll } from '@/types/organisations' | ||
import { useMemo, useState } from 'react' | ||
import AddPollCard from './myPolls/AddPollCard' | ||
import PollCard from './myPolls/PollCard' | ||
|
||
type Props = { | ||
polls: OrganisationPoll[] | ||
} | ||
|
||
export default function MyPolls({ polls }: Props) { | ||
const [sort, setSort] = useState('date-old') | ||
const [isMinified, setIsMinified] = useState(true) | ||
|
||
const pollsSorted = useMemo( | ||
() => | ||
polls.sort((a, b) => { | ||
if (sort === 'date-new') { | ||
return ( | ||
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() | ||
) | ||
} | ||
|
||
if (sort === 'date-old') { | ||
return ( | ||
new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime() | ||
) | ||
} | ||
|
||
if (sort === 'alphabetical') { | ||
return (a.name ?? '').localeCompare(b.name ?? '') | ||
} | ||
|
||
if (sort === 'anti-alphabetical') { | ||
return (b.name ?? '').localeCompare(a.name ?? '') | ||
} | ||
|
||
return 0 | ||
}), | ||
[polls, sort] | ||
) | ||
|
||
return ( | ||
<section className="mb-12"> | ||
<div className="flex items-center justify-between"> | ||
<Title tag="h2"> | ||
<Trans>Mes campagnes</Trans> | ||
</Title> | ||
|
||
{pollsSorted.length > 0 && ( | ||
<Select | ||
onChange={(e) => { | ||
setSort(e.target.value) | ||
}} | ||
className="p-2 text-sm" | ||
name="sortOrder"> | ||
<option value="date-old"> | ||
<Trans>Date (anciennes > récentes)</Trans> | ||
</option> | ||
<option value="date-new"> | ||
<Trans>Date (récentes > anciennes)</Trans> | ||
</option> | ||
<option value="alphabetical"> | ||
<Trans>Nom (A > Z)</Trans> | ||
</option> | ||
<option value="anti-alphabetical"> | ||
<Trans>Nom (Z > A)</Trans> | ||
</option> | ||
</Select> | ||
)} | ||
</div> | ||
|
||
<ul className="mt-8 grid gap-8 sm:grid-cols-2 md:grid-cols-3"> | ||
{(isMinified ? pollsSorted.slice(0, 2) : pollsSorted).map( | ||
(poll, index) => ( | ||
<li key={poll._id} className="col-span-1"> | ||
<PollCard poll={poll} index={index} /> | ||
</li> | ||
) | ||
)} | ||
|
||
<AddPollCard hasNoPollsYet={polls.length === 0} /> | ||
</ul> | ||
|
||
{pollsSorted.length > 2 && ( | ||
<Button | ||
className="mt-6" | ||
onClick={() => setIsMinified((prevState) => !prevState)} | ||
color="link"> | ||
{isMinified ? ( | ||
<span> | ||
+ <Trans>Voir toutes les campagnes</Trans> | ||
</span> | ||
) : ( | ||
<span> | ||
- <Trans>Masquer les autres campagnes</Trans> | ||
</span> | ||
)} | ||
</Button> | ||
)} | ||
</section> | ||
) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.