Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 0c0c327

Browse files
committed
WIP - Edit Profile
1 parent a652cc9 commit 0c0c327

File tree

8 files changed

+103
-21
lines changed

8 files changed

+103
-21
lines changed

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/WebApp.iml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/background/redux/store.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ import { createStore } from "redux";
22
import rootReducer from "./reducers";
33

44
export default createStore(rootReducer);
5+
6+
export type RootState = ReturnType<typeof rootReducer>;
Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,71 @@
1-
import React, {ReactElement} from "react";
2-
import {Container, Row, Button} from "react-bootstrap";
1+
import React, {ReactElement, useState} from "react";
2+
import {Button, Container, Form, Row} from "react-bootstrap";
3+
import {useSelector} from "react-redux";
4+
import {RootState} from "../../../background/redux/store";
5+
36

47
export default function Profile(): ReactElement {
5-
const user = {
6-
name: "Gimleux",
7-
groups: ["FAMILY", "ADMIN"]
8-
};
8+
const [isEditing, setIsEditing] = useState<boolean>(false);
9+
const user = useSelector((state: RootState) => state.user);
910

10-
return (
11-
<Container className="page-content">
12-
<Container fluid>
13-
<Row className="title-action mt-1">
14-
<h1 className="mr-1 h4">
15-
My Profile
16-
</h1>
17-
<Button>Edit Informations</Button>
18-
</Row>
19-
</Container>
11+
function handleEditModeChange(): void {
12+
console.log("[PROFILE] hi")
13+
setIsEditing(!isEditing)
14+
}
15+
16+
function EditProfile(): ReactElement {
17+
return (
18+
<Form>
19+
<Form.Group controlId="editProfileForm.Username">
20+
<Form.Label>Your Username</Form.Label>
21+
<Form.Control type="text" placeholder="Enter username" value={user.username ?? ""}/>
22+
<Form.Text>
23+
Your username will be visible to anyone using this system.
24+
</Form.Text>
25+
</Form.Group>
26+
<Form.Group controlId="editProfileForm.Password">
27+
<Form.Label>New Password</Form.Label>
28+
<Form.Control type="password" placeholder="New Password"/>
29+
</Form.Group>
30+
<Form.Group controlId="editProfileForm.PasswordConfirmation">
31+
<Form.Label>Repeat new Password</Form.Label>
32+
<Form.Control type="password" placeholder="New Password"/>
33+
</Form.Group>
34+
</Form>
35+
)
36+
}
2037

38+
function DisplayProfile(): ReactElement {
39+
return (
2140
<Container className="profile-information-display p-0">
22-
<h2 className="h3 pt-3 pb-3">
23-
{user.name}
41+
<h2 className="h3 pb-3">
42+
{user.username}
2443
</h2>
2544
<dl>
2645
<dt>Username</dt>
27-
<dd>{user.name}</dd>
46+
<dd>{user.username}</dd>
2847
<dt>Groups</dt>
29-
<dd>{user.groups.map((group: string) => {
30-
return group + " "
48+
<dd>{user.groups.map((value: number, index: number, array: number[]) => {
49+
return value + " "
3150
})}
3251
</dd>
3352
</dl>
3453
</Container>
54+
)
55+
}
56+
57+
return (
58+
<Container className="page-content">
59+
<Container fluid className=" mt-1 mb-3">
60+
<Row className="title-action">
61+
<h1 className="mr-1 h4">
62+
My Profile
63+
</h1>
64+
<Button onClick={handleEditModeChange}>{isEditing ? "Save Changes" : "Edit Informations"}</Button>
65+
</Row>
66+
</Container>
67+
{isEditing ? <EditProfile/> : <DisplayProfile/>}
68+
3569
</Container>
3670
);
3771
}

0 commit comments

Comments
 (0)