-
Notifications
You must be signed in to change notification settings - Fork 3
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 #40 from neuefische/Feat/SettingsPage
add SettingsPage with Update Reading Goal function
- Loading branch information
Showing
4 changed files
with
137 additions
and
22 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
49 changes: 49 additions & 0 deletions
49
frontend/src/pages/SettingsPage/settingsPage/SettingsPage.css
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,49 @@ | ||
.settingsPageForm { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 12px; | ||
margin-bottom: 10px; | ||
justify-content: stretch; | ||
align-content: stretch; | ||
} | ||
|
||
.settingsPageForm input:disabled, select:disabled, textarea:disabled { | ||
background-color: transparent; | ||
color: white; | ||
border: none; | ||
} | ||
|
||
.settingsPageForm input, select, textarea { | ||
background-color: #183A37; | ||
padding: 8px 5px; | ||
border: 1px solid rgba(93, 165, 45, 0.45); | ||
border-radius: 5px; | ||
font-size: 14px; | ||
font-weight: bold; | ||
} | ||
|
||
.creator-container { | ||
display: flex; | ||
margin-top: 250px; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
.creator-names { | ||
display: flex; | ||
color: #747bff; | ||
opacity: 0.7; | ||
flex-direction: row; | ||
gap: 8px; | ||
flex-wrap: wrap; | ||
font-size: 14px; | ||
} | ||
|
||
@media only screen and (min-width: 768px) { | ||
.creator-container { | ||
position: fixed; | ||
bottom: 20px; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
frontend/src/pages/SettingsPage/settingsPage/SettingsPage.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,63 @@ | ||
import {User} from "../../../types/types.ts"; | ||
import {ChangeEvent, FormEvent, useState} from "react"; | ||
import './SettingsPage.css' | ||
|
||
type SettingsPageProps = { | ||
user: User, | ||
updateUser: (updatedProperty: string, updatedValue: string | number) => void | ||
} | ||
|
||
export default function SettingsPage({user, updateUser}: SettingsPageProps) { | ||
|
||
const [formData, setFormData] = useState({ | ||
readingGoal: user.readingGoal, | ||
goalDate: user.goalDate | ||
}); | ||
|
||
function handleChange(event: ChangeEvent<HTMLInputElement>) { | ||
const {name, value} = event.target; | ||
setFormData({ | ||
...formData, | ||
[name]: value, | ||
}) | ||
} | ||
|
||
function handleSubmit(event: FormEvent<HTMLFormElement>) { | ||
event.preventDefault() | ||
updateUser("readingGoal", formData.readingGoal); | ||
updateUser("goalDate", formData.goalDate); | ||
} | ||
|
||
return ( | ||
<> | ||
<h2>Settings</h2> | ||
<h3>{user.userName}</h3> | ||
<form className={"settingsPageForm"} onSubmit={handleSubmit}> | ||
<label htmlFor={"readingGoal"} className={"book-label"}>Reading Goal: </label> | ||
<input | ||
name="readingGoal" | ||
type="number" | ||
value={formData.readingGoal} | ||
onChange={handleChange} | ||
/> | ||
<label htmlFor={"goalDate"} className={"book-label"}>Goal Date: </label> | ||
<input | ||
type="date" | ||
name="goalDate" | ||
value={formData.goalDate} | ||
onChange={handleChange} | ||
/> | ||
<button type={"submit"}>Update</button> | ||
</form> | ||
<div className={"creator-container"}> | ||
<h3>Created By</h3> | ||
<div className={"creator-names"}> | ||
<p>Eva Goetzke</p> | ||
<p>Marcel Herr</p> | ||
<p>Rinae Hyun</p> | ||
<p>Simon Staß</p> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} |