diff --git a/client/.env.local.example b/client/.env.local.example
new file mode 100644
index 000000000..6d7f792bc
--- /dev/null
+++ b/client/.env.local.example
@@ -0,0 +1,2 @@
+NEXT_PUBLIC_GOOGLE_API_OAUTH_TOKEN=
+NEXT_PUBLIC_GITHUB_API_OAUTH_TOKEN=
diff --git a/client/.eslintrc.json b/client/.eslintrc.json
index bec4c12cb..4aa249ea2 100644
--- a/client/.eslintrc.json
+++ b/client/.eslintrc.json
@@ -5,13 +5,14 @@
"jest": true
},
"parser": "@typescript-eslint/parser",
- "plugins": ["@typescript-eslint"],
+ "plugins": ["@typescript-eslint", "@tanstack/query"],
"extends": [
"next",
"next/core-web-vitals",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
- "plugin:storybook/recommended"
+ "plugin:storybook/recommended",
+ "plugin:@tanstack/eslint-plugin-query/recommended"
],
"globals": {
"React": "readonly"
@@ -37,6 +38,9 @@
}
],
"@typescript-eslint/no-explicit-any": "error",
- "@typescript-eslint/no-var-requires": "off"
+ "@typescript-eslint/no-var-requires": "off",
+ // query rules
+ "@tanstack/query/exhaustive-deps": "error",
+ "@tanstack/query/stable-query-client": "error"
}
}
diff --git a/client/package.json b/client/package.json
index 741197097..e15fadcc6 100644
--- a/client/package.json
+++ b/client/package.json
@@ -24,17 +24,21 @@
"dependencies": {
"@react-oauth/google": "^0.11.1",
"@storybook/addon-styling": "^1.3.6",
- "@tanstack/react-query": "beta",
+ "@tanstack/react-query": "^5.0.0",
+ "@tanstack/react-query-devtools": "^5.0.1",
"@teameights/types": "^1.1.24",
+ "@types/js-cookie": "^3.0.5",
"@types/lodash.debounce": "^4.0.7",
"@types/node": "20.4.8",
"@types/react": "18.2.18",
"@types/react-dom": "18.2.7",
"@uiball/loaders": "^1.3.0",
"add": "^2.0.6",
+ "axios": "^1.5.1",
"clsx": "^2.0.0",
"eslint": "8.46.0",
"eslint-config-next": "13.4.12",
+ "js-cookie": "^3.0.5",
"lodash.debounce": "^4.0.8",
"next": "13.4.12",
"qs": "^6.11.2",
@@ -67,6 +71,7 @@
"@storybook/nextjs": "7.2.1",
"@storybook/react": "7.2.1",
"@storybook/testing-library": "0.2.0",
+ "@tanstack/eslint-plugin-query": "^5.0.0",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.5",
diff --git a/client/public/images/team8s.png b/client/public/images/team8s.png
new file mode 100644
index 000000000..0a34f88af
Binary files /dev/null and b/client/public/images/team8s.png differ
diff --git a/client/src/app/(auth)/layout.tsx b/client/src/app/(auth)/layout.tsx
index e4f362337..5f364dfae 100644
--- a/client/src/app/(auth)/layout.tsx
+++ b/client/src/app/(auth)/layout.tsx
@@ -7,8 +7,9 @@ import { LogoBig, LogoSmall } from '@/shared/assets';
import { Flex, Tabs } from '@/shared/ui';
import styles from './styles.module.scss';
import { useGetScreenWidth } from '@/shared/lib';
+import Image from 'next/image';
-const baseLayouts = ['confirmation', 'expired', 'success'];
+const baseLayouts = ['confirmation', 'expired', 'success', 'processing'];
export default function AuthLayout({ children }: { children: ReactNode }) {
const router = useRouter();
@@ -30,9 +31,7 @@ export default function AuthLayout({ children }: { children: ReactNode }) {
{width > 420 ? : }
-
-
-
+
);
@@ -59,7 +58,15 @@ export default function AuthLayout({ children }: { children: ReactNode }) {
{children}
-
+
);
diff --git a/client/src/app/(auth)/login/page.tsx b/client/src/app/(auth)/login/page.tsx
index 160eda5fa..e4d91d126 100644
--- a/client/src/app/(auth)/login/page.tsx
+++ b/client/src/app/(auth)/login/page.tsx
@@ -9,6 +9,7 @@ import { Button, Flex, Input, InputPassword, Typography } from '@/shared/ui';
import { useState } from 'react';
import styles from '../shared.module.scss';
import { Github, Google } from '@/shared/assets';
+import { useLogin } from '@/entities/session';
interface LoginProps {
email: string;
@@ -19,6 +20,7 @@ export default function LoginPage() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const router = useRouter();
+ const { mutate: loginUser, isPending } = useLogin();
const {
register,
@@ -27,11 +29,17 @@ export default function LoginPage() {
} = useForm();
const login = useGoogleLogin({
- onSuccess: codeResponse => console.log(codeResponse),
+ // issue: https://github.com/MomenSherif/react-oauth/issues/12
+ onSuccess: codeResponse => router.push(`/proxy/google?code=${codeResponse.code}`),
flow: 'auth-code',
});
- const onSubmit: SubmitHandler = data => console.log(data);
+ const loginWithGit = () =>
+ router.push(
+ `https://github.com/login/oauth/authorize?client_id=${process.env.NEXT_PUBLIC_GITHUB_API_OAUTH_TOKEN}`
+ );
+
+ const onSubmit: SubmitHandler = data => loginUser(data);
return (
);
diff --git a/client/src/app/(auth)/signup/page.tsx b/client/src/app/(auth)/signup/page.tsx
index b86654a51..0d113c4ac 100644
--- a/client/src/app/(auth)/signup/page.tsx
+++ b/client/src/app/(auth)/signup/page.tsx
@@ -6,6 +6,8 @@ import { Github, Google } from '@/shared/assets';
import { SubmitHandler, useForm } from 'react-hook-form';
import { Button, Flex, Input, InputPassword, Typography } from '@/shared/ui';
import styles from '../shared.module.scss';
+import { useRouter } from 'next/navigation';
+import { useRegister } from '@/entities/session';
interface SignupProps {
email: string;
@@ -17,9 +19,11 @@ export default function SignupPage() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [repeatPassword, setRepeatPassword] = useState('');
+ const router = useRouter();
+ const { mutate: registerUser } = useRegister();
const login = useGoogleLogin({
- onSuccess: codeResponse => console.log(codeResponse),
+ onSuccess: codeResponse => router.push(`/proxy/google?code=${codeResponse.code}`),
flow: 'auth-code',
});
@@ -29,7 +33,13 @@ export default function SignupPage() {
formState: { errors },
} = useForm();
- const onSubmit: SubmitHandler = data => console.log(data);
+ const loginWithGit = () =>
+ router.push(
+ `https://github.com/login/oauth/authorize?client_id=${process.env.NEXT_PUBLIC_GITHUB_API_OAUTH_TOKEN}`
+ );
+
+ const onSubmit: SubmitHandler = data =>
+ registerUser({ email: data.email, password: data.password });
return (