Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(DIAKONIE-424): preselection logic mobile #133

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading