-
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.
Add persistent storage ,login and dashboard
- Loading branch information
Showing
20 changed files
with
296 additions
and
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
"use client"; | ||
import { Provider } from "react-redux"; | ||
import store from "./redux/store"; | ||
import store, { persistor } from "./redux/store"; | ||
import { PersistGate } from "redux-persist/integration/react"; | ||
|
||
export default function Client({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<Provider store={store}> | ||
{children} | ||
<PersistGate loading={null} persistor={persistor}> | ||
{children} | ||
</PersistGate> | ||
</Provider> | ||
); | ||
} |
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 API_URL = "https://api.port0.iiitk.in"; |
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,49 @@ | ||
"use client"; | ||
import NavBar from "../components/NavBar"; | ||
import DarkModeStatus from "../redux/status/darkModeStatus"; | ||
import UserDataStatus from "../redux/status/userDataStatus"; | ||
import Details from "./Details"; | ||
|
||
const HomePage = () => { | ||
const details: any = UserDataStatus(); | ||
const name = `${details.UserData.FormData.firstName} ${details.UserData.FormData.lastName}`; | ||
const dark = DarkModeStatus(); | ||
return ( | ||
<div | ||
className={ | ||
dark | ||
? "h-screen overflow-auto flex flex-col bg-gradient-to-b from-[#020024] to-[#020024] text-white transition-all duration-500 ease-in" | ||
: "h-screen overflow-auto flex flex-col bg-gradient-to-b from-amber-100 to-white text-black transition-all duration-500 ease-in" | ||
} | ||
> | ||
<NavBar /> | ||
<div> | ||
<h1 | ||
className={ | ||
dark | ||
? "md:text-4xl text-4xl ml-5 my-10 font-extrabold" | ||
: "md:text-4xl text-4xl ml-5 my-10 font-extrabold text-red-900" | ||
} | ||
> | ||
Welcome, {name} | ||
</h1> | ||
<div> | ||
<Details /> | ||
<div className="flex justify-center align-center mt-5"> | ||
<button | ||
className={ | ||
dark | ||
? "text-white text-xl bg-slate-800 border-0 p-2 rounded-lg flex align-center justify-center mb-10" | ||
: "text-xl bg-red hover:bg-beige-800 border border-red-900 p-2 rounded-lg flex align-center justify-center mb-10" | ||
} | ||
> | ||
Edit Details | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HomePage; |
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,48 +1,24 @@ | ||
"use client"; | ||
import NavBar from "../components/NavBar"; | ||
import DarkModeStatus from "../redux/status/darkModeStatus"; | ||
import LoggedInStatus from "../redux/status/loggedInStatus"; | ||
import UserDataStatus from "../redux/status/userDataStatus"; | ||
import Details from "./Details"; | ||
import HomePage from "./HomePage"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
const Dashboard = () => { | ||
const name = "John Doe"; | ||
const dark = DarkModeStatus(); | ||
|
||
return ( | ||
<div | ||
className={ | ||
dark | ||
? "h-screen overflow-auto flex flex-col bg-gradient-to-b from-[#020024] to-[#020024] text-white transition-all duration-500 ease-in" | ||
: "h-screen overflow-auto flex flex-col bg-gradient-to-b from-amber-100 to-white text-black transition-all duration-500 ease-in" | ||
} | ||
> | ||
<NavBar /> | ||
<div> | ||
<h1 | ||
className={ | ||
dark | ||
? "md:text-4xl text-4xl ml-5 my-10 font-extrabold" | ||
: "md:text-4xl text-4xl ml-5 my-10 font-extrabold text-red-900" | ||
} | ||
> | ||
Welcome, {name} | ||
</h1> | ||
<div> | ||
<Details /> | ||
<div className="flex justify-center align-center mt-5"> | ||
<button | ||
className={ | ||
dark | ||
? "text-white text-xl bg-slate-800 border-0 p-2 rounded-lg flex align-center justify-center mb-10" | ||
: "text-xl bg-red hover:bg-beige-800 border border-red-900 p-2 rounded-lg flex align-center justify-center mb-10" | ||
} | ||
> | ||
Edit Details | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
const router = useRouter(); | ||
const logInStatus = LoggedInStatus(); | ||
if (logInStatus) { | ||
return ( | ||
<> | ||
<HomePage />; | ||
</> | ||
); | ||
} else { | ||
router.push("/login"); | ||
} | ||
}; | ||
|
||
export default 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const { convertFromAES } = require("@harshiyer/json-crypto"); | ||
export default function decodeVault(vault: any) { | ||
const { aes256Bit, salt, password } = vault; | ||
const decryptedData: object = new convertFromAES(aes256Bit, password, salt); | ||
return decryptedData; | ||
} |
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,14 +1,16 @@ | ||
import { combineReducers } from "redux"; | ||
import darkModeReducer from "./darkMode/darkModeReducers"; | ||
import emailReducer from "./email/emailReducers"; | ||
import { combineReducers } from "redux"; | ||
import formDataReducer from "./formData/formDataReducers"; | ||
import userDataReducer from "./userData/userDataReducer"; | ||
import logInReducer from "./loggedIn/loggedInActions"; | ||
|
||
const allReducers = combineReducers({ | ||
darkMode: darkModeReducer, | ||
email: emailReducer, | ||
formData: formDataReducer, | ||
userData: userDataReducer, | ||
isLoggedIn: logInReducer, | ||
}); | ||
|
||
export default allReducers; |
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,19 @@ | ||
import { CHANGE_LOG_STATUS } from "./loggedInTypes"; | ||
|
||
const initialState = { | ||
isLoggedIn: false, | ||
}; | ||
|
||
const logInReducer = (state = initialState, action: { type: any }) => { | ||
switch (action.type) { | ||
case CHANGE_LOG_STATUS: | ||
return { | ||
...state, | ||
isLoggedIn: !state.isLoggedIn, | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default logInReducer; |
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,7 @@ | ||
import { CHANGE_LOG_STATUS } from "./loggedInTypes"; | ||
|
||
export const updateData = (data: object) => { | ||
return { | ||
type: CHANGE_LOG_STATUS, | ||
}; | ||
}; |
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 CHANGE_LOG_STATUS = "CHANGE_LOG_STATUS"; |
Oops, something went wrong.