-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from hotosm/feat/user-profile-form-slicing
User Profile Form Initial Slicing
- Loading branch information
Showing
9 changed files
with
227 additions
and
9 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/frontend/src/components/UserProfile/FormContents/BasicDetails/index.tsx
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,34 @@ | ||
import { Flex, FlexColumn } from '@Components/common/Layouts'; | ||
import { FormControl, Input, Label, Select } from '@Components/common/FormUI'; | ||
|
||
export default function BasicDetails() { | ||
return ( | ||
<section className="naxatw-px-14 naxatw-py-10"> | ||
<FlexColumn gap={5}> | ||
<Flex className="naxatw-h-14 naxatw-w-14 naxatw-items-center naxatw-justify-center naxatw-rounded-full naxatw-bg-grey-600"> | ||
<h4>SK</h4> | ||
</Flex> | ||
<FormControl> | ||
<Label required>Name</Label> | ||
<Input placeholder="Enter Full Name" className="naxatw-mt-1" /> | ||
</FormControl> | ||
<FormControl> | ||
<Label required>Country</Label> | ||
<Select | ||
options={[]} | ||
placeholder="Choose Country" | ||
className="naxatw-mt-1" | ||
/> | ||
</FormControl> | ||
<FormControl> | ||
<Label required>City</Label> | ||
<Select | ||
options={[]} | ||
placeholder="Choose City" | ||
className="naxatw-mt-1" | ||
/> | ||
</FormControl> | ||
</FlexColumn> | ||
</section> | ||
); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/frontend/src/components/UserProfile/FormContents/OrganizationDetails/index.tsx
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,29 @@ | ||
import { FormControl, Input, Label } from '@Components/common/FormUI'; | ||
import { FlexColumn } from '@Components/common/Layouts'; | ||
|
||
export default function OrganizationDetails() { | ||
return ( | ||
<section className="naxatw-px-14 naxatw-py-10"> | ||
<FlexColumn gap={5}> | ||
<FormControl> | ||
<Label required>Organization Name</Label> | ||
<Input | ||
placeholder="Enter Organization Name" | ||
className="naxatw-mt-1" | ||
/> | ||
</FormControl> | ||
<FormControl> | ||
<Label required>Organization Address</Label> | ||
<Input | ||
placeholder="Enter Organization Address" | ||
className="naxatw-mt-1" | ||
/> | ||
</FormControl> | ||
<FormControl> | ||
<Label required>Job Title</Label> | ||
<Input placeholder="Enter Job Title" className="naxatw-mt-1" /> | ||
</FormControl> | ||
</FlexColumn> | ||
</section> | ||
); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/frontend/src/components/UserProfile/FormContents/Password/index.tsx
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 { FormControl, Input, Label } from '@Components/common/FormUI'; | ||
import { FlexColumn } from '@Components/common/Layouts'; | ||
|
||
export default function PasswordSection() { | ||
return ( | ||
<section className="naxatw-px-14 naxatw-py-10"> | ||
<FlexColumn gap={5}> | ||
<FormControl> | ||
<Label required>Password</Label> | ||
<Input className="naxatw-mt-1" placeholder="Enter Password" /> | ||
</FormControl> | ||
<FormControl> | ||
<Label required>Confirm Password</Label> | ||
<Input className="naxatw-mt-1" placeholder="Enter Password Again" /> | ||
</FormControl> | ||
</FlexColumn> | ||
</section> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/frontend/src/components/UserProfile/FormContents/index.tsx
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,5 @@ | ||
import BasicDetails from './BasicDetails'; | ||
import OrganizationDetails from './OrganizationDetails'; | ||
import PasswordSection from './Password'; | ||
|
||
export { BasicDetails, OrganizationDetails, PasswordSection }; |
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
51 changes: 51 additions & 0 deletions
51
src/frontend/src/views/UserProfile/UserProfileTabs/index.tsx
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,51 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable jsx-a11y/click-events-have-key-events */ | ||
/* eslint-disable jsx-a11y/no-static-element-interactions */ | ||
import React, { useState, useEffect, act } from 'react'; | ||
|
||
interface ITabOptions { | ||
id: number; | ||
label: string; | ||
value: number; | ||
} | ||
|
||
interface TabProps { | ||
tabOptions: ITabOptions[]; | ||
onTabChange: (index: number) => void; | ||
activeTab?: number; | ||
} | ||
|
||
const Tab: React.FC<TabProps> = ({ tabOptions, onTabChange, activeTab }) => { | ||
const [activeTabx, setActiveTab] = useState(activeTab); | ||
|
||
useEffect(() => { | ||
setActiveTab(activeTab); | ||
}, [activeTab]); | ||
|
||
const handleTabClick = (index: number) => { | ||
setActiveTab(index); | ||
onTabChange(index); | ||
}; | ||
|
||
return ( | ||
<div> | ||
{tabOptions.map(tab => ( | ||
<div | ||
key={tab.id} | ||
className={`naxatw-cursor-pointer hover:naxatw-bg-red hover:naxatw-bg-opacity-10 ${ | ||
activeTabx === tab.id | ||
? 'naxatw-bg-red naxatw-bg-opacity-10 naxatw-text-red' | ||
: '' | ||
}`} | ||
onClick={() => handleTabClick(tab.id)} | ||
> | ||
<p className="naxatw-px-5 naxatw-py-3 naxatw-text-body-lg"> | ||
{tab.label} | ||
</p> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Tab; |
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,69 @@ | ||
import { useTypedDispatch, useTypedSelector } from '@Store/hooks'; | ||
import { UserProfileHeader } from '@Components/UserProfile'; | ||
import { tabOptions } from '@Constants/index'; | ||
import { setCommonState } from '@Store/actions/common'; | ||
import { Button } from '@Components/RadixComponents/Button'; | ||
import { | ||
BasicDetails, | ||
OrganizationDetails, | ||
PasswordSection, | ||
} from '@Components/UserProfile/FormContents'; | ||
import Tab from './UserProfileTabs'; | ||
|
||
const getActiveFormContent = (activeTab: number) => { | ||
switch (activeTab) { | ||
case 1: | ||
return <BasicDetails />; | ||
case 2: | ||
return <OrganizationDetails />; | ||
case 3: | ||
return <PasswordSection />; | ||
default: | ||
return <></>; | ||
} | ||
}; | ||
|
||
export default function UserProfile() { | ||
const dispatch = useTypedDispatch(); | ||
const userProfileActiveTab = useTypedSelector( | ||
state => state.common.userProfileActiveTab, | ||
); | ||
|
||
const onNextBtnClick = () => { | ||
if (userProfileActiveTab === 3) return; | ||
dispatch( | ||
setCommonState({ userProfileActiveTab: userProfileActiveTab + 1 }), | ||
); | ||
}; | ||
|
||
return ( | ||
<section className="naxatw-h-screen-nav naxatw-bg-grey-50 naxatw-px-16 naxatw-pt-8"> | ||
<UserProfileHeader /> | ||
<section className="naxatw-mt-5 naxatw-bg-grey-50 naxatw-px-80"> | ||
<div className="naxatw-grid naxatw-h-[35rem] naxatw-grid-cols-3 naxatw-gap-14 naxatw-bg-white naxatw-py-10"> | ||
<div className="naxatw-col-span-1"> | ||
<Tab | ||
onTabChange={info => { | ||
dispatch(setCommonState({ userProfileActiveTab: info })); | ||
}} | ||
tabOptions={tabOptions} | ||
activeTab={userProfileActiveTab} | ||
/> | ||
</div> | ||
<div className="naxatw-relative naxatw-col-span-2"> | ||
{getActiveFormContent(userProfileActiveTab)} | ||
<Button | ||
className="naxatw-absolute naxatw-bottom-4 naxatw-right-4 naxatw-bg-red" | ||
rightIcon={ | ||
userProfileActiveTab !== 3 ? 'chevron_right' : undefined | ||
} | ||
onClick={onNextBtnClick} | ||
> | ||
{userProfileActiveTab === 3 ? 'Complete Profile' : 'Next'} | ||
</Button> | ||
</div> | ||
</div> | ||
</section> | ||
</section> | ||
); | ||
} |