-
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.
Merge pull request #5230 from webkom/ivarnakken/aba-1196-differentiat…
- Loading branch information
Showing
7 changed files
with
157 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { Flex, Icon } from '@webkom/lego-bricks'; | ||
import { AlarmClock } from 'lucide-react'; | ||
import Tag from 'app/components/Tags/Tag'; | ||
import Time from 'app/components/Time'; | ||
import { useIsLoggedIn } from 'app/reducers/auth'; | ||
import { EventStatusType } from 'app/store/models/Event'; | ||
import utilities from 'app/styles/utilities.css'; | ||
import type { ListEvent } from 'app/store/models/Event'; | ||
|
||
type Props = { | ||
event: ListEvent; | ||
isRegistrationOpen: boolean; | ||
isRegistrationSameYear: boolean; | ||
}; | ||
|
||
const RegistrationStatusTag = ({ | ||
event, | ||
isRegistrationOpen, | ||
isRegistrationSameYear, | ||
}: Props) => { | ||
const loggedIn = useIsLoggedIn(); | ||
|
||
const getRegistrationStatus = () => { | ||
if ( | ||
event.eventStatusType === EventStatusType.OPEN || | ||
event.eventStatusType === EventStatusType.INFINITE | ||
) { | ||
return 'Åpent for alle'; | ||
} | ||
|
||
if (event.isAdmitted) { | ||
return 'Du er påmeldt'; | ||
} | ||
|
||
if (event.userReg && event.eventStatusType === EventStatusType.NORMAL) { | ||
return 'Du er på venteliste'; | ||
} | ||
|
||
if (!!event.activationTime) { | ||
return ( | ||
<Flex alignItems="center" gap="var(--spacing-xs)"> | ||
<Icon | ||
iconNode={<AlarmClock />} | ||
size={14} | ||
className={utilities.hiddenOnMobile} | ||
/> | ||
<span> | ||
Påmelding {isRegistrationOpen ? 'åpnet' : 'åpner'}{' '} | ||
<Time | ||
time={event.activationTime} | ||
format={isRegistrationSameYear ? 'D. MMM HH:mm' : 'll HH:mm'} | ||
/> | ||
</span> | ||
</Flex> | ||
); | ||
} | ||
|
||
return 'Påmelding er ikke bestemt'; | ||
}; | ||
|
||
const getTagColor = () => { | ||
if (event.isAdmitted) { | ||
return 'green'; | ||
} | ||
|
||
if (event.userReg && event.eventStatusType === EventStatusType.NORMAL) { | ||
return 'orange'; | ||
} | ||
|
||
if ( | ||
event.eventStatusType === EventStatusType.OPEN || | ||
event.eventStatusType === EventStatusType.INFINITE | ||
) { | ||
return 'red'; | ||
} | ||
|
||
return isRegistrationOpen ? 'red' : 'gray'; | ||
}; | ||
|
||
if (!loggedIn) { | ||
return null; | ||
} | ||
|
||
return <Tag tag={getRegistrationStatus()} color={getTagColor()} />; | ||
}; | ||
|
||
export default RegistrationStatusTag; |
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
Oops, something went wrong.