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