-
Notifications
You must be signed in to change notification settings - Fork 4
BackEnd-EditProfile-ahmed #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AhmedMohamed809
wants to merge
12
commits into
main
Choose a base branch
from
BackEnd-EditProfile-Ahmed
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7963c76
change title of the project
AhmedMohamed809 91e6880
add the Home page to Home page folder
AhmedMohamed809 7344497
add Edit Profile Bottom
AhmedMohamed809 423b649
create EditProfile route
AhmedMohamed809 a17e2bd
add useState function
AhmedMohamed809 4d6d526
add on change function
AhmedMohamed809 4f62ddb
add upload img function
AhmedMohamed809 d1b88ec
add upload image element
AhmedMohamed809 1b2d60a
edit and add setAuth
AhmedMohamed809 d0eb67e
add PUT method
AhmedMohamed809 676c94b
Merge branch 'Demo-Branch' of https://github.com/levilu800b/DALR-Lang…
AhmedMohamed809 96924c2
create a new route PUT
AhmedMohamed809 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,8 +1,146 @@ | ||
| import React from "react"; | ||
| import React, { useState } from "react"; | ||
| import { toast } from "react-toastify"; | ||
| import { UploadOutlined } from "@ant-design/icons"; | ||
| import { Button, message, Upload } from "antd"; | ||
| import "./EditProfile.css"; | ||
| const props = { | ||
| name: "file", | ||
| action: "https://www.mocky.io/v2/5cc8019d300000980a055e76", | ||
| headers: { | ||
| authorization: "authorization-text", | ||
| }, | ||
| onChange(info) { | ||
| if (info.file.status !== "uploading") { | ||
| console.log(info.file, info.fileList); | ||
| } | ||
| if (info.file.status === "done") { | ||
| message.success(`${info.file.name} file uploaded successfully`); | ||
| } else if (info.file.status === "error") { | ||
| message.error(`${info.file.name} file upload failed.`); | ||
| } | ||
| }, | ||
| }; | ||
| const EditProfile = ({ setAuth }) => { | ||
| const [inputs, setInputs] = useState({ | ||
| firstname: "", | ||
| secondname: "", | ||
| email: "", | ||
| language_speak: "", | ||
| language_interest: "", | ||
| city: "", | ||
| country: "", | ||
| }); | ||
| const { | ||
| firstname, | ||
| secondname, | ||
| email, | ||
| language_speak, | ||
| language_interest, | ||
| city, | ||
| country, | ||
| } = inputs; | ||
| const onChange = (e) => | ||
| setInputs({ ...inputs, [e.target.name]: e.target.value }); | ||
| const onSubmitForm = async (e) => { | ||
| e.preventDefault(); | ||
| try { | ||
| const body = { | ||
| firstname, | ||
| secondname, | ||
| email, | ||
| language_speak, | ||
| language_interest, | ||
| city, | ||
| country, | ||
| }; | ||
| const response = await fetch("/api/dashboard/update/${user.id}", { | ||
| method: "PUT", | ||
| headers: { | ||
| "Content-type": "application/json", | ||
| }, | ||
| body: JSON.stringify(body), | ||
| }); | ||
| const parseRes = await response.json(); | ||
| if (parseRes.jwtToken) { | ||
| localStorage.setItem("token", parseRes.jwtToken); | ||
| setAuth(true); | ||
| toast.success("Edit Successfully"); | ||
| } else { | ||
| setAuth(false); | ||
| toast.error(parseRes); | ||
| } | ||
| } catch (err) { | ||
| console.error(err.message); | ||
| } | ||
| }; | ||
| return <div className="epcontainer"> | ||
|
|
||
| const EditProfile = () => { | ||
| return <div>Edit Profile</div>; | ||
| <h1 className="mt-5 text-center">Edit Profile</h1> | ||
| <form className="col-md-4" onSubmit={onSubmitForm}> | ||
| <input | ||
| type="text" | ||
| name="firstname" | ||
| value={firstname} | ||
| placeholder="first name" | ||
| onChange={(e) => onChange(e)} | ||
| className="form-control my-3" | ||
| /> | ||
| <input | ||
| type="text" | ||
| name="secondname" | ||
| value={secondname} | ||
| placeholder="last name" | ||
| onChange={(e) => onChange(e)} | ||
| className="form-control my-3" | ||
| /> | ||
| <input | ||
| type="text" | ||
| name="email" | ||
| value={email} | ||
| placeholder="email" | ||
| onChange={(e) => onChange(e)} | ||
| className="form-control my-3" | ||
| /> | ||
|
|
||
| <input | ||
| type="text" | ||
| name="language_speak" | ||
| value={language_speak} | ||
| placeholder="language I speak" | ||
| onChange={(e) => onChange(e)} | ||
| className="form-control my-3" | ||
| /> | ||
| <input | ||
| type="text" | ||
| name="language_interest" | ||
| value={language_interest} | ||
| placeholder="language of interest" | ||
| onChange={(e) => onChange(e)} | ||
| className="form-control my-3" | ||
| /> | ||
| <input | ||
| type="text" | ||
| name="city" | ||
| value={city} | ||
| placeholder="city" | ||
| onChange={(e) => onChange(e)} | ||
| className="form-control my-3" | ||
| /> | ||
| <input | ||
| type="text" | ||
| name="country" | ||
| value={country} | ||
| placeholder="country" | ||
| onChange={(e) => onChange(e)} | ||
| className="form-control my-3" | ||
| /> | ||
| <Upload {...props}> | ||
| <Button icon={<UploadOutlined />}>Upload Your Profile Image</Button> | ||
| </Upload> | ||
|
|
||
| <button className="btn btn-success btn-block">Edit Profile</button> | ||
| </form> | ||
| </div>; | ||
| }; | ||
|
|
||
| export default EditProfile; |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
client/src/pages/Home.js → client/src/components/HomePage/Home.js
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grete job