-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(profile): 🎉 update profile sub-pages and interfaces
- Loading branch information
1 parent
3b11a24
commit 47d5950
Showing
13 changed files
with
167 additions
and
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, { createContext, useState } from "react"; | ||
import { Itabs, ProfileActiveTab } from "../interfaces/profileInterfaces"; | ||
|
||
export const ProfileContext: any = createContext<any>(null); | ||
|
||
// eslint-disable-next-line | ||
export default ({ children }: any) => { | ||
const [activeTab, setActiveTab] = useState<ProfileActiveTab>("Overview"); | ||
|
||
const tabs: Itabs = [ | ||
"Overview", | ||
"Profile Info", | ||
"Connected Apps", | ||
"Email Preferences", | ||
"Notifications", | ||
"Change Password", | ||
"Deactivate Account", | ||
]; | ||
|
||
return ( | ||
<ProfileContext.Provider | ||
value={{ | ||
tabs, | ||
activeTab, | ||
setActiveTab, | ||
}} | ||
> | ||
{children} | ||
</ProfileContext.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
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,11 @@ | ||
import { useContext } from "react"; | ||
import { IuseProfile } from "../interfaces/profileInterfaces"; | ||
import { ProfileContext } from "../contexts/ProfileContext"; | ||
|
||
const useProfile = () => { | ||
const useProfile: IuseProfile = useContext(ProfileContext); | ||
|
||
return useProfile; | ||
}; | ||
|
||
export default useProfile; |
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,24 @@ | ||
export interface IuseProfile { | ||
activeTab: ProfileActiveTab; | ||
setActiveTab: React.Dispatch<React.SetStateAction<ProfileActiveTab>>; | ||
tabs: Itabs; | ||
} | ||
|
||
export type Itabs = [ | ||
"Overview", | ||
"Profile Info", | ||
"Connected Apps", | ||
"Email Preferences", | ||
"Notifications", | ||
"Change Password", | ||
"Deactivate Account" | ||
]; | ||
|
||
export type ProfileActiveTab = | ||
| "Overview" | ||
| "Profile Info" | ||
| "Connected Apps" | ||
| "Email Preferences" | ||
| "Notifications" | ||
| "Change Password" | ||
| "Deactivate Account"; |
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,36 @@ | ||
import { Fragment, ReactElement } from "react"; | ||
import ProfileOverview from "../components/ProfileOverview/ProfileOverview"; | ||
import ProfileInfo from "../components/ProfileInfo/ProfileInfo"; | ||
import ProfileConnectedApps from "../components/ProfileConnectedApps/ProfileConnectedApps"; | ||
import ProfileEmailPreferances from "../components/ProfileEmailPreferances/ProfileEmailPreferances"; | ||
import ProfileNotifications from "../components/ProfileNotifications/ProfileNotifications"; | ||
import ProfileChangePassword from "../components/ProfileChangePassword/ProfileChangePassword"; | ||
import ProfileDeactivate from "../components/ProfileDeactivate/ProfileDeactivate"; | ||
import useProfile from "../hooks/useProfile"; | ||
|
||
export default function ProfileSubPageLayout(): ReactElement { | ||
const { activeTab } = useProfile(); | ||
|
||
return ( | ||
<Fragment> | ||
{(() => { | ||
switch (activeTab) { | ||
case "Overview": | ||
return <ProfileOverview />; | ||
case "Profile Info": | ||
return <ProfileInfo className="col-span-2" />; | ||
case "Connected Apps": | ||
return <ProfileConnectedApps className="col-span-2" />; | ||
case "Email Preferences": | ||
return <ProfileEmailPreferances className="col-span-2" />; | ||
case "Notifications": | ||
return <ProfileNotifications className="col-span-2" />; | ||
case "Change Password": | ||
return <ProfileChangePassword className="col-span-2" />; | ||
case "Deactivate Account": | ||
return <ProfileDeactivate className="col-span-2" />; | ||
} | ||
})()} | ||
</Fragment> | ||
); | ||
} |
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,41 +1,12 @@ | ||
import React, { ReactElement, useState } from "react"; | ||
import React, { ReactElement } from "react"; | ||
import ProfileHeader from "../../components/ProfileHeader/ProfileHeader"; | ||
import ProfileConnectedApps from "../../components/ProfileConnectedApps/ProfileConnectedApps"; | ||
import ProfileInfo from "../../components/ProfileInfo/ProfileInfo"; | ||
import ProfileEmailPreferances from "../../components/ProfileEmailPreferances/ProfileEmailPreferances"; | ||
import ProfileDeactive from "../../components/ProfileDeactive/ProfileDeactive"; | ||
import ProfileNotifications from "../../components/ProfileNotifications/ProfileNotifications"; | ||
import ProfileChangePassword from "../../components/ProfileChangePassword/ProfileChangePassword"; | ||
import ProfileOverview from "../../components/ProfileOverview/ProfileOverview"; | ||
import ProfileSubPageLayout from "../../layouts/ProfileSubPageLayout"; | ||
|
||
export default function Profile(): ReactElement { | ||
const [activeTab, setActiveTab] = useState("Overview"); | ||
|
||
return ( | ||
<div className="grid grid-cols-2 gap-6"> | ||
<ProfileHeader | ||
className="col-span-2" | ||
activeTab={activeTab} | ||
handleChangeActiveTab={setActiveTab} | ||
/> | ||
{(() => { | ||
switch (activeTab) { | ||
case "Overview": | ||
return <ProfileOverview />; | ||
case "Profile Info": | ||
return <ProfileInfo className="col-span-2" />; | ||
case "Connected Apps": | ||
return <ProfileConnectedApps className="col-span-2" />; | ||
case "Email Preferances": | ||
return <ProfileEmailPreferances className="col-span-2" />; | ||
case "Notifications": | ||
return <ProfileNotifications className="col-span-2" />; | ||
case "Change Password": | ||
return <ProfileChangePassword className="col-span-2" />; | ||
case "Deactive Account": | ||
return <ProfileDeactive className="col-span-2" />; | ||
} | ||
})()} | ||
<ProfileHeader /> | ||
<ProfileSubPageLayout /> | ||
</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