Skip to content

Commit 8888e1c

Browse files
committed
complete user auth with verification
1 parent 63cd6ec commit 8888e1c

File tree

22 files changed

+520
-198
lines changed

22 files changed

+520
-198
lines changed

package-lock.json

Lines changed: 83 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@radix-ui/react-label": "^2.0.2",
1717
"@radix-ui/react-popover": "^1.0.7",
1818
"@radix-ui/react-slot": "^1.0.2",
19+
"@radix-ui/react-toast": "^1.1.5",
1920
"@reduxjs/toolkit": "^2.2.2",
2021
"axios": "^1.6.8",
2122
"chartjs": "^0.3.24",
@@ -27,6 +28,7 @@
2728
"react-chartjs-2": "^5.2.0",
2829
"react-dom": "^18.2.0",
2930
"react-hook-form": "^7.51.2",
31+
"react-hot-toast": "^2.4.1",
3032
"react-redux": "^9.1.0",
3133
"react-router-dom": "^6.22.3",
3234
"tailwind-merge": "^2.2.1",

src/api/axiosclient.ts

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,14 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import { LoginData, ResultData, SingupData } from '@/types';
32
import axios from 'axios';
4-
import Cookies from 'js-cookie';
5-
class AxiosClient {
6-
private client;
7-
constructor() {
8-
this.client = axios.create({
9-
baseURL: String(import.meta.env.VITE_APP_BACKEND_BASE_URL),
10-
withCredentials: true,
11-
headers: {
12-
'Content-Type': 'application/json',
13-
'Access-Control-Allow-Origin': String(import.meta.env.VITE_APP_FRONTEND_BASE_URL),
14-
"Access-Control-Allow-Methods": "GET,PUT,POST,DELETE,PATCH,OPTIONS",
15-
'cache-control': 'private',
16-
'E-Tag': Cookies.get('auth_token'),
17-
},
18-
});
19-
}
20-
async post(url: string, content: LoginData | SingupData | ResultData) {
21-
try {
22-
const { data } = await this.client.post(url, content);
23-
return data;
24-
} catch (e: any) {
25-
if (import.meta.env.VITE_APP_ENV === "development") console.log(e.response.data);
26-
return e;
27-
}
28-
}
29-
async get(url: string) {
30-
try {
31-
const { data } = await this.client.get(url);
32-
return data;
33-
} catch (e: any) {
34-
if (import.meta.env.VITE_APP_ENV === "development") console.log(e.response.data);
35-
return e;
36-
}
37-
}
38-
async patch(url: string) {
39-
try {
40-
const { data } = await this.client.patch(url);
41-
return data;
42-
} catch (e: any) {
43-
if (import.meta.env.VITE_APP_ENV === "development") console.log(e.response.data);
44-
return e;
45-
}
46-
}
47-
}
48-
export const axiosClient = new AxiosClient();
3+
// import Cookies from 'js-cookie';
4+
export const axiosClient=axios.create({
5+
baseURL: String(import.meta.env.VITE_APP_BACKEND_BASE_URL),
6+
withCredentials: true,
7+
headers: {
8+
'Content-Type': 'application/json',
9+
'Access-Control-Allow-Origin': String(import.meta.env.VITE_APP_FRONTEND_BASE_URL),
10+
"Access-Control-Allow-Methods": "GET,PUT,POST,DELETE,PATCH,OPTIONS",
11+
// 'cache-control': 'private',
12+
// 'E-Tag': Cookies.get('auth_token'),
13+
},
14+
});

src/approutes.tsx

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { createBrowserRouter } from 'react-router-dom';
2-
import App from './App';
3-
import HomeScreen from './pages/Homepage/HomeScreen';
4-
import SignupScreen from './pages/SignupScreen/SignupScreen';
5-
import LoginScreen from './pages/LoginScreen/LoginScreen';
6-
import EmailVerification from './pages/EmailVerification/EmailVerification';
7-
import Protected from './components/Protected';
8-
import TypingTest from './pages/Typingtest/TypingTest';
9-
import DashBoard from './pages/Dashboard/DashBoard';
1+
import { createBrowserRouter } from "react-router-dom";
2+
import App from "./App";
3+
import HomeScreen from "./pages/Homepage/HomeScreen";
4+
import SignupScreen from "./pages/SignupScreen/SignupScreen";
5+
import LoginScreen from "./pages/LoginScreen/LoginScreen";
6+
import EmailVerification from "./pages/EmailVerification/EmailVerification";
7+
import Protected from "./components/Protected";
8+
import TypingTest from "./pages/Typingtest/TypingTest";
9+
import DashBoard from "./pages/Dashboard/DashBoard";
10+
import GettingStarted from "./pages/GettingStarted/GettingStarted";
11+
import Pricing from "./components/Pricing";
1012
const router = createBrowserRouter([
1113
{
1214
path: "/",
@@ -18,24 +20,58 @@ const router = createBrowserRouter([
1820
},
1921
{
2022
path: "/signup",
21-
element:<Protected authentication={false}><SignupScreen /></Protected>,
22-
},{
23+
element: (
24+
<Protected authentication={false}>
25+
<SignupScreen />
26+
</Protected>
27+
),
28+
},
29+
{
30+
path: "getting-started",
31+
element: <GettingStarted />,
32+
children: [
33+
{
34+
path: "/getting-started/:id",
35+
},
36+
],
37+
},
38+
{
2339
path: "/login",
24-
element: <Protected authentication={false}><LoginScreen /></Protected>,
40+
element: (
41+
<Protected authentication={false}>
42+
<LoginScreen />
43+
</Protected>
44+
),
2545
},
2646
{
2747
path: "/verify",
28-
element: <Protected authentication={true}><EmailVerification /></Protected>,
29-
}
48+
element: (
49+
<Protected authentication={true}>
50+
<EmailVerification />
51+
</Protected>
52+
),
53+
},
3054
],
3155
},
3256
{
33-
path:'/test',
34-
element:<Protected authentication={true}><TypingTest/></Protected>
57+
path: "/test",
58+
element: (
59+
<Protected authentication={true}>
60+
<TypingTest />
61+
</Protected>
62+
),
63+
},
64+
{
65+
path: "/dashboard/:id",
66+
element: (
67+
<Protected authentication={true}>
68+
<DashBoard />
69+
</Protected>
70+
),
3571
},
3672
{
37-
path:'/dashboard/:id',
38-
element:<Protected authentication={true}><DashBoard/></Protected>
39-
}
73+
path: "/pricing",
74+
element: <Pricing />,
75+
},
4076
]);
41-
export default router;
77+
export default router;

src/components/Footer.tsx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
import React from "react";
1+
import React, { useCallback } from "react";
22

33
const Footer: React.FC = () => {
4+
const scrolltop = useCallback(() => {
5+
window.scrollTo(0, 0);
6+
}, []);
47
return (
58
<footer className="bg-white rounded-lg shadow dark:bg-gray-900 m-4">
69
<div className="w-full max-w-screen-xl mx-auto p-4 md:py-8">
7-
<div className="sm:flex sm:items-center sm:justify-between">
8-
<a
9-
href="https://flowbite.com/"
10-
className="flex items-center mb-4 sm:mb-0 space-x-3 rtl:space-x-reverse"
10+
<div className="sm:flex sm:items-center sm:justify-center">
11+
<div
12+
className="flex items-center mb-4 sm:mb-0 space-x-3 rtl:space-x-reverse cursor-pointer"
13+
onClick={scrolltop}
1114
>
12-
<img
13-
src="https://flowbite.com/docs/images/logo.svg"
14-
className="h-8"
15-
alt="Flowbite Logo"
16-
/>
15+
<img src="/logo.png" className="h-8" alt="TypeSight Logo" />
1716
<span className="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">
18-
Flowbite
17+
TypeSight
1918
</span>
20-
</a>
21-
<ul className="flex flex-wrap items-center mb-6 text-sm font-medium text-gray-500 sm:mb-0 dark:text-gray-400">
19+
</div>
20+
{/* <ul className="flex flex-wrap items-center mb-6 text-sm font-medium text-gray-500 sm:mb-0 dark:text-gray-400">
2221
<li>
23-
<a href="#" className="hover:underline me-4 md:me-6">
22+
<a href="#about" className="hover:underline me-4 md:me-6">
2423
About
2524
</a>
2625
</li>
@@ -34,14 +33,14 @@ const Footer: React.FC = () => {
3433
Contact
3534
</a>
3635
</li>
37-
</ul>
36+
</ul> */}
3837
</div>
3938
<hr className="my-6 border-gray-200 sm:mx-auto dark:border-gray-700 lg:my-8" />
4039
<span className="block text-sm text-gray-500 sm:text-center dark:text-gray-400">
4140
© 2024{" "}
42-
<a href="https://flowbite.com/" className="hover:underline">
41+
<span className="hover:underline" onClick={scrolltop}>
4342
Typesight™
44-
</a>
43+
</span>
4544
. All Rights Reserved.
4645
</span>
4746
</div>

0 commit comments

Comments
 (0)