Refactored code to make it more reusable
This commit is contained in:
1 parent
fd4c5436bd
commit
f9852c19d5
2 files changed
+133
-168
No files matched your search
@@ -1,18 +1,24 @@
|
|||||||
.edit-profile-form, .delete-profile-form{
|
.edit-profile-form,
|
||||||
width: inherit;
|
.edit-password-form,
|
||||||
|
.delete-profile-form {
|
||||||
|
width: inherit;
|
||||||
}
|
}
|
||||||
.edit-profile-form__wrapper, .delete-profile-form__wrapper{
|
.edit-profile-form__wrapper,
|
||||||
width: 90%;
|
.delete-profile-form__wrapper,
|
||||||
|
.edit-password-form__wrapper {
|
||||||
display: flex;
|
width: 90%;
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-between;
|
display: flex;
|
||||||
align-items: flex-start;
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
}
|
}
|
||||||
.edit-profile-form__wrapper:not(:first-of-type){
|
.edit-profile-form__wrapper:not(:first-of-type),
|
||||||
margin-top: 40px;
|
.edit-password-form__wrapper:not(:first-of-type) {
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
.edit-profile-form__wrapper input,
|
||||||
|
.edit-password-form__wrapper input {
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 10px;
|
||||||
}
|
}
|
||||||
.edit-profile-form__wrapper input{
|
|
||||||
font-size: 13px;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
+112
-153
@@ -20,6 +20,30 @@ import ButtonSpinner from "../../Components/ButtonSpinner";
|
|||||||
import Button from "../../Components/Button";
|
import Button from "../../Components/Button";
|
||||||
|
|
||||||
const tabList = ["Profile", "Password", "Team"];
|
const tabList = ["Profile", "Password", "Team"];
|
||||||
|
const profileConfig = {
|
||||||
|
firstName: {
|
||||||
|
id: "edit-first-name",
|
||||||
|
label: "First name",
|
||||||
|
type: "input",
|
||||||
|
},
|
||||||
|
lastName: {
|
||||||
|
id: "edit-last-name",
|
||||||
|
label: "Last name",
|
||||||
|
type: "input",
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
id: "edit-email",
|
||||||
|
label: "Email",
|
||||||
|
description: "After updating, you'll receive a confirmation email.",
|
||||||
|
type: "input",
|
||||||
|
},
|
||||||
|
photo: {
|
||||||
|
id: "edit-photo",
|
||||||
|
label: "Your photo",
|
||||||
|
description: "This photo will be displayed in your profile page.",
|
||||||
|
type: "photo",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const Settings = () => {
|
const Settings = () => {
|
||||||
//(tab) 0 - Profile
|
//(tab) 0 - Profile
|
||||||
@@ -95,159 +119,91 @@ const Settings = () => {
|
|||||||
sx={{ padding: "0", marginTop: theme.spacing(6.25), width: "100%" }}
|
sx={{ padding: "0", marginTop: theme.spacing(6.25), width: "100%" }}
|
||||||
>
|
>
|
||||||
<form className="edit-profile-form" noValidate spellCheck="false">
|
<form className="edit-profile-form" noValidate spellCheck="false">
|
||||||
<div className="edit-profile-form__wrapper">
|
{Object.entries(profileConfig).map(([key, field]) => (
|
||||||
<Typography
|
<div className="edit-profile-form__wrapper" key={key}>
|
||||||
variant="h4"
|
<Stack
|
||||||
component="h1"
|
direction="column"
|
||||||
sx={{
|
gap="8px"
|
||||||
flex: 1,
|
sx={{ flex: 1, marginRight: "10px" }}
|
||||||
color: theme.palette.secondary.main,
|
|
||||||
fontSize: "13px",
|
|
||||||
fontWeight: "600",
|
|
||||||
marginRight: "10px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
First name
|
|
||||||
</Typography>
|
|
||||||
<TextField
|
|
||||||
id="edit-first-name"
|
|
||||||
placeholder="Enter your first name"
|
|
||||||
sx={{
|
|
||||||
flex: 1,
|
|
||||||
minWidth: theme.spacing(30),
|
|
||||||
}}
|
|
||||||
></TextField>
|
|
||||||
</div>
|
|
||||||
<div className="edit-profile-form__wrapper">
|
|
||||||
<Typography
|
|
||||||
variant="h4"
|
|
||||||
component="h1"
|
|
||||||
sx={{
|
|
||||||
flex: 1,
|
|
||||||
color: theme.palette.secondary.main,
|
|
||||||
fontSize: "13px",
|
|
||||||
fontWeight: "600",
|
|
||||||
marginRight: "10px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Last name
|
|
||||||
</Typography>
|
|
||||||
<TextField
|
|
||||||
id="edit-last-name"
|
|
||||||
placeholder="Enter your last name"
|
|
||||||
sx={{
|
|
||||||
flex: 1,
|
|
||||||
minWidth: theme.spacing(30),
|
|
||||||
}}
|
|
||||||
></TextField>
|
|
||||||
</div>
|
|
||||||
<div className="edit-profile-form__wrapper">
|
|
||||||
<Stack
|
|
||||||
direction="column"
|
|
||||||
gap="8px"
|
|
||||||
sx={{
|
|
||||||
flex: 1,
|
|
||||||
marginRight: "10px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="h4"
|
|
||||||
component="h1"
|
|
||||||
sx={{
|
|
||||||
color: theme.palette.secondary.main,
|
|
||||||
fontSize: "13px",
|
|
||||||
fontWeight: "600",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Email
|
<Typography
|
||||||
</Typography>
|
variant="h4"
|
||||||
<Typography
|
component="h1"
|
||||||
variant="h4"
|
sx={{
|
||||||
component="p"
|
color: theme.palette.secondary.main,
|
||||||
sx={{
|
fontSize: "13px",
|
||||||
color: theme.palette.secondary.main,
|
fontWeight: "600",
|
||||||
opacity: 0.6,
|
}}
|
||||||
fontSize: "13px",
|
>
|
||||||
}}
|
{field.label}
|
||||||
>
|
</Typography>
|
||||||
After updating, you'll receive a confirmation email.
|
{field ? (
|
||||||
</Typography>
|
<Typography
|
||||||
</Stack>
|
variant="h5"
|
||||||
<TextField
|
component="p"
|
||||||
id="edit-email"
|
sx={{
|
||||||
placeholder="Enter your email"
|
color: theme.palette.secondary.main,
|
||||||
sx={{
|
opacity: 0.6,
|
||||||
flex: 1,
|
fontSize: "13px",
|
||||||
minWidth: theme.spacing(30),
|
}}
|
||||||
}}
|
>
|
||||||
></TextField>
|
{field.description}
|
||||||
</div>
|
</Typography>
|
||||||
<div className="edit-profile-form__wrapper">
|
) : (
|
||||||
<Stack
|
""
|
||||||
direction="column"
|
)}
|
||||||
gap="8px"
|
</Stack>
|
||||||
sx={{ flex: 1, marginRight: "10px" }}
|
{field.type === "input" ? (
|
||||||
>
|
<TextField
|
||||||
<Typography
|
id={field.id}
|
||||||
variant="h4"
|
placeholder={`Enter your ${field.label.toLowerCase()}`}
|
||||||
component="h1"
|
sx={{
|
||||||
sx={{
|
flex: 1,
|
||||||
color: theme.palette.secondary.main,
|
minWidth: theme.spacing(30),
|
||||||
fontSize: "13px",
|
}}
|
||||||
fontWeight: "600",
|
></TextField>
|
||||||
}}
|
) : field.type === "photo" ? (
|
||||||
>
|
<Stack direction="row" alignItems="center" sx={{ flex: 1 }}>
|
||||||
Your photo
|
{/* TODO - Use Avatar component instead of @mui */}
|
||||||
</Typography>
|
<Avatar
|
||||||
<Typography
|
alt="Remy Sharp"
|
||||||
variant="h4"
|
src="/static/images/avatar/2.jpg"
|
||||||
component="p"
|
className="icon-button-avatar"
|
||||||
sx={{
|
style={{ width: "64px", height: "64px" }}
|
||||||
color: theme.palette.secondary.main,
|
/>
|
||||||
opacity: 0.6,
|
<ButtonSpinner
|
||||||
fontSize: "13px",
|
level="tertiary"
|
||||||
}}
|
label="Delete"
|
||||||
>
|
onClick={handleDeletePicture}
|
||||||
This photo will be displayed in your profile page.
|
isLoading={isLoading}
|
||||||
</Typography>
|
sx={{
|
||||||
</Stack>
|
height: "fit-content",
|
||||||
<Stack direction="row" alignItems="center" sx={{ flex: 1 }}>
|
fontSize: "13px",
|
||||||
{/* TODO - Use Avatar component instead of @mui */}
|
"&:focus": {
|
||||||
<Avatar
|
outline: "none",
|
||||||
alt="Remy Sharp"
|
},
|
||||||
src="/static/images/avatar/2.jpg"
|
}}
|
||||||
className="icon-button-avatar"
|
/>
|
||||||
style={{ width: "64px", height: "64px" }}
|
{/* TODO - modal popup for update pfp? */}
|
||||||
/>
|
<Button
|
||||||
<ButtonSpinner
|
level="tertiary"
|
||||||
level="tertiary"
|
label="Update"
|
||||||
label="Delete"
|
onClick={handleUpdatePicture}
|
||||||
onClick={handleDeletePicture}
|
sx={{
|
||||||
isLoading={isLoading}
|
height: "fit-content",
|
||||||
sx={{
|
color: theme.palette.primary.main,
|
||||||
height: "fit-content",
|
fontSize: "13px",
|
||||||
fontSize: "13px",
|
"&:focus": {
|
||||||
"&:focus": {
|
outline: "none",
|
||||||
outline: "none",
|
},
|
||||||
},
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
</Stack>
|
||||||
{/* TODO - modal popup for update pfp? */}
|
) : (
|
||||||
<Button
|
""
|
||||||
level="tertiary"
|
)}
|
||||||
label="Update"
|
</div>
|
||||||
onClick={handleUpdatePicture}
|
))}
|
||||||
sx={{
|
|
||||||
height: "fit-content",
|
|
||||||
color: theme.palette.primary.main,
|
|
||||||
fontSize: "13px",
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
<Divider sx={{ marginY: theme.spacing(6.25) }} />
|
<Divider sx={{ marginY: theme.spacing(6.25) }} />
|
||||||
<form className="delete-profile-form" noValidate spellCheck="false">
|
<form className="delete-profile-form" noValidate spellCheck="false">
|
||||||
@@ -293,7 +249,10 @@ const Settings = () => {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel value="1">Password</TabPanel>
|
<TabPanel
|
||||||
|
value="1"
|
||||||
|
sx={{ padding: "0", marginTop: theme.spacing(6.25), width: "100%" }}
|
||||||
|
></TabPanel>
|
||||||
<TabPanel value="2">Team</TabPanel>
|
<TabPanel value="2">Team</TabPanel>
|
||||||
</TabContext>
|
</TabContext>
|
||||||
{/* TODO - Update ModalPopup Component with @mui for reusability */}
|
{/* TODO - Update ModalPopup Component with @mui for reusability */}
|
||||||
|
|||||||
Reference in new issue
Block a user