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

fix(human-app): page card component #11

Merged
merged 2 commits into from
Sep 28, 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
Expand Up @@ -52,7 +52,6 @@ export function Input({
}
label={label}
name={name}
sx={{ maxWidth: '376px' }}
variant="outlined"
{...rest}
/>
Expand Down
35 changes: 28 additions & 7 deletions packages/apps/human-app/frontend/src/components/ui/page-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const IconWrapper = styled('div')(() => ({
}));

const commonStyles: SxProps<Theme> = {
padding: '2rem 2rem 8.75rem 2rem',
padding: '2rem',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
Expand All @@ -44,9 +44,10 @@ type ButtonsProps = string | -1 | (() => void);

interface FormCardProps {
children: React.JSX.Element;
maxContentWidth?: string;
childrenMaxWidth?: string;
title?: React.JSX.Element | string;
alert?: React.JSX.Element;
childrenMaxWidth?: string;
backArrowPath?: ButtonsProps;
cancelRouterPathOrCallback?: ButtonsProps;
hiddenCancelButton?: boolean;
Expand All @@ -59,6 +60,7 @@ export function PageCard({
children,
title,
alert,
maxContentWidth = '376px',
childrenMaxWidth = '486px',
backArrowPath = -1,
cancelRouterPathOrCallback = routerPaths.homePage,
Expand All @@ -69,6 +71,13 @@ export function PageCard({
const { setGrayBackground } = useBackgroundColorStore();
const navigate = useNavigate();
const isMobile = useIsMobile('md');
const contentStyles = {
maxWidth: maxContentWidth,
width: '100%',
[breakpoints.mobile]: {
maxWidth: 'unset',
},
};

useEffect(() => {
if (withLayoutBackground) {
Expand All @@ -94,7 +103,7 @@ export function PageCard({
container
sx={{
...commonStyles,
padding: isMobile ? '0 1rem 7.25rem 1rem' : '2rem 2rem 8.75rem 2rem',
padding: isMobile ? '0 1rem 7.25rem 1rem' : '2rem 2rem 7.7rem 2rem',
}}
>
{!hiddenCancelButton && (
Expand Down Expand Up @@ -132,6 +141,9 @@ export function PageCard({
width: '100%',
justifyContent: 'center',
alignItems: 'center',
[breakpoints.mobile]: {
maxWidth: '100%',
},
}}
>
<Grid
Expand Down Expand Up @@ -198,7 +210,7 @@ export function PageCard({
}}
xs={12}
>
{alert ? <>{alert}</> : null}
<Grid sx={contentStyles}>{alert ? <>{alert}</> : null}</Grid>
</Grid>
<Grid
item
Expand All @@ -207,6 +219,7 @@ export function PageCard({
sx={{
display: 'flex',
justifyContent: 'flex-end',
mt: '5px',
[breakpoints.mobile]: {
display: 'none',
},
Expand All @@ -219,12 +232,20 @@ export function PageCard({
</IconWrapper>
) : null}
</Grid>
<Grid item md={10} order={{ xs: 4, md: 4 }} xs={12}>
<Typography variant="h4">{title}</Typography>
<Grid
item
md={10}
order={{ xs: 4, md: 4 }}
sx={{ marginBottom: '24px' }}
xs={12}
>
<Grid sx={contentStyles}>
<Typography variant="h4">{title}</Typography>
</Grid>
</Grid>
<Grid item md={1} order={{ xs: 5, md: 5 }} xs={1} />
<Grid item md={10} order={{ xs: 6, md: 6 }} xs={12}>
{children}
<Grid sx={contentStyles}>{children}</Grid>
</Grid>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export function ChooseSignUpAccountType() {
<PageCard
backArrowPath={backToWelcomeStage}
cancelRouterPathOrCallback={backToWelcomeStage}
childrenMaxWidth="100%"
childrenMaxWidth="876px"
hiddenCancelButton={!isMobileMd}
maxContentWidth="748px"
title={<Typography variant="h4">{t('homepage.welcome')} 👋</Typography>}
>
<Grid container spacing={4}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function Form({
).length;

return (
<Grid container gap="2rem" marginTop="1rem">
<Grid container gap="2rem">
<div
style={{
width: '100%',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function ExistingKeysForm({
useResetMutationErrors(existingKeysMethods.watch, existingKeysMutation.reset);

return (
<Grid container gap="2rem" marginTop="1rem">
<Grid container gap="1.5rem">
<div
style={{
width: '100%',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function PendingKeysForm({
style={{
display: 'flex',
flexDirection: 'column',
gap: '1rem',
gap: '1.5rem',
}}
>
<EditPendingKeysForm existingKeysInitialState={keysData} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function AddStakeOperatorPage() {
<PageCard alert={getAlert()} title={t('operator.addStake.title')}>
<Grid
container
sx={{ flexDirection: 'column', gap: '1rem', marginTop: '2rem' }}
sx={{ flexDirection: 'column', gap: '1.5rem', marginTop: '1rem' }}
>
<Typography variant="body4">
{t('operator.addStake.formHeader')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function ConnectWalletOperatorPage() {

return (
<PageCard alert={getAlert()} title={t('operator.connectWallet.title')}>
<Grid container sx={{ flexDirection: 'column', gap: '2rem' }}>
<Grid container sx={{ flexDirection: 'column', gap: '1.5rem' }}>
<Typography variant="body1">
{t('operator.connectWallet.description')}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function SetUpOperatorPage() {
}
title={t('operator.connectWallet.title')}
>
<Grid container sx={{ flexDirection: 'column', gap: '2rem' }}>
<Grid container sx={{ flexDirection: 'column', gap: '1.5rem' }}>
<Typography variant="body1">
{t('operator.connectWallet.description')}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function ResetPasswordWorkerSuccessPage() {
</Grid>
}
>
<Grid container gap="2rem">
<Grid container gap="1.5rem">
<Typography variant="body1">
{t('worker.resetPasswordSuccess.description')}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { defaultErrorMessage } from '@/shared/helpers/default-error-message';
import { routerPaths } from '@/router/router-paths';
import { FormCaptcha } from '@/components/h-captcha';
import { useResetMutationErrors } from '@/hooks/use-reset-mutation-errors';
import { MAX_INPUT_WIDTH } from '@/shared/consts';

export function ResetPasswordWorkerPage() {
const location = useLocation();
Expand Down Expand Up @@ -70,7 +69,7 @@ export function ResetPasswordWorkerPage() {
void methods.handleSubmit(handleWorkerResetPassword)(event);
}}
>
<Grid container gap="2rem" maxWidth={`${MAX_INPUT_WIDTH}px`}>
<Grid container gap="1.5rem">
<Typography variant="body1">
{t('worker.resetPassword.description')}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function SendResetLinkWorkerSuccessPage() {
void methods.handleSubmit(handleWorkerSendResetLink)(event);
}}
>
<Grid container gap="2rem">
<Grid container gap="1.5rem">
<Typography>
<Trans
components={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { useAuth } from '@/auth/use-auth';
import { FormCaptcha } from '@/components/h-captcha';
import { routerPaths } from '@/router/router-paths';
import { useResetMutationErrors } from '@/hooks/use-reset-mutation-errors';
import { MAX_INPUT_WIDTH } from '@/shared/consts';

export function SendResetLinkWorkerPage() {
const { t } = useTranslation();
Expand Down Expand Up @@ -63,7 +62,7 @@ export function SendResetLinkWorkerPage() {
void methods.handleSubmit(handleWorkerSendResetLink)(event);
}}
>
<Grid container gap="2rem" maxWidth={`${MAX_INPUT_WIDTH}px`}>
<Grid container gap="1.5rem">
<Typography variant="body1">
{t('worker.sendResetLinkForm.description')}
</Typography>
Expand Down
28 changes: 12 additions & 16 deletions packages/apps/human-app/frontend/src/pages/worker/sign-in.page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FormProvider, useForm } from 'react-hook-form';
import { Grid, Typography } from '@mui/material';
import { Box, Grid, Typography } from '@mui/material';
import { zodResolver } from '@hookform/resolvers/zod';
import { useTranslation } from 'react-i18next';
import { t as i18NextT } from 'i18next';
Expand All @@ -21,7 +21,6 @@ import { Alert } from '@/components/ui/alert';
import { FormCaptcha } from '@/components/h-captcha';
import { useResetMutationErrors } from '@/hooks/use-reset-mutation-errors';
import { browserAuthProvider } from '@/shared/helpers/browser-auth-provider';
import { MAX_INPUT_WIDTH } from '@/shared/consts';

function formattedSignInErrorMessage(unknownError: unknown) {
if (unknownError instanceof FetchError && unknownError.status === 400) {
Expand Down Expand Up @@ -80,12 +79,7 @@ export function SignInWorkerPage() {
void methods.handleSubmit(handleWorkerSignIn)(event)
}
>
<Grid
container
gap="2rem"
maxWidth={`${MAX_INPUT_WIDTH}px`}
sx={{ paddingTop: '1rem' }}
>
<Grid container gap="1.5rem">
<Input
fullWidth
label={t('worker.signInForm.fields.email')}
Expand All @@ -96,14 +90,16 @@ export function SignInWorkerPage() {
label={t('worker.signInForm.fields.password')}
name="password"
/>
<Typography variant="body1">
<Link
style={{ textDecoration: 'none', fontWeight: 600 }}
to={routerPaths.worker.sendResetLink}
>
{t('worker.signInForm.forgotPassword')}
</Link>
</Typography>
<Box width="100%">
<Typography variant="body1">
<Link
style={{ textDecoration: 'none', fontWeight: 600 }}
to={routerPaths.worker.sendResetLink}
>
{t('worker.signInForm.forgotPassword')}
</Link>
</Typography>
</Box>
<FormCaptcha error={signInWorkerError} name="h_captcha_token" />
<Button
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { FetchError } from '@/api/fetcher';
import { FormCaptcha } from '@/components/h-captcha';
import { useResetMutationErrors } from '@/hooks/use-reset-mutation-errors';
import { browserAuthProvider } from '@/shared/helpers/browser-auth-provider';
import { MAX_INPUT_WIDTH } from '@/shared/consts';

function formattedSignUpErrorMessage(unknownError: unknown) {
if (unknownError instanceof FetchError && unknownError.status === 409) {
Expand Down Expand Up @@ -81,7 +80,7 @@ export function SignUpWorkerPage() {
void methods.handleSubmit(handleWorkerSignUp)(event);
}}
>
<Grid container gap="2rem" maxWidth={`${MAX_INPUT_WIDTH}px`}>
<Grid container gap="1.5rem">
<Input label={t('worker.signUpForm.fields.email')} name="email" />
<Password
label={t('worker.signUpForm.fields.password')}
Expand Down
2 changes: 0 additions & 2 deletions packages/apps/human-app/frontend/src/shared/consts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { JobTypes } from '@/smart-contracts/EthKVStore/config';

export const JOB_TYPES = Object.values(JobTypes);

export const MAX_INPUT_WIDTH = 376;
Loading