-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
protected routes and protected layout initial commit
- Loading branch information
Showing
12 changed files
with
114 additions
and
115 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from "react"; | ||
import { Outlet } from "react-router-dom"; | ||
|
||
type PropsType = { | ||
children?: React.ReactNode; | ||
}; | ||
|
||
export const AppLayout = ({ children }: PropsType) => { | ||
return ( | ||
<div> | ||
<div>Navigation</div> | ||
<div> | ||
<Outlet /> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,15 @@ | ||
import React from "react"; | ||
import { Navigate, Outlet } from "react-router-dom"; | ||
|
||
import { identify } from "@helpers"; | ||
import { useAuthStore } from "@/modules/global/auth/useAuthStore"; | ||
|
||
export const ProtectedRoute = () => { | ||
const { isLoggedIn } = useAuthStore<IAuthStore>(identify); | ||
|
||
if (!isLoggedIn) { | ||
return <Navigate to="/login" />; | ||
} | ||
|
||
return <Outlet />; | ||
}; |
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
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,9 +1,17 @@ | ||
import { InjectionToken } from "@/constants/injection-token"; | ||
import { useController } from "@/utils/hooks/useController"; | ||
import React from "react"; | ||
|
||
export const Login = () => { | ||
const { loginClicked } = useController<IAuthController>( | ||
InjectionToken.IAuthController | ||
); | ||
|
||
return ( | ||
<div> | ||
<button>Login</button> | ||
<input type="text" /> | ||
<input type="password" /> | ||
<button onClick={loginClicked}>Login</button> | ||
</div> | ||
); | ||
}; |
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 @@ | ||
export const identify = <T>(x: T): T => x; |
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