-
{t('login')}
-
-
-
-
- {t('noAccount')}{' '}
-
- {t('register')}
-
-
+
+
+ {/* @ts-expect-error - SmoothCorners is not typed */}
+
+
+
+
+ Castled
+
+
Get Started
+
+
Sign-in and start analysing your chess games
+
+
+
+
+
+ {t('login')}
+ Sign in to an existing account
+
+
+ {/*
*/}
+ {/*
*/}
+
+ {/*
*/}
+ {/*
*/}
- {/*
*/}
- {/*
*/}
+
*/}
+
(
+
+
+
+
+
+
+
+ )}
+ />
+
+
+
+
+
+
+
+
+ {t('noAccount')}{' '}
+
+ {t('register')}
+
+
+
+
+
);
+
+ // return (
+ //
+ //
+ //
{t('login')}
+ //
+ //
+ //
+ //
+ // {t('noAccount')}{' '}
+ //
+ // {t('register')}
+ //
+ //
+ //
+ // {/*
*/}
+ // {/*
*/}
+ //
+ // {/*
*/}
+ // {/*
*/}
+ //
+ //
+ // );
};
diff --git a/src/pages/oauth.tsx b/src/pages/oauth.tsx
new file mode 100644
index 0000000..4e6f7d6
--- /dev/null
+++ b/src/pages/oauth.tsx
@@ -0,0 +1,35 @@
+import { useAuthStore } from '@/store/auth';
+import { Icon } from '@iconify/react/dist/iconify.js';
+import { useEffect } from 'react';
+import { useNavigate } from 'react-router-dom';
+
+export const Oauth = () => {
+ const { setUser, setAccessToken, setRefreshToken } = useAuthStore();
+ const navigate = useNavigate();
+
+ function getCookie(key: string) {
+ var b = document.cookie.match('(^|;)\\s*' + key + '\\s*=\\s*([^;]+)');
+ return b ? b.pop() : '';
+ }
+
+ useEffect(() => {
+ const access = getCookie('lichess_access_token') as string;
+ const refresh = getCookie('lichess_refresh_token') as string;
+ const user = getCookie('lichess_user') as string;
+
+ setUser(JSON.parse(decodeURIComponent(user)));
+ setAccessToken(access);
+ setRefreshToken(refresh);
+
+ navigate('/');
+ }, []);
+
+ return (
+
+ );
+};
diff --git a/src/pages/register/register.tsx b/src/pages/register/register.tsx
index 75ebb17..b9a21eb 100644
--- a/src/pages/register/register.tsx
+++ b/src/pages/register/register.tsx
@@ -10,8 +10,9 @@ import { useNavigate, Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { track } from '@vercel/analytics';
import { useDeviceData } from 'react-device-detect';
-// import lichessIcon from '@/assets/icons/lichess.svg?url';
-// import chessComIcon from '@/assets/icons/chesscom.svg?url';
+import { Label } from '@/components/ui/label.tsx';
+import { SmoothCorners } from 'react-smooth-corners';
+import lichessIcon from '@/assets/icons/lichess.svg?url';
/**
* Register component renders a registration form for new users.
@@ -65,108 +66,167 @@ export const Register = () => {
navigate('/');
/* eslint-disable @typescript-eslint/no-explicit-any */
} catch (error: any) {
- console.error(
- 'Failed to register:',
- error,
- // error.response.data.message.map((e: any) => e.constraints),
- );
+ console.error('Failed to register:', error);
- // TODO: implement error display -> need types
+ const errors: { property: string; value: string; constraints: Record
}[] =
+ error.response.data.message;
- // const errors: { property: string; value: string; constraints: Record }[] =
- // error.response.data.message;
- //
- // errors.forEach(({ property, constraints }) => {
- // form.setError(property as keyof typeof data, {
- // type: 'server',
- // message: constraints[Object.keys(constraints)[0]],
- // });
- // });
+ errors.forEach(({ property, constraints }) => {
+ form.setError(property as keyof typeof data, {
+ type: 'server',
+ message: constraints[Object.keys(constraints)[0]],
+ });
+ });
}
};
return (
-