-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show passenger information messages on station and train pages (#18)
- Loading branch information
Showing
11 changed files
with
1,567 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Alert, ButtonBase } from '@mui/material'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
getPassengerInformationMessageForLanguage, | ||
PassengerInformationMessage, | ||
} from '../utils/passengerInformationMessages'; | ||
|
||
type PassengerInformationMessageAlertProps = { | ||
onClick: () => void; | ||
passengerInformationMessages: PassengerInformationMessage[]; | ||
}; | ||
|
||
const PassengerInformationMessageAlert = ({ | ||
onClick, | ||
passengerInformationMessages, | ||
}: PassengerInformationMessageAlertProps) => { | ||
const { i18n } = useTranslation(); | ||
|
||
if (passengerInformationMessages.length === 0) return null; | ||
|
||
const firstMessage = passengerInformationMessages[0]; | ||
|
||
return ( | ||
<ButtonBase | ||
onClick={onClick} | ||
sx={{ | ||
width: '100%', | ||
textAlign: 'left', | ||
'&:focus-visible': { | ||
outline: 'auto 1px', | ||
}, | ||
}} | ||
> | ||
<Alert severity="info" sx={{ width: '100%' }}> | ||
{getPassengerInformationMessageForLanguage( | ||
firstMessage, | ||
i18n.resolvedLanguage | ||
)} | ||
{passengerInformationMessages.length > 1 && ( | ||
<strong> + {passengerInformationMessages.length - 1}</strong> | ||
)} | ||
</Alert> | ||
</ButtonBase> | ||
); | ||
}; | ||
|
||
export default PassengerInformationMessageAlert; |
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,49 @@ | ||
import { Alert, DialogActions, DialogContent } from '@mui/material'; | ||
import Dialog from '@mui/material/Dialog'; | ||
import DialogTitle from '@mui/material/DialogTitle'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
getPassengerInformationMessageForLanguage, | ||
PassengerInformationMessage, | ||
} from '../utils/passengerInformationMessages'; | ||
|
||
type PassengerInformationMessagesDialogProps = { | ||
onClose: () => void; | ||
open: boolean; | ||
passengerInformationMessages: | ||
| PassengerInformationMessage[] | ||
| null | ||
| undefined; | ||
}; | ||
|
||
const PassengerInformationMessagesDialog = ( | ||
props: PassengerInformationMessagesDialogProps | ||
) => { | ||
const { onClose, open, passengerInformationMessages } = props; | ||
const { i18n } = useTranslation(); | ||
const { t } = useTranslation(); | ||
|
||
const handleClose = () => { | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<Dialog onClose={handleClose} open={open}> | ||
<DialogTitle>{t('alerts')}</DialogTitle> | ||
<DialogContent> | ||
{passengerInformationMessages?.map((m) => ( | ||
<Alert key={m.id} severity="info" sx={{ mb: 1 }}> | ||
{getPassengerInformationMessageForLanguage( | ||
m, | ||
i18n.resolvedLanguage | ||
)} | ||
</Alert> | ||
))} | ||
</DialogContent> | ||
<DialogActions sx={{ justifyContent: 'space-evenly' }}></DialogActions> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default PassengerInformationMessagesDialog; |
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.