Skip to content

Commit 80f8586

Browse files
committed
basic filter
1 parent be61158 commit 80f8586

File tree

3 files changed

+69
-16
lines changed

3 files changed

+69
-16
lines changed

frontend/src/components/blocks/dynamic-content-display-section/accepted-proposals-content.tsx

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
import {
22
CardPart,
3+
Grid,
34
Heading,
45
HorizontalStack,
56
MultiplePartsCard,
67
MultiplePartsCardCollection,
78
Section,
9+
Text,
10+
VerticalStack,
811
} from "@python-italia/pycon-styleguide";
12+
import React from "react";
913
import { FormattedMessage } from "react-intl";
1014
import { VotingCard } from "~/components/voting-card";
1115
import { useCurrentLanguage } from "~/locale/context";
1216
import { useAcceptedProposalsQuery } from "~/types";
1317

1418
export const AcceptedProposalsContent = () => {
19+
const [filterBy, setFilterBy] = React.useState(null);
1520
const language = useCurrentLanguage();
16-
const {
21+
let {
1722
data: {
1823
submissions: { items: submissions },
1924
},
@@ -24,6 +29,16 @@ export const AcceptedProposalsContent = () => {
2429
},
2530
});
2631

32+
if (filterBy === "talks") {
33+
submissions = submissions.filter(
34+
(submission) => submission.type.name.toLowerCase() === "talk",
35+
);
36+
} else if (filterBy === "workshops") {
37+
submissions = submissions.filter(
38+
(submission) => submission.type.name.toLowerCase() === "workshop",
39+
);
40+
}
41+
2742
return (
2843
<Section>
2944
<MultiplePartsCardCollection>
@@ -33,6 +48,38 @@ export const AcceptedProposalsContent = () => {
3348
<Heading size={2}>
3449
<FormattedMessage id="voting.proposals" />
3550
</Heading>
51+
<VerticalStack alignItems="center" gap="small">
52+
<Text weight="strong" size="label3">
53+
<FormattedMessage id="voting.filterBy" />
54+
</Text>
55+
56+
<div className="divide-x divide-black">
57+
<Text
58+
weight={filterBy === null ? "strong" : null}
59+
size="label3"
60+
className="pr-2"
61+
onClick={() => setFilterBy(null)}
62+
>
63+
<FormattedMessage id="voting.all" />
64+
</Text>
65+
<Text
66+
weight={filterBy === "talks" ? "strong" : null}
67+
size="label3"
68+
className="pl-2 pr-2"
69+
onClick={() => setFilterBy("talks")}
70+
>
71+
<FormattedMessage id="voting.talks" />
72+
</Text>
73+
<Text
74+
weight={filterBy === "workshops" ? "strong" : null}
75+
size="label3"
76+
className="pl-2"
77+
onClick={() => setFilterBy("workshops")}
78+
>
79+
<FormattedMessage id="voting.workshops" />
80+
</Text>
81+
</div>
82+
</VerticalStack>
3683
</HorizontalStack>
3784
</CardPart>
3885
</MultiplePartsCard>

frontend/src/components/blocks/dynamic-content-display-section/speakers-content.tsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,17 @@ export const SpeakersContent = () => {
3535
<Section>
3636
<Grid cols={3}>
3737
{Object.entries(submissionsBySpeaker).map(
38-
([speakerId, submissions]) => {
39-
let title = submissions[0].title;
40-
if (submissions.length > 1) {
41-
title = `${title} (+${submissions.length - 1})`;
42-
}
43-
return (
44-
<Link noHover href={`/profile/${speakerId}`} key={speakerId}>
45-
<SpeakerCard
46-
speakerName={submissions[0].speaker.fullname}
47-
portraitUrl={submissions[0].speaker.photo}
48-
sessions={title}
49-
/>
50-
</Link>
51-
);
52-
},
38+
([speakerId, submissions]) => (
39+
<Link noHover href={`/profile/${speakerId}`} key={speakerId}>
40+
<SpeakerCard
41+
speakerName={submissions[0].speaker.fullname}
42+
portraitUrl={submissions[0].speaker.photo}
43+
sessions={submissions
44+
.map((submission) => submission.title)
45+
.join(",")}
46+
/>
47+
</Link>
48+
),
5349
)}
5450
</Grid>
5551
</Section>

frontend/src/locale/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export const messages = {
2626
"checkout.billing.businessInvoice.description":
2727
"Turn this option on if your company, university or similar is paying for you or if you need an invoice.",
2828

29+
"voting.talks": "Talks",
30+
"voting.workshops": "Workshops",
31+
"voting.filterBy": "Filter by",
32+
"voting.all": "All",
33+
2934
"sponsorLeadModal.title": "Download our brochure",
3035
"sponsorLeadModal.submit": "Submit",
3136
"sponsorLeadModal.body": `Our packages gives you an idea of what we offer and how you can optimize your presence at PyCon Italia, but are not set in stone!
@@ -1939,6 +1944,8 @@ Affrettati a comprare il biglietto!`,
19391944
"scheduleEventDetail.materials.download": "Scarica ({mimeType})",
19401945

19411946
"voting.speaker": "Speaker",
1947+
"voting.talks": "Talks",
1948+
"voting.workshops": "Workshops",
19421949

19431950
"global.sessions": "Sessioni",
19441951

@@ -2279,6 +2286,9 @@ Clicca sulla casella per cambiare. Se lasciato vuoto, presumeremo che tu sia dis
22792286
"Il form aprirà il {date}. Segui i nostri socials per aggiornamenti e cambiamenti.",
22802287
"requestInvitationLetter.formClosed":
22812288
"Il form è chiuso. Se hai domande, contattaci.",
2289+
2290+
"voting.filterBy": "Filtra per",
2291+
"voting.all": "Tutti",
22822292
},
22832293
};
22842294

0 commit comments

Comments
 (0)