Skip to content
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
2 changes: 1 addition & 1 deletion packages/apps/human-app/frontend/src/api/auth-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jwtDecode } from 'jwt-decode';
import { type SignInDto } from '@/modules/signin/worker/schemas';
import { type SignInDto } from '@/modules/signin/schemas';
import { browserAuthProvider } from '@/shared/contexts/browser-auth-provider';
import {
type AuthTokensSuccessResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from './http-api-client';
import { AuthService, type AuthProvider } from './auth-service';

export class AuthorizedHttpApiClient extends HttpApiClient {
class AuthorizedHttpApiClient extends HttpApiClient {
constructor(
baseUrl: string,
private readonly authProvider: AuthProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Paper, Button } from '@mui/material';
import { Paper, Button, Typography } from '@mui/material';

import { routerPaths } from '@/router/router-paths';

Expand All @@ -21,7 +21,7 @@ export function SignInSection() {
gap: 2,
}}
>
<Button
{/* <Button
component={Link}
to={routerPaths.signUp}
variant="contained"
Expand All @@ -30,7 +30,7 @@ export function SignInSection() {
fullWidth
>
{t('homepage.signUp')}
</Button>
</Button> */}
<Button
component={Link}
to={routerPaths.signIn}
Expand All @@ -41,6 +41,9 @@ export function SignInSection() {
>
{t('homepage.signIn')}
</Button>
<Typography variant="body2" sx={{ textAlign: 'center' }}>
{t('homepage.signUpClosed')}
</Typography>
</Paper>
);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type SubmitEvent } from 'react';
import { FormProvider, useForm } from 'react-hook-form';
import { Box, Divider, Grid, Link as MuiLink, Typography } from '@mui/material';
import { Box, Grid, Link as MuiLink } from '@mui/material';
import { zodResolver } from '@hookform/resolvers/zod';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
Expand All @@ -11,7 +11,7 @@ import { Password } from '@/shared/components/data-entry/password';
import { useResetMutationErrors } from '@/shared/hooks/use-reset-mutation-errors';
import { HCaptchaForm } from '@/shared/components/hcaptcha';
import { routerPaths } from '@/router/router-paths';
import { type SignInDto, signInDtoSchema } from './schemas';
import { type SignInDto, signInDtoSchema } from '../schemas';

interface SignInFormProps {
onSubmit: (data: SignInDto) => void;
Expand Down Expand Up @@ -47,14 +47,10 @@ export function SignInForm({
<FormProvider {...methods}>
<form onSubmit={handleSubmit}>
<Grid container sx={{ gap: 3 }}>
<Input
fullWidth
label={t('worker.signInForm.fields.email')}
name="email"
/>
<Input fullWidth label={t('signInForm.fields.email')} name="email" />
<Password
fullWidth
label={t('worker.signInForm.fields.password')}
label={t('signInForm.fields.password')}
name="password"
/>
<Box sx={{ width: '100%' }}>
Expand All @@ -67,7 +63,7 @@ export function SignInForm({
textDecoration: 'underline',
}}
>
{t('worker.signInForm.forgotPassword')}
{t('signInForm.forgotPassword')}
</MuiLink>
</Box>
<HCaptchaForm error={error} name="h_captcha_token" />
Expand All @@ -78,9 +74,9 @@ export function SignInForm({
fullWidth
loading={isLoading}
>
{t('worker.signInForm.submitBtn')}
{t('signInForm.submitBtn')}
</Button>
<Box sx={{ position: 'relative', width: '100%' }}>
{/* <Box sx={{ position: 'relative', width: '100%' }}>
<Divider sx={{ bgcolor: 'border.main' }} />
<Typography
variant="body2"
Expand All @@ -93,7 +89,7 @@ export function SignInForm({
fontWeight: 700,
}}
>
{t('worker.signInForm.or')}
{t('signInForm.or')}
</Typography>
</Box>
<Box
Expand All @@ -108,7 +104,7 @@ export function SignInForm({
}}
>
<Typography variant="body2" sx={{ color: 'text.auxiliary200' }}>
{t('worker.signInForm.dontHaveAccount')}
{t('signInForm.dontHaveAccount')}
</Typography>{' '}
<MuiLink
component={Link}
Expand All @@ -120,9 +116,9 @@ export function SignInForm({
textDecoration: 'underline',
}}
>
{t('worker.signInForm.signUp')}
{t('signInForm.signUp')}
</MuiLink>
</Box>
</Box> */}
</Grid>
</form>
</FormProvider>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMutation } from '@tanstack/react-query';
import { env } from '@/shared/env';
import { AuthService, HttpApiClient } from '@/api';
import { useAuth } from '@/modules/auth/hooks/use-auth';
import { type SignInDto } from './schemas';
import { type SignInDto } from '../schemas';

function signInMutationFn(data: SignInDto) {
const httpClient = new HttpApiClient(env.VITE_API_URL);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useEffect } from 'react';

import { browserAuthProvider } from '@/shared/contexts/browser-auth-provider';
import { useSignInMutation } from './use-sign-in-mutation';
import { type SignInDto } from './schemas';
import { type SignInDto } from '../schemas';

export function useSignIn() {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Box, Grid, Typography } from '@mui/material';

import { getErrorMessageForError } from '@/shared/errors';
import { ApiClientError } from '@/api';
import { useSignIn } from './use-sign-in';
import { SignInForm } from './sign-in-form';
import { useSignIn } from './hooks/use-sign-in';
import { SignInForm } from './components/sign-in-form';
import signInImage from '@/assets/background-images/signin-background.png';
import {
TopNotificationType,
Expand All @@ -23,7 +23,7 @@ function formattedSignInErrorMessage(
unknownError: unknown
): string | undefined {
if (unknownError instanceof ApiClientError && unknownError.status === 401) {
return t('worker.signInForm.errors.invalidCredentials');
return t('signInForm.errors.invalidCredentials');
}
}

Expand Down Expand Up @@ -134,7 +134,7 @@ export function SignInPage() {
variant="h4"
sx={{ color: 'text.auxiliary100' }}
>
{t('worker.signInForm.title')}
{t('signInForm.title')}
</Typography>
</Box>
<SignInForm
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiClientError, humanAppApiClient } from '@/api';
import { type SignUpDto } from '../worker/schema';
import { type SignUpDto } from '../schema';

const signUpPath = '/auth/signup';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from 'react';
import { useEffect, type SubmitEvent } from 'react';
import { FormProvider, useForm } from 'react-hook-form';
import { Link as RouterLink, useNavigate } from 'react-router-dom';
import { zodResolver } from '@hookform/resolvers/zod';
Expand All @@ -13,9 +13,9 @@ import { env } from '@/shared/env';
import { getErrorMessageForError } from '@/shared/errors';
import { HCaptchaForm } from '@/shared/components/hcaptcha';
import { useResetMutationErrors } from '@/shared/hooks/use-reset-mutation-errors';
import { useSignUpWorker } from '@/modules/signup/worker/hooks/use-sign-up-worker';
import { useSignUpWorker } from './hooks/use-sign-up-worker';
import { ApiClientError } from '@/api';
import { signUpDtoSchema } from '../schema';
import { signUpDtoSchema } from './schema';
import signUpImage from '@/assets/background-images/signup-background.png';
import { BackButton } from '@/shared/components/ui/page-card/back-button';
import { routerPaths } from '@/router/router-paths';
Expand All @@ -28,7 +28,7 @@ import { useColorMode } from '@/shared/contexts/color-mode';

function handleSignupError(unknownError: unknown) {
if (unknownError instanceof ApiClientError && unknownError.status === 409) {
return t('worker.signUpForm.errors.emailTaken');
return t('signUpForm.errors.emailTaken');
}
}

Expand Down Expand Up @@ -65,7 +65,7 @@ export function SignUpPage() {
navigate(-1);
};

const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
const handleSubmit = (event: SubmitEvent) => {
void methods.handleSubmit(signUp)(event);
};

Expand Down Expand Up @@ -106,22 +106,19 @@ export function SignUpPage() {
variant="h4"
sx={{ color: 'text.auxiliary100' }}
>
{t('worker.signUpForm.title')}
{t('signUpForm.title')}
</Typography>
</Box>
<FormProvider {...methods}>
<form onSubmit={handleSubmit}>
<Grid container sx={{ gap: 3 }}>
<Input
label={t('worker.signUpForm.fields.email')}
name="email"
/>
<Input label={t('signUpForm.fields.email')} name="email" />
<Password
label={t('worker.signUpForm.fields.password')}
label={t('signUpForm.fields.password')}
name="password"
/>
<Password
label={t('worker.signUpForm.fields.confirmPassword')}
label={t('signUpForm.fields.confirmPassword')}
name="confirmPassword"
/>
<Typography
Expand Down Expand Up @@ -149,7 +146,7 @@ export function SignUpPage() {
/>
),
}}
i18nKey="worker.signUpForm.termsOfServiceAndPrivacyPolicy"
i18nKey="signUpForm.termsOfServiceAndPrivacyPolicy"
/>
</Typography>
<HCaptchaForm error={error} name="hCaptchaToken" />
Expand All @@ -161,7 +158,7 @@ export function SignUpPage() {
fullWidth
loading={isLoading}
>
{t('worker.signUpForm.submitBtn')}
{t('signUpForm.submitBtn')}
</Button>
<Box sx={{ position: 'relative', width: '100%' }}>
<Divider sx={{ bgcolor: 'border.main' }} />
Expand All @@ -176,7 +173,7 @@ export function SignUpPage() {
fontWeight: 700,
}}
>
{t('worker.signUpForm.or')}
{t('signUpForm.or')}
</Typography>
</Box>
<Box
Expand All @@ -194,7 +191,7 @@ export function SignUpPage() {
variant="body2"
sx={{ color: 'text.auxiliary200' }}
>
{t('worker.signUpForm.alreadyHaveAccount')}
{t('signUpForm.alreadyHaveAccount')}
</Typography>{' '}
<Link
component={RouterLink}
Expand All @@ -206,7 +203,7 @@ export function SignUpPage() {
textDecoration: 'underline',
}}
>
{t('worker.signUpForm.signIn')}
{t('signUpForm.signIn')}
</Link>
</Box>
</Grid>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
// function
import { ChainId } from '@human-protocol/sdk/src/enums';
import { NETWORKS } from '@human-protocol/sdk/src/constants';
import { env } from '@/shared/env';
import {
MainnetContracts,
TestnetContracts,
type ContractsAddresses,
} from '@/modules/smart-contracts/contracts';

export interface Chain {
interface Chain {
explorerUrl: string;
name: string;
chainId: number;
Expand All @@ -23,22 +22,22 @@ export type ChainWithAddresses = Chain & {
addresses: ContractsAddresses;
};

export const TestnetChainsIds = [
const TestnetChainsIds = [
ChainId.POLYGON_AMOY,
ChainId.SEPOLIA,
ChainId.BSC_TESTNET,
ChainId.LOCALHOST,
] as const;

export const MainnetChainsIds = [
const MainnetChainsIds = [
ChainId.POLYGON,
ChainId.MAINNET,
ChainId.BSC_MAINNET,
ChainId.ALL,
] as const;

export type TestnetNarrow = Exclude<ChainId, (typeof MainnetChainsIds)[number]>;
export type MainnetNarrow = Exclude<ChainId, (typeof TestnetChainsIds)[number]>;
type TestnetNarrow = Exclude<ChainId, (typeof MainnetChainsIds)[number]>;
type MainnetNarrow = Exclude<ChainId, (typeof TestnetChainsIds)[number]>;

export const TestnetChains: readonly ChainWithAddresses[] = [
{
Expand Down Expand Up @@ -87,28 +86,3 @@ function getChainConfigsForChainIds<T extends TestnetNarrow | MainnetNarrow>(
}
return result;
}

const handleFilterChains = (
chainsArr: ChainWithAddresses[],
chainIdsEnabled: number[]
) => {
return chainsArr.filter((chain) =>
chainIdsEnabled.some((el) => el === chain.chainId)
);
};

export const getTestnetChainsEnabled = (chainIdsEnabled: number[]) => {
return handleFilterChains(AllTestnetsChains, chainIdsEnabled);
};

export const getMainnetChainsEnabled = (chainIdsEnabled: number[]) => {
return handleFilterChains(AllMainnetChains, chainIdsEnabled);
};

export const getEnabledChainsByUiConfig = (
chainIdsEnabled: number[]
): Chain[] =>
(env.VITE_NETWORK === 'mainnet'
? getMainnetChainsEnabled(chainIdsEnabled)
: getTestnetChainsEnabled(chainIdsEnabled)
).map(({ addresses: _, ...chainData }) => chainData);
Loading
Loading