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

Ham 52 fix help button in worker profile #205

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 @@ -2,6 +2,7 @@ import { t } from 'i18next';
import type { BottomMenuItem } from '@/components/layout/protected/drawer-navigation';
import { HelpIcon, UserOutlinedIcon } from '@/components/ui/icons';
import { routerPaths } from '@/router/router-paths';
import { env } from '@/shared/env';

export const operatorDrawerBottomMenuItems: BottomMenuItem[] = [
{
Expand All @@ -11,7 +12,7 @@ export const operatorDrawerBottomMenuItems: BottomMenuItem[] = [
},
{
label: t('components.DrawerNavigation.help'),
link: routerPaths.homePage,
link: env.VITE_HUMAN_PROTOCOL_HELP_URL,
icon: <HelpIcon />,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
} from '@/components/layout/protected/drawer-navigation';
import { HelpIcon, UserOutlinedIcon, WorkIcon } from '@/components/ui/icons';
import { routerPaths } from '@/router/router-paths';
import { env } from '@/shared/env';

export const workerDrawerTopMenuItems = (
addressRegistered: boolean
Expand Down Expand Up @@ -47,7 +48,7 @@ export const workerDrawerBottomMenuItems: BottomMenuItem[] = [
},
{
label: t('components.DrawerNavigation.help'),
link: routerPaths.homePage,
link: env.VITE_HUMAN_PROTOCOL_HELP_URL,
icon: <HelpIcon />,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ export function OperatorSignIn() {
isError: isSignInMutationError,
error: signInMutationError,
} = useWeb3SignIn();
const { user } = useWeb3Auth();
const { user, signOut } = useWeb3Auth();
const modalWasOpened = useRef(false);

useEffect(() => {
signOut();
// eslint-disable-next-line react-hooks/exhaustive-deps -- ...
}, []);

useEffect(() => {
if (isConnected && modalWasOpened.current) {
signInMutation({ address, type: PrepareSignatureType.SignIn });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { t } from 'i18next';
import { Link } from 'react-router-dom';
import { useAuth } from '@/auth/use-auth';
import { Button } from '@/components/ui/button';
import { routerPaths } from '@/router/router-paths';

export function WorkerSignIn() {
const { user } = useAuth();

const redirectPath = user
? routerPaths.worker.profile
: routerPaths.worker.signIn;

return (
<Button
component={Link}
Expand All @@ -19,7 +12,7 @@ export function WorkerSignIn() {
sx={{
mb: '1.5625rem',
}}
to={redirectPath}
to={routerPaths.worker.signIn}
variant="contained"
>
{t('homepage.workerSignIn')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Grid, Typography } from '@mui/material';
import { zodResolver } from '@hookform/resolvers/zod';
import { useTranslation } from 'react-i18next';
import { t as i18NextT } from 'i18next';
import { Link, useNavigate } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { useEffect } from 'react';
import { PageCard } from '@/components/ui/page-card';
import { Input } from '@/components/data-entry/input';
Expand All @@ -29,14 +29,13 @@ function formattedSignInErrorMessage(unknownError: unknown) {

export function SignInWorkerPage() {
const { t } = useTranslation();
const { user } = useAuth();
const navigate = useNavigate();
const { user, signOut } = useAuth();

useEffect(() => {
if (user) {
navigate(routerPaths.worker.profile, { replace: true });
signOut();
}
}, [navigate, user]);
}, [signOut, user]);

const methods = useForm<SignInDto>({
defaultValues: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
import { t } from 'i18next';
import omit from 'lodash/omit';
import { Navigate } from 'react-router-dom';
import { useEffect } from 'react';
import type { SignUpDto } from '@/api/servieces/worker/sign-up';
import {
signUpDtoSchema,
Expand All @@ -32,7 +32,13 @@ function formattedSignUpErrorMessage(unknownError: unknown) {
}

export function SignUpWorkerPage() {
const { user } = useAuth();
const { user, signOut } = useAuth();

useEffect(() => {
if (user) {
signOut();
}
}, [signOut, user]);

const methods = useForm<SignUpDto>({
defaultValues: {
Expand All @@ -56,10 +62,6 @@ export function SignUpWorkerPage() {
signUpWorkerMutate(omit(data, ['confirmPassword']));
};

if (user) {
return <Navigate replace to={routerPaths.worker.profile} />;
}

return (
<PageCard
alert={
Expand Down
Loading