Alterando informações de perfil
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const usersRoutesDefault = '/users';
|
||||
const usersRoutes = {
|
||||
create: {
|
||||
url: `${usersRoutesDefault}/create`
|
||||
url: `${usersRoutesDefault}`
|
||||
},
|
||||
get: {
|
||||
url: `${usersRoutesDefault}`
|
||||
|
||||
@@ -70,7 +70,8 @@ const Cadastro: React.FC = () => {
|
||||
if(name != '' && email != '' && birthDate != '' && password != '' && confirmPassword != '') {
|
||||
if(password === confirmPassword){
|
||||
const signUpForm = {
|
||||
name: firstName +' '+ lastName,
|
||||
name: firstName,
|
||||
lastname: lastName,
|
||||
email: email,
|
||||
birth_date: birthDate,
|
||||
password: password
|
||||
|
||||
@@ -32,8 +32,10 @@ const Perfil: React.FC = () => {
|
||||
(state: any, newState: any) => ({ ...state, ...newState }),
|
||||
{
|
||||
name: '',
|
||||
lastname: '',
|
||||
email: '',
|
||||
birth_date: '',
|
||||
bio: '',
|
||||
email: ''
|
||||
}
|
||||
);
|
||||
|
||||
@@ -73,7 +75,13 @@ const Perfil: React.FC = () => {
|
||||
|
||||
const userData = response.data
|
||||
|
||||
setInputValues({'name': userData.name, 'bio': userData.bio, 'email': userData.email});
|
||||
setInputValues({
|
||||
'name': userData.name,
|
||||
'lastname': userData.lastname,
|
||||
'email': userData.email,
|
||||
'birth_date': userData.birth_date,
|
||||
'bio': userData.bio
|
||||
});
|
||||
}).catch(() => {
|
||||
redirectUserToLogin()
|
||||
})
|
||||
@@ -115,7 +123,7 @@ const Perfil: React.FC = () => {
|
||||
</IonRow>
|
||||
|
||||
<IonCardHeader>
|
||||
<IonCardTitle class="ion-text-center">{inputValues.name}</IonCardTitle>
|
||||
<IonCardTitle class="ion-text-center">{inputValues.name} {inputValues.lastname}</IonCardTitle>
|
||||
</IonCardHeader>
|
||||
</IonCardContent>
|
||||
</IonCard>
|
||||
|
||||
@@ -27,10 +27,14 @@ import isEqual from 'lodash.isequal';
|
||||
|
||||
import * as usersRoutes from '../services/users';
|
||||
|
||||
import './Cadastro/Cadastro.css'
|
||||
|
||||
interface userData {
|
||||
name: string;
|
||||
bio: string;
|
||||
lastname: string;
|
||||
email: string;
|
||||
birth_date: string;
|
||||
bio: string;
|
||||
}
|
||||
|
||||
interface LocationState {
|
||||
@@ -46,22 +50,34 @@ const PerfilEditar: React.FC = () => {
|
||||
|
||||
const [userData, setUserData] = useState({
|
||||
name: '',
|
||||
lastname: '',
|
||||
email: '',
|
||||
birth_date: '',
|
||||
bio: '',
|
||||
email: ''
|
||||
});
|
||||
|
||||
const [inputValues, setInputValues] = useReducer(
|
||||
(state: any, newState: any) => ({ ...state, ...newState }),
|
||||
{
|
||||
name: '',
|
||||
lastname: '',
|
||||
email: '',
|
||||
birth_date: '',
|
||||
bio: '',
|
||||
email: ''
|
||||
}
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
let userData = location.state.userData
|
||||
|
||||
setUserData(location.state.userData)
|
||||
setInputValues({'name': userData.name, 'email': userData.email, 'bio': userData.bio});
|
||||
setInputValues({
|
||||
'name': userData.name,
|
||||
'lastname': userData.lastname,
|
||||
'email': userData.email,
|
||||
'birth_date': userData.birth_date,
|
||||
'bio': userData.bio
|
||||
});
|
||||
}, [userData]);
|
||||
|
||||
const handleUpdateUserData = () => {
|
||||
@@ -90,7 +106,7 @@ const PerfilEditar: React.FC = () => {
|
||||
<IonToolbar>
|
||||
<IonTitle>Editar perfil</IonTitle>
|
||||
<IonButtons slot="start">
|
||||
<IonBackButton defaultHref="perfil" />
|
||||
<IonBackButton defaultHref="/perfil" />
|
||||
</IonButtons>
|
||||
</IonToolbar>
|
||||
</IonHeader>
|
||||
@@ -104,15 +120,27 @@ const PerfilEditar: React.FC = () => {
|
||||
|
||||
<IonGrid>
|
||||
<IonRow>
|
||||
<IonCol>
|
||||
<IonItem>
|
||||
<IonLabel position="stacked"> Nome completo</IonLabel>
|
||||
<IonInput
|
||||
type="text"
|
||||
value={inputValues.name}
|
||||
onIonChange={(e) => setInputValues({'name': e.detail.value!})}
|
||||
></IonInput>
|
||||
</IonItem>
|
||||
<IonCol size="12">
|
||||
<div id='nome-sobrenome'>
|
||||
<IonItem>
|
||||
<IonLabel position="stacked"> Nome</IonLabel>
|
||||
<IonInput
|
||||
type="text"
|
||||
value={inputValues.name}
|
||||
onIonChange={(e) => setInputValues({'name': e.detail.value!})}
|
||||
></IonInput>
|
||||
</IonItem>
|
||||
|
||||
<IonItem>
|
||||
<IonLabel position="stacked"> Sobrenome</IonLabel>
|
||||
<IonInput
|
||||
type="text"
|
||||
value={inputValues.lastname}
|
||||
onIonChange={(e) => setInputValues({'lastname': e.detail.value!})}
|
||||
></IonInput>
|
||||
</IonItem>
|
||||
</div>
|
||||
|
||||
<IonItem>
|
||||
<IonLabel position="stacked"> Email</IonLabel>
|
||||
<IonInput
|
||||
@@ -121,6 +149,17 @@ const PerfilEditar: React.FC = () => {
|
||||
onIonChange={(e) => setInputValues({'email': e.detail.value!})}
|
||||
></IonInput>
|
||||
</IonItem>
|
||||
|
||||
<IonItem>
|
||||
<IonLabel position='stacked'>Data de nascimento</IonLabel>
|
||||
<IonInput
|
||||
type='date'
|
||||
value={inputValues.birth_date}
|
||||
onIonInput={(e: any) => setInputValues({'birth_date': e.detail.value!})}
|
||||
>
|
||||
</IonInput>
|
||||
</IonItem>
|
||||
|
||||
<IonItem>
|
||||
<IonLabel position="stacked"> Biografia</IonLabel>
|
||||
<IonTextarea
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface CadastroResponse {
|
||||
|
||||
export interface CadastroRequest {
|
||||
name: string;
|
||||
lastname: string;
|
||||
email: string;
|
||||
birth_date: string;
|
||||
password: string;
|
||||
|
||||
Reference in New Issue
Block a user