Skip to content

Commit

Permalink
rename states
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnIckler committed Dec 5, 2024
1 parent 8a57cc1 commit cc378c8
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions app/webpacker/components/MyCompetitions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@ import {
import UpcomingCompetitionTable from './UpcomingCompetitionTable';
import PastCompetitionsTable from './PastCompetitionTable';

const defaultPermissions = {
can_attend_competitions: { scope: [] },
can_organize_competitions: { scope: [] },
can_administer_competitions: { scope: [] },
};

export default function MyCompetitions({ permissions, competitions, userInfo }) {
const [isAccordionOpen, setIsAccordionOpen] = useState(false);
const [shouldShowRegistrationStatus, setShouldShowRegistrationStatus] = useState(false);
const [registrationStatusIsSown, setRegistrationStatusIsSown] = useState(false);

return (
<>
Expand All @@ -31,9 +25,9 @@ export default function MyCompetitions({ permissions, competitions, userInfo })
{I18n.t('competitions.my_competitions.disclaimer')}
</p>
<UpcomingCompetitionTable
competitions={competitions.futureCompetitions ?? []}
permissions={permissions ?? defaultPermissions}
registrationStatuses={competitions.registrationStatuses ?? {}}
competitions={competitions.futureCompetitions}
permissions={permissions}
registrationStatuses={competitions.registrationStatuses}
/>
<Accordion fluid styled>
<Accordion.Title
Expand All @@ -45,7 +39,7 @@ export default function MyCompetitions({ permissions, competitions, userInfo })
<Accordion.Content active={isAccordionOpen}>
<PastCompetitionsTable
permissions={permissions}
competitions={competitions.pastCompetitions ?? []}
competitions={competitions.pastCompetitions}
/>
</Accordion.Content>
</Accordion>
Expand All @@ -58,14 +52,14 @@ export default function MyCompetitions({ permissions, competitions, userInfo })
</Header>
<p>{I18n.t('competitions.my_competitions.bookmarked_explanation')}</p>
<Checkbox
checked={shouldShowRegistrationStatus}
checked={registrationStatusIsSown}
label={I18n.t('competitions.index.show_registration_status')}
onChange={() => setShouldShowRegistrationStatus(!shouldShowRegistrationStatus)}
onChange={() => setRegistrationStatusIsSown(!registrationStatusIsSown)}
/>
<UpcomingCompetitionTable
competitions={competitions.bookmarkedCompetitions ?? []}
registrationStatuses={competitions.registrationStatuses ?? {}}
shouldShowRegistrationStatus={shouldShowRegistrationStatus}
competitions={competitions.bookmarkedCompetitions}
registrationStatuses={competitions.registrationStatuses}
shouldShowRegistrationStatus={registrationStatusIsSown}
permissions={permissions}
/>
</>
Expand Down

0 comments on commit cc378c8

Please sign in to comment.