import React, { useMemo } from "react"; import { Page } from "@/pages/base"; import { Box, Button, Container, Step as StepperStep, StepContent, StepLabel, Stepper, StepProps as StepperStepProps, Typography } from "@material-ui/core"; import { Link as RouterLink } from "react-router-dom"; import { route } from "@/routing"; import { useTranslation } from "react-i18next"; import moment, { Moment } from "moment"; import { useSelector } from "react-redux"; import { AppState } from "@/state/reducer"; import { getMissingStudentData, Student } from "@/data"; import { Deadlines, Edition, getEditionDeadlines } from "@/data/edition"; import { Description as DescriptionIcon } from "@material-ui/icons" import { Actions } from "@/components/actions"; type StepProps = StepperStepProps & { until?: Moment; completedOn?: Moment; label: string; } const now = moment(); const Step = ({ until, label, completedOn, children, completed, ...props }: StepProps) => { const { t } = useTranslation(); const isLate = useMemo(() => until?.isBefore(completedOn || now), [completedOn, until]); const left = useMemo(() => moment.duration(now.diff(until)), [until]); return { label } { until && { t('until', { date: until }) } { isLate && - { t('late', { by: moment.duration(now.diff(until)) }) } } { !isLate && !completed && - { t('left', { left: left }) } } } { children && { children } } } export const MainPage = () => { const { t } = useTranslation(); const student = useSelector(state => state.student); const deadlines = useSelector(state => getEditionDeadlines(state.edition as Edition)); // edition cannot be null at this point const missingStudentData = useMemo(() => student ? getMissingStudentData(student) : [], [student]); return { t("sections.my-internship.header") } { missingStudentData.length > 0 && <>

{ t('steps.personal-data.info') }

    { missingStudentData.map(field =>
  • { t(`student.${ field }`) }
  • ) }
}

{ t('steps.internship-proposal.info') }

{ t('steps.plan.info') }

}