-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
188 additions
and
165 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
import { Component } from "@/shared/model"; | ||
import styles from "./editProfilePage.module.css"; | ||
import profileStyles from "@/pages/profile/profilePage.module.css"; | ||
import { | ||
validateEmail, | ||
validateLogin, | ||
validateName, | ||
validatePhone, | ||
} from "@/shared/lib"; | ||
import { EditProfilePageProps } from "./editProfilePage.types"; | ||
import { connect } from "@/shared/model/store/connect"; | ||
import { UserAPI } from "@/shared/api/user"; | ||
|
||
class EditProfilePage extends Component { | ||
constructor(props: EditProfilePageProps) { | ||
|
@@ -25,93 +21,46 @@ class EditProfilePage extends Component { | |
const phone = this.refs.fields.refs.phone.refs.phone.value(); | ||
|
||
if (firstName && lastName && login && email && displayName && phone) { | ||
console.log({ | ||
firstName, | ||
lastName, | ||
login, | ||
email, | ||
displayName, | ||
phone, | ||
const userAPI = new UserAPI(); | ||
userAPI.editUser({ | ||
first_name: firstName, | ||
last_name: lastName, | ||
login: login, | ||
email: email, | ||
display_name: displayName, | ||
phone: phone, | ||
}); | ||
} | ||
}, | ||
userEditFields: [ | ||
{ | ||
title: "Почта", | ||
type: "edit", | ||
inputName: "email", | ||
value: "[email protected]", | ||
validate: validateEmail, | ||
ref: "email", | ||
}, | ||
{ | ||
title: "Логин", | ||
type: "edit", | ||
inputName: "login", | ||
value: "ivanovivan", | ||
validate: validateLogin, | ||
ref: "login", | ||
}, | ||
{ | ||
title: "Имя", | ||
type: "edit", | ||
inputName: "first_name", | ||
value: "Иван", | ||
validate: validateName, | ||
ref: "firstName", | ||
}, | ||
{ | ||
title: "Фамилия", | ||
type: "edit", | ||
inputName: "second_name", | ||
value: "Иванов", | ||
validate: validateName, | ||
ref: "lastName", | ||
}, | ||
{ | ||
title: "Имя в чате", | ||
type: "edit", | ||
inputName: "display_name", | ||
value: "Ivan", | ||
validate: validateLogin, | ||
ref: "displayName", | ||
}, | ||
{ | ||
title: "Телефон", | ||
type: "edit", | ||
inputName: "phone", | ||
value: "+7 (909) 123 45 67", | ||
validate: validatePhone, | ||
ref: "phone", | ||
}, | ||
], | ||
}); | ||
} | ||
protected render() { | ||
return ` | ||
{{#> layout}} | ||
<div class="${profileStyles.profilePage} ${styles.editProfilePage}"> | ||
<div> | ||
{{{ SideButton to="/profile" }}} | ||
</div> | ||
<div class="${profileStyles.profile}"> | ||
{{{ UserImage }}} | ||
<div class="${profileStyles.username}"> | ||
Иван | ||
</div> | ||
<form> | ||
{{{ InfoList items=userEditFields ref="fields" }}} | ||
<div class="profile_buttons"> | ||
{{{ Button label="Сохранить" type="submit" onClick=onSubmit }}} | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
{{/layout}} | ||
{{#> layout}} | ||
<div class="${profileStyles.profilePage} ${styles.editProfilePage}"> | ||
<div> | ||
{{{ SideButton to="/profile" }}} | ||
</div> | ||
<div class="${profileStyles.profile}"> | ||
{{{ UserImage }}} | ||
<div class="${profileStyles.username}"> | ||
Иван | ||
</div> | ||
`; | ||
<form> | ||
{{{ SettingsList user=user ref="fields" }}} | ||
<div class="profile_buttons"> | ||
{{{ Button label="Сохранить" type="submit" onClick=onSubmit }}} | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
{{/layout}} | ||
`; | ||
} | ||
} | ||
|
||
export { EditProfilePage }; | ||
const EditProfilePageWithStore = connect(({ user }) => ({ user }))( | ||
EditProfilePage, | ||
); | ||
export { EditProfilePageWithStore }; |
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 +1 @@ | ||
export { EditProfilePage } from "./editProfile.component"; | ||
export { EditProfilePageWithStore as EditProfilePage } from "./editProfile.component"; |
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
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 +1,2 @@ | ||
export { UserAPI } from "./user.api"; | ||
export type { User } from "./user.types"; |
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,11 @@ | ||
import { HTTPClient } from "@/shared/api"; | ||
|
||
const userAPIInstance = new HTTPClient("https://ya-praktikum.tech/api/v2/user"); | ||
|
||
class UserAPI { | ||
public async editUser(data: any) { | ||
return userAPIInstance.put("/profile", { data }); | ||
} | ||
} | ||
|
||
export { UserAPI }; |
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 was deleted.
Oops, something went wrong.
Empty file.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.messageCard { | ||
border: 1px solid #000000; | ||
border: 2px solid #3369f3; | ||
border-radius: 5px; | ||
padding: 5px; | ||
margin-bottom: 10px; | ||
} |
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,5 +1,5 @@ | ||
.navigationList { | ||
position: fixed; | ||
bottom: 0; | ||
right: 0; | ||
left: 0; | ||
} |
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
Oops, something went wrong.