Skip to content

Commit

Permalink
Merge pull request #133 from virtualidentityag/feat/DIAKONIE-424-post…
Browse files Browse the repository at this point in the history
…code-link-mobile

Feat(DIAKONIE-424): preselection logic mobile
  • Loading branch information
koepferd authored Nov 21, 2024
2 parents 545f558 + 5d73b04 commit 307e523
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { Typography } from '@mui/material';
import { SxProps, Theme, Typography } from '@mui/material';
import ReportProblemIcon from '@mui/icons-material/ReportProblem';
import { AgencyDataInterface } from '../../../../globalState/interfaces';

const PreselectedAgency = ({
hasError,
agency
agency,
sx
}: {
hasError: boolean;
agency: AgencyDataInterface;
sx?: SxProps<Theme>;
}) => {
const { t } = useTranslation();

Expand All @@ -21,8 +23,10 @@ const PreselectedAgency = ({
<>
<Typography
sx={{
...sx,
fontWeight: '600',
mb: '8px'
mb: '8px',
mt: '16px'
}}
>
{t('registration.agency.summary')}
Expand All @@ -37,14 +41,15 @@ const PreselectedAgency = ({
width: '20px',
height: '20px',
mr: '8px',
color: '#FF9F00'
color: '#FF9F00',
...sx
}}
/>
{t('registration.errors.aid')}
</>
</Typography>
) : (
<Typography>{agency.name}</Typography>
<Typography sx={{ ...sx, mt: '8px' }}>{agency.name}</Typography>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { Typography } from '@mui/material';
import { SxProps, Theme, Typography } from '@mui/material';
import ReportProblemIcon from '@mui/icons-material/ReportProblem';

const PreselectedConsultant = ({ hasError }: { hasError: boolean }) => {
const PreselectedConsultant = ({
hasError,
sx
}: {
hasError: boolean;
sx?: SxProps<Theme>;
}) => {
const { t } = useTranslation();
if (hasError) {
return (
Expand All @@ -23,7 +29,7 @@ const PreselectedConsultant = ({ hasError }: { hasError: boolean }) => {
);
}

return <Typography> {t('registration.consultantlink')}</Typography>;
return <Typography sx={sx}> {t('registration.consultantlink')}</Typography>;
};

export default PreselectedConsultant;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const PreselectedTopic = ({
}: {
hasError: boolean;
topic: TopicsDataInterface;
sx: SxProps<Theme>;
sx?: SxProps<Theme>;
}) => {
const { t } = useTranslation();

Expand All @@ -21,7 +21,14 @@ const PreselectedTopic = ({

return (
<>
<Typography sx={{ fontWeight: '600', mb: '8px' }}>
<Typography
sx={{
...sx,
fontWeight: '600',
mb: '8px',
mt: '16px'
}}
>
{t('registration.topic.summary')}
</Typography>
{hasError ? (
Expand All @@ -41,7 +48,7 @@ const PreselectedTopic = ({
</>
</Typography>
) : (
<Typography sx={sx}>
<Typography sx={{ ...sx, mt: '8px' }}>
{topic.titles?.long || topic.name}
</Typography>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,11 @@ import { Box, Drawer, Typography, Button } from '@mui/material';
import { ReactComponent as Loader } from './loader.svg';
import { ReactComponent as Logo } from './logo.svg';
import { useTranslation } from 'react-i18next';
import { PreselectionError } from '../preselectionError/PreselectionError';
import { RegistrationContext } from '../../../../globalState';
import { UrlParamsContext } from '../../../../globalState/provider/UrlParamsProvider';

const ConsultantPreslection = ({ hasError }) => {
const { t } = useTranslation();

if (hasError) {
return (
<PreselectionError errorMessage={t('registration.errors.cid')} />
);
}

return (
<Typography
sx={{
color: 'white',
mt: '24px'
}}
>
{t('registration.consultantlink')}
</Typography>
);
};
import PreselectedTopic from '../preselectionBox/PreselectedTopic';
import PreselectedAgency from '../preselectionBox/PreselectedAgency';
import PreselectedConsultant from '../preselectionBox/PreselectedConsultant';

export const PreselectionDrawer = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -150,57 +131,28 @@ export const PreselectionDrawer = () => {
}}
>
{preselectedConsultant ? (
<ConsultantPreslection
<PreselectedConsultant
sx={{ color: 'white', mt: '16px' }}
hasError={hasConsultantError}
/>
) : (
<>
{preselectedTopic || hasTopicError ? (
<Typography
sx={{
color: 'white',
fontWeight: '600',
mt: '24px'
}}
>
{t('registration.topic.summary')}
</Typography>
) : null}
{hasTopicError ? (
<PreselectionError
errorMessage={t(
'registration.errors.tid'
)}
/>
) : preselectedAgency ? (
<Typography
sx={{ color: 'white', mt: '8px' }}
>
{preselectedTopic?.name}
</Typography>
) : null}
<Typography
<PreselectedTopic
hasError={hasTopicError}
topic={preselectedTopic}
sx={{
color: 'white',
fontWeight: '600',
mt: '16px'
mb:
preselectedAgency || hasAgencyError
? '16px'
: '0px',
color: 'white'
}}
>
{t('registration.agency.summary')}
</Typography>
{hasAgencyError ? (
<PreselectionError
errorMessage={t(
'registration.errors.aid'
)}
/>
) : (
<Typography
sx={{ color: 'white', mt: '8px' }}
>
{preselectedAgency.name}
</Typography>
)}
/>
<PreselectedAgency
hasError={hasAgencyError}
agency={preselectedAgency}
sx={{ color: 'white' }}
/>
</>
)}
<Button
Expand Down

0 comments on commit 307e523

Please sign in to comment.