|
@@ -10,6 +10,7 @@ import React, { useState } from "react"
|
|
import { View } from "react-native"
|
|
import { View } from "react-native"
|
|
import { UserProfile } from "../../data/profiles"
|
|
import { UserProfile } from "../../data/profiles"
|
|
import { RegisterCredsValues } from "../../utils/RegistrationUtils"
|
|
import { RegisterCredsValues } from "../../utils/RegistrationUtils"
|
|
|
|
+import { ProfileAbout } from './ProfileSections/ProfileAbout'
|
|
import { ProfileInformation } from "./ProfileSections/ProfileInformation"
|
|
import { ProfileInformation } from "./ProfileSections/ProfileInformation"
|
|
import { ProfileLegal } from "./ProfileSections/ProfileLegal"
|
|
import { ProfileLegal } from "./ProfileSections/ProfileLegal"
|
|
import { ProfilePrefs } from "./ProfileSections/ProfilePrefs"
|
|
import { ProfilePrefs } from "./ProfileSections/ProfilePrefs"
|
|
@@ -29,6 +30,17 @@ interface ProfileSectionsProps {
|
|
deleteAccountStatus: string
|
|
deleteAccountStatus: string
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+type SectionName = "information" | "legal" | "prefs" | "subscription" | "skills" | "about" | 'none'
|
|
|
|
+
|
|
|
|
+interface SectionsCollapseState {
|
|
|
|
+ info: boolean,
|
|
|
|
+ prefs: boolean,
|
|
|
|
+ legal: boolean,
|
|
|
|
+ subscription: boolean,
|
|
|
|
+ skills: boolean,
|
|
|
|
+ about: boolean
|
|
|
|
+}
|
|
|
|
+
|
|
export const ProfileSections: React.FC<ProfileSectionsProps> = ({
|
|
export const ProfileSections: React.FC<ProfileSectionsProps> = ({
|
|
profile,
|
|
profile,
|
|
toggleTipsAsync,
|
|
toggleTipsAsync,
|
|
@@ -41,56 +53,28 @@ export const ProfileSections: React.FC<ProfileSectionsProps> = ({
|
|
deleteAccount,
|
|
deleteAccount,
|
|
deleteAccountStatus
|
|
deleteAccountStatus
|
|
}) => {
|
|
}) => {
|
|
|
|
+ const [collapsed, setCollapsed] = useState<SectionsCollapseState>({info: true, prefs: true, legal: true, subscription: true, skills: true, about: true})
|
|
const [infoCollapsed, toggleInfo] = useState<boolean>(true)
|
|
const [infoCollapsed, toggleInfo] = useState<boolean>(true)
|
|
const [skillsCollapsed, toggleSkills] = useState<boolean>(true)
|
|
const [skillsCollapsed, toggleSkills] = useState<boolean>(true)
|
|
const [prefsCollapsed, togglePrefs] = useState<boolean>(true)
|
|
const [prefsCollapsed, togglePrefs] = useState<boolean>(true)
|
|
const [subscriptionCollapsed, toggleSubscription] = useState<boolean>(true)
|
|
const [subscriptionCollapsed, toggleSubscription] = useState<boolean>(true)
|
|
const [legalCollapsed, toggleLegal] = useState<boolean>(true)
|
|
const [legalCollapsed, toggleLegal] = useState<boolean>(true)
|
|
|
|
|
|
- const openInfo = () => {
|
|
|
|
- toggleInfo(!infoCollapsed)
|
|
|
|
- if (!skillsCollapsed) toggleSkills(true)
|
|
|
|
- if (!prefsCollapsed) togglePrefs(true)
|
|
|
|
- if (!subscriptionCollapsed) toggleSubscription(!subscriptionCollapsed)
|
|
|
|
- if (!legalCollapsed) toggleLegal(true)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const openSkills = () => {
|
|
|
|
- toggleSkills(!skillsCollapsed)
|
|
|
|
- if (!infoCollapsed) toggleInfo(true)
|
|
|
|
- if (!prefsCollapsed) togglePrefs(true)
|
|
|
|
- if (!subscriptionCollapsed) toggleSubscription(!subscriptionCollapsed)
|
|
|
|
- if (!legalCollapsed) toggleLegal(true)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const openPrefs = () => {
|
|
|
|
- togglePrefs(!prefsCollapsed)
|
|
|
|
- if (!infoCollapsed) toggleInfo(true)
|
|
|
|
- if (!skillsCollapsed) toggleSkills(true)
|
|
|
|
- if (!subscriptionCollapsed) toggleSubscription(!subscriptionCollapsed)
|
|
|
|
- if (!legalCollapsed) toggleLegal(true)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const openSubscription = () => {
|
|
|
|
- toggleSubscription(!subscriptionCollapsed)
|
|
|
|
- if (!infoCollapsed) toggleInfo(true)
|
|
|
|
- if (!skillsCollapsed) toggleSkills(true)
|
|
|
|
- if (!prefsCollapsed) togglePrefs(true)
|
|
|
|
- if (!legalCollapsed) toggleLegal(true)
|
|
|
|
|
|
+ const toggleSection = (section: SectionName) => {
|
|
|
|
+ Object.keys(collapsed).forEach(key => {
|
|
|
|
+ if (key === section) {
|
|
|
|
+ setCollapsed({...collapsed, [key]: !collapsed[key]})
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ setCollapsed({...collapsed, [key]: true})
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
-
|
|
|
|
const openFeedback = () => {
|
|
const openFeedback = () => {
|
|
|
|
+ toggleSection('none')
|
|
Linking.openURL('mailto:dev@clicknpush.ca')
|
|
Linking.openURL('mailto:dev@clicknpush.ca')
|
|
}
|
|
}
|
|
|
|
|
|
- const openLegal = () => {
|
|
|
|
- toggleLegal(!legalCollapsed)
|
|
|
|
- if (!infoCollapsed) toggleInfo(true)
|
|
|
|
- if (!subscriptionCollapsed) toggleSubscription(true)
|
|
|
|
- if (!skillsCollapsed) toggleSkills(true)
|
|
|
|
- if (!prefsCollapsed) togglePrefs(true)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
return (
|
|
return (
|
|
<View>
|
|
<View>
|
|
<ProfileInformation
|
|
<ProfileInformation
|
|
@@ -102,14 +86,14 @@ export const ProfileSections: React.FC<ProfileSectionsProps> = ({
|
|
resetChangePassword={resetChangePassword}
|
|
resetChangePassword={resetChangePassword}
|
|
changePasswordStatus={changePasswordStatus}
|
|
changePasswordStatus={changePasswordStatus}
|
|
changePassword={changePassword}
|
|
changePassword={changePassword}
|
|
- openInfo={openInfo}
|
|
|
|
|
|
+ openInfo={() => toggleSection('information')}
|
|
infoCollapsed={infoCollapsed}
|
|
infoCollapsed={infoCollapsed}
|
|
email={profile?.email}
|
|
email={profile?.email}
|
|
username={profile?.username} />
|
|
username={profile?.username} />
|
|
{/* <ProfileSkills openSkills={openSkills} skillsCollapsed={skillsCollapsed} /> */}
|
|
{/* <ProfileSkills openSkills={openSkills} skillsCollapsed={skillsCollapsed} /> */}
|
|
- <ProfilePrefs openPrefs={openPrefs} showTips={profile?.show_tips} prefsCollapsed={prefsCollapsed} toggleTipsAsync={toggleTipsAsync} />
|
|
|
|
- <ProfileSubscription openSubscription={openSubscription} subscriptionCollapsed={subscriptionCollapsed} />
|
|
|
|
- <ProfileLegal openLegal={openLegal} legalCollapsed={legalCollapsed} />
|
|
|
|
|
|
+ <ProfilePrefs openPrefs={() => toggleSection('prefs')} showTips={profile?.show_tips} prefsCollapsed={collapsed.prefs} toggleTipsAsync={toggleTipsAsync} />
|
|
|
|
+ <ProfileSubscription openSubscription={() => toggleSection('subscription')} subscriptionCollapsed={collapsed.subscription} />
|
|
|
|
+ <ProfileLegal openLegal={() => toggleSection('legal')} legalCollapsed={collapsed.legal} />
|
|
<ProfileSectionHeader isCollapsed={true} collapseToggleMethod={openFeedback} title="Provide feedback"/>
|
|
<ProfileSectionHeader isCollapsed={true} collapseToggleMethod={openFeedback} title="Provide feedback"/>
|
|
</View>
|
|
</View>
|
|
)
|
|
)
|