-
Notifications
You must be signed in to change notification settings - Fork 0
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 #41 from Student-Labs-2023/develop
Develop
- Loading branch information
Showing
22 changed files
with
332 additions
and
68 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 was deleted.
Oops, something went wrong.
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,34 @@ | ||
import { useState, useEffect } from 'react'; | ||
|
||
export const useAddUser = (fullname: any, photo_url: string, email: any) => { | ||
const API = String(import.meta.env.VITE_API); | ||
const [user, setUser] = useState({}); | ||
|
||
const newUser = { | ||
full_name: fullname, | ||
photo_url: photo_url, | ||
email: email | ||
} | ||
|
||
async function createUser() { | ||
await fetch(`${API}/users`, { | ||
method : 'POST', | ||
headers: { | ||
'Content-type': 'application/json', | ||
}, | ||
body : JSON.stringify(newUser), | ||
}) | ||
.then(response => response.text()) | ||
.then(response => { | ||
response = JSON.parse(response); | ||
console.log(response); | ||
setUser(response); | ||
}) | ||
} | ||
|
||
useEffect(() => { | ||
createUser(); | ||
}, []) | ||
|
||
return user; | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { EditUserForm } from "./ui/EditUserForm"; |
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,112 @@ | ||
import React, { useState } from "react"; | ||
import styled from "styled-components"; | ||
import styles from "./styles.module.css"; | ||
import ProfileFormLayout from "../../../widgets/layout/ProfileFormLayout"; | ||
import { useAuth0 } from "@auth0/auth0-react"; | ||
import avatarDefault from "../../../../public/icons/avatar.svg"; | ||
import FormButton from "../../../shared/ui/formButton/FormButton"; | ||
import profileFormState from "../../../pages/Profile/store/profileFormState"; | ||
import { observer } from "mobx-react-lite"; | ||
|
||
const Form = styled.form` | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
&::before { | ||
content: ""; | ||
position: absolute; | ||
top: -2px; | ||
bottom: -2px; | ||
left: -2px; | ||
right: -2px; | ||
border-radius: 12px; | ||
background: linear-gradient( | ||
223deg, | ||
rgba(255, 178, 64, 0.9) 0%, | ||
rgba(216, 97, 196, 0.9) 50.52%, | ||
rgba(23, 94, 241, 0.9) 100% | ||
); | ||
z-index: -1; | ||
} | ||
`; | ||
|
||
export const EditUserForm: React.FC = observer(() => { | ||
const { user } = useAuth0(); | ||
const [avatar, setAvatar] = useState(user?.picture || avatarDefault); | ||
const [name, setName] = useState(user?.name); | ||
|
||
const sendAccess = () => { | ||
profileFormState.confirmEmail(); | ||
}; | ||
|
||
const saveChanges = () => { | ||
profileFormState.closeEditForm(); | ||
}; | ||
|
||
const onImageChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
if (event.target.files && event.target.files[0]) { | ||
setAvatar(URL.createObjectURL(event.target.files[0])); | ||
} | ||
}; | ||
|
||
return ( | ||
<ProfileFormLayout> | ||
<Form | ||
action="" | ||
autoComplete="off" | ||
method="post" | ||
encType="multipart/form-data" | ||
onSubmit={saveChanges} | ||
> | ||
<div className={styles.user}> | ||
<div className={styles.avatar}> | ||
<img | ||
src={avatar} | ||
alt="" | ||
style={{ width: "100%", height: "100%", borderRadius: "7px" }} | ||
/> | ||
<input | ||
className={styles.inputAvatar} | ||
type="file" | ||
title=" " | ||
onChange={onImageChange} | ||
/> | ||
</div> | ||
<div className={styles.info}> | ||
<input | ||
className={styles.name} | ||
type="text" | ||
value={name} | ||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => | ||
setName(e.target.value) | ||
} | ||
autoFocus | ||
/> | ||
<div className={styles.email}> | ||
<div className={styles.emailText}>{user?.email}</div> | ||
{!user?.email_verified ? ( | ||
<a className={styles.accessEmail}> | ||
{profileFormState.isEmailConfirmed ? ( | ||
<div style={{ color: "var(--green, #5bc259)" }}> | ||
На вашу почту выслано письмо с подтверждением | ||
</div> | ||
) : ( | ||
<a className={styles.accessText} onClick={sendAccess}> | ||
Подтвердите почту | ||
</a> | ||
)} | ||
</a> | ||
) : ( | ||
"" | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
<FormButton>Сохранить</FormButton> | ||
</Form> | ||
</ProfileFormLayout> | ||
); | ||
}); |
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,71 @@ | ||
.user { | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
gap: 20px; | ||
} | ||
|
||
.avatar { | ||
width: 86px; | ||
height: 86px; | ||
border-radius: 10px; | ||
border: 2px dashed #175ef1; | ||
position: relative; | ||
} | ||
|
||
.inputAvatar { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
color: transparent; | ||
|
||
&:hover { | ||
cursor: pointer; | ||
} | ||
|
||
&::file-selector-button { | ||
display: none; | ||
} | ||
} | ||
|
||
.info { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
gap: 8px; | ||
} | ||
|
||
.name { | ||
width: 100%; | ||
font-size: 22px; | ||
font-weight: 500; | ||
} | ||
|
||
.email { | ||
display: flex; | ||
align-items: center; | ||
gap: 12px; | ||
} | ||
|
||
.emailText { | ||
font-size: 20px; | ||
font-weight: 300; | ||
line-height: normal; | ||
} | ||
|
||
.accessEmail { | ||
font-size: 20px; | ||
font-weight: 300; | ||
line-height: normal; | ||
} | ||
|
||
.accessText { | ||
color: var(--red, #f95a39); | ||
|
||
&:hover { | ||
text-decoration: underline; | ||
cursor: pointer; | ||
} | ||
} |
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.