2021-06-17 17:26:35 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { FabModal } from '../base/fab-modal';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { HtmlTranslate } from '../base/html-translate';
|
2021-10-11 18:50:53 +02:00
|
|
|
import FormatLib from '../../lib/format';
|
2022-05-24 17:55:19 +02:00
|
|
|
import { TDateISO } from '../../typings/date-iso';
|
2021-06-17 17:26:35 +02:00
|
|
|
|
|
|
|
interface PendingTrainingModalProps {
|
|
|
|
isOpen: boolean,
|
|
|
|
toggleModal: () => void,
|
2022-05-24 17:55:19 +02:00
|
|
|
nextReservation: TDateISO,
|
2021-06-17 17:26:35 +02:00
|
|
|
}
|
|
|
|
|
2021-06-18 16:05:36 +02:00
|
|
|
/**
|
|
|
|
* Modal dialog shown if the current user has registered for a training but this training isn't validated
|
|
|
|
* when the user tries to book a machine.
|
|
|
|
*/
|
2021-06-17 17:26:35 +02:00
|
|
|
export const PendingTrainingModal: React.FC<PendingTrainingModalProps> = ({ isOpen, toggleModal, nextReservation }) => {
|
|
|
|
const { t } = useTranslation('logged');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the formatted localized date for the given date
|
|
|
|
*/
|
2022-05-24 17:55:19 +02:00
|
|
|
const formatDateTime = (date: TDateISO): string => {
|
2021-10-11 18:50:53 +02:00
|
|
|
return t('app.logged.pending_training_modal.DATE_TIME', { DATE: FormatLib.date(date), TIME: FormatLib.time(date) });
|
2021-07-01 12:34:10 +02:00
|
|
|
};
|
2021-06-17 17:26:35 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<FabModal title={t('app.logged.pending_training_modal.machine_reservation')}
|
2021-07-01 12:34:10 +02:00
|
|
|
isOpen={isOpen}
|
|
|
|
toggleModal={toggleModal}
|
|
|
|
closeButton={true}>
|
2021-06-17 17:26:35 +02:00
|
|
|
<p>{t('app.logged.pending_training_modal.wait_for_validated')}</p>
|
2021-06-18 12:47:04 +02:00
|
|
|
<p><HtmlTranslate trKey="app.logged.pending_training_modal.training_will_occur_DATE_html" options={{ DATE: formatDateTime(nextReservation) }} /></p>
|
2021-06-17 17:26:35 +02:00
|
|
|
</FabModal>
|
2021-07-01 12:34:10 +02:00
|
|
|
);
|
|
|
|
};
|