import Stack from '@material-hu/mui/Stack';

import useRules from 'src/hooks/useRules';
import { LearningCard } from 'src/pages/dashboard/Learning/common/components/LearningCard';
import {
  newSessionFields,
  newSessionRules,
} from 'src/pages/dashboard/Learning/Sessions/New/form';
import { useLokaliseTranslation } from 'src/utils/i18n';

import { useSessionStatus } from '../../../hooks/useSessionStatus';
import InputText from '../InputText';

const SessionPresential = () => {
  const { blockSessionEdition } = useSessionStatus();
  const { t } = useLokaliseTranslation('learning');

  const addressRules = useRules(newSessionRules.configuration.address());
  const meetingLinkRules = useRules(
    newSessionRules.configuration.meetingLink(),
  );

  return (
    <LearningCard id="session-configuration-presential-location-card">
      <Stack sx={{ gap: 3 }}>
        <InputText
          id="session-configuration-presential-address"
          label={t('session.address.label')}
          helperText={t('session.address.helper_text')}
          name={newSessionFields.configuration.address()}
          rules={addressRules}
          required
          inputProps={{
            placeholder: t('session.address.placeholder'),
            maxLength: newSessionRules.configuration.address().maxString!,
            disabled: blockSessionEdition,
          }}
        />
        <InputText
          id="session-configuration-presential-meeting-link"
          label={t('general:inputs.optional', {
            label: t('session.meeting_link.label'),
          })}
          helperText={t('session.meeting_link.helper_text.presential')}
          name={newSessionFields.configuration.meetingLink()}
          rules={meetingLinkRules}
          inputProps={{
            placeholder: t('session.meeting_link.placeholder'),
            maxLength: newSessionRules.configuration.meetingLink().maxString!,
            disabled: blockSessionEdition,
          }}
        />
      </Stack>
    </LearningCard>
  );
};

export default SessionPresential;
