-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
153 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
export * from './lib/auth'; | ||
export * from './lib/authorization'; | ||
export * from './lib/protected-route'; | ||
|
||
export * from './routes'; | ||
export * from './routes/Register'; | ||
export * from './routes/Login'; | ||
|
||
export * from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Navigate, useLocation } from 'react-router-dom'; | ||
|
||
import { useUser } from './auth'; | ||
|
||
export const ProtectedRoute = ({ children }: { children: React.ReactNode }) => { | ||
const user = useUser(); | ||
const location = useLocation(); | ||
|
||
if (!user.data) { | ||
return ( | ||
<Navigate to={`/auth/login?redirectTo=${encodeURIComponent(location.pathname)}`} replace /> | ||
); | ||
} | ||
|
||
return children; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useNavigate, useSearchParams } from 'react-router-dom'; | ||
|
||
import { Layout } from '../components/Layout'; | ||
import { LoginForm } from '../components/LoginForm'; | ||
|
||
export const Login = () => { | ||
export const LoginRoute = () => { | ||
const navigate = useNavigate(); | ||
const [searchParams] = useSearchParams(); | ||
const redirectTo = searchParams.get('redirectTo'); | ||
|
||
return ( | ||
<Layout title="Log in to your account"> | ||
<LoginForm onSuccess={() => navigate('/app')} /> | ||
<LoginForm | ||
onSuccess={() => navigate(`${redirectTo ? `${redirectTo}` : '/app'}`, { replace: true })} | ||
/> | ||
</Layout> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useNavigate, useSearchParams } from 'react-router-dom'; | ||
|
||
import { Layout } from '../components/Layout'; | ||
import { RegisterForm } from '../components/RegisterForm'; | ||
|
||
export const Register = () => { | ||
export const RegisterRoute = () => { | ||
const navigate = useNavigate(); | ||
const [searchParams] = useSearchParams(); | ||
const redirectTo = searchParams.get('redirectTo'); | ||
|
||
return ( | ||
<Layout title="Register your account"> | ||
<RegisterForm onSuccess={() => navigate('/app')} /> | ||
<RegisterForm | ||
onSuccess={() => navigate(`${redirectTo ? `${redirectTo}` : '/app'}`, { replace: true })} | ||
/> | ||
</Layout> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './types'; | ||
export * from './routes'; | ||
export * from './routes/Discussion'; | ||
export * from './routes/Discussions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './routes'; | ||
export * from './routes/Landing'; | ||
export * from './routes/NotFound'; | ||
export * from './routes/Dashboard'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
export const NotFound = () => { | ||
return <div>404</div>; | ||
import { Link } from '@/components/Elements'; | ||
|
||
export const NotFoundRoute = () => { | ||
return ( | ||
<div className="mt-52 flex flex-col items-center font-semibold"> | ||
<h1>404 - Not Found</h1> | ||
<p>Sorry, the page you are looking for does not exist.</p> | ||
<Link to="/" replace> | ||
Go to Home | ||
</Link> | ||
</div> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.