-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move attendees and registration out of EventDetail page file
- Loading branch information
Showing
7 changed files
with
156 additions
and
92 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
82 changes: 82 additions & 0 deletions
82
app/routes/events/components/EventDetail/AttendeeSection.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,82 @@ | ||
import { Flex } from '@webkom/lego-bricks'; | ||
import moment from 'moment-timezone'; | ||
import Attendance from 'app/components/UserAttendance/Attendance'; | ||
import { useIsLoggedIn } from 'app/reducers/auth'; | ||
import { selectRegistrationsFromPools } from 'app/reducers/events'; | ||
import RegistrationMeta from 'app/routes/events/components/RegistrationMeta'; | ||
import { getEventSemesterFromStartTime } from 'app/routes/events/utils'; | ||
import { useAppSelector } from 'app/store/hooks'; | ||
import type { UserDetailedEvent } from 'app/store/models/Event'; | ||
import type { | ||
PaymentRegistration, | ||
ReadRegistration, | ||
} from 'app/store/models/Registration'; | ||
|
||
const MIN_USER_GRID_ROWS = 2; | ||
const MAX_USER_GRID_ROWS = 2; | ||
|
||
interface Props { | ||
showSkeleton: boolean; | ||
event: UserDetailedEvent; | ||
currentRegistration?: PaymentRegistration; | ||
pools: any; | ||
currentPool: any; | ||
} | ||
|
||
export const AttendeeSection = ({ | ||
showSkeleton, | ||
event, | ||
currentRegistration, | ||
pools, | ||
currentPool, | ||
}: Props) => { | ||
const loggedIn = useIsLoggedIn(); | ||
const fetching = useAppSelector((state) => state.events.fetching); | ||
const registrations: ReadRegistration[] | undefined = useAppSelector( | ||
(state) => selectRegistrationsFromPools(state, { eventId: event.id }), | ||
); | ||
|
||
const currentMoment = moment(); | ||
const hasSimpleWaitingList = | ||
pools.filter((p) => p.name != 'Venteliste').length <= 1; | ||
const waitingListIndex = | ||
currentPool?.registrations.indexOf(currentRegistration); | ||
|
||
// The UserGrid is expanded when there's less than 5 minutes till activation | ||
const minUserGridRows = currentMoment.isAfter( | ||
moment(event.activationTime).subtract(5, 'minutes'), | ||
) | ||
? MIN_USER_GRID_ROWS | ||
: 0; | ||
|
||
return ( | ||
<Flex column> | ||
<h3>Påmeldte</h3> | ||
|
||
<Attendance | ||
pools={pools} | ||
registrations={registrations} | ||
currentRegistration={currentRegistration} | ||
minUserGridRows={minUserGridRows} | ||
maxUserGridRows={MAX_USER_GRID_ROWS} | ||
legacyRegistrationCount={event.legacyRegistrationCount} | ||
skeleton={fetching && !registrations} | ||
/> | ||
|
||
{loggedIn && ( | ||
<RegistrationMeta | ||
useConsent={event.useConsent} | ||
hasOpened={moment(event.activationTime).isBefore(currentMoment)} | ||
photoConsents={event.photoConsents} | ||
eventSemester={getEventSemesterFromStartTime(event.startTime)} | ||
hasEnded={moment(event.endTime).isBefore(currentMoment)} | ||
registration={currentRegistration} | ||
isPriced={event.isPriced} | ||
registrationIndex={waitingListIndex} | ||
hasSimpleWaitingList={hasSimpleWaitingList} | ||
skeleton={showSkeleton} | ||
/> | ||
)} | ||
</Flex> | ||
); | ||
}; |
28 changes: 28 additions & 0 deletions
28
app/routes/events/components/EventDetail/UnansweredSurveys.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,28 @@ | ||
import { Card } from '@webkom/lego-bricks'; | ||
import { Link } from 'react-router-dom'; | ||
import type { AuthUserDetailedEvent } from 'app/store/models/Event'; | ||
import type { ReadRegistration } from 'app/store/models/Registration'; | ||
|
||
interface Props { | ||
event: AuthUserDetailedEvent; | ||
currentRegistration: ReadRegistration | null; | ||
} | ||
|
||
export const UnansweredSurveys = ({ event, currentRegistration }: Props) => { | ||
return ( | ||
<Card severity="danger"> | ||
<p> | ||
Du kan ikke melde deg {currentRegistration ? 'av' : 'på'} dette | ||
arrangementet fordi du har ubesvarte spørreundersøkelser. Gå til lenkene | ||
under for å svare: | ||
</p> | ||
<ul> | ||
{event.unansweredSurveys.map((surveyId, i) => ( | ||
<li key={surveyId}> | ||
<Link to={`/surveys/${surveyId}`}>Undersøkelse {i + 1}</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</Card> | ||
); | ||
}; |
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
Oops, something went wrong.