-
Notifications
You must be signed in to change notification settings - Fork 0
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
PR de correção. Não precisa mergeear. #48
base: correcao-projeto
Are you sure you want to change the base?
Conversation
componentes criados
rotas prontas
searchPage
router com todas as paginas
router com r minisculo
Login - SignUp - Adress Page
pagina de carrinho estatica
iniciada a pagina estatica do carrinho
colors.js, theme.js, cores primárias, login, cadastro, endereco alinh…
feedPage e RestaurantCard meio feitos
começo de estilização das pags editar perfil e editar endereço
login ok - signup ok - cadastro de endereco falta bater na api
erros corrigidos
header alterado
adicionei header e footer nas paginas e acertei alguns tokens que est…
header footer route cart varias paradas
loading page
active order estatico
tentando mandar dados para o carrinho
icones de edição funcionando para as páginas adequadas.
funcao de editar perfil OK
pagina de edicao de endereco OK
carrinho meio feito
alterei o readme
useEffect(() => { | ||
getRestaurantDetails(); | ||
}, []); | ||
|
||
const getRestaurantDetails = () => { | ||
const body = { | ||
products: [ | ||
{ | ||
id: "CnKdjU6CyKakQDGHzNln", | ||
quantity: 10, | ||
}, | ||
{ | ||
quantity: 1, | ||
id: "KJqMl2DxeShkSBevKVre", | ||
}, | ||
], | ||
paymentMethod: "creditcard", | ||
}; | ||
|
||
axios | ||
.post( | ||
"https://us-central1-missao-newton.cloudfunctions.net/futureEatsA/restaurants/1/order", | ||
{ | ||
headers: { | ||
authorization: localStorage.getItem("token"), | ||
}, | ||
} | ||
) | ||
.then((response) => { | ||
setProducts(response.data.restaurant.products); | ||
console.log(response); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
}; |
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.
É sempre bom abstrair as lógicas de ciclo de vida e requisição em hooks e funções. Aqui, vcs poderiam criar um hook chamado useRequestData para fazer esse trecho, o que deixaria o componente mais limpo e reutilizável.
useEffect(() => { | ||
getProfile(); | ||
}, []); | ||
|
||
const getProfile = () => { | ||
const token = localStorage.getItem("token"); | ||
|
||
axios | ||
.get( | ||
`https://us-central1-missao-newton.cloudfunctions.net/futureEatsA/profile/address`, | ||
{ | ||
headers: { | ||
auth: token, | ||
}, | ||
} | ||
) | ||
.then((response) => { | ||
setaddress(response.data.address); | ||
}) | ||
.catch((error) => { | ||
console.log(error.messenge); | ||
}); | ||
}; |
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.
Mesma coisa que falei na última mensagem, dava pra abstrair todo esse ciclo pra um custom hook
const putUpdateProfile = (event) => { | ||
event.preventDefault(); | ||
const body = { | ||
name: profile.name, | ||
email: profile.email, | ||
cpf: profile.cpf, | ||
}; | ||
|
||
console.log("body", body); | ||
const token = localStorage.getItem("token"); | ||
|
||
axios | ||
.put( | ||
`https://us-central1-missao-newton.cloudfunctions.net/futureEatsA/profile`, | ||
body, | ||
{ | ||
headers: { | ||
auth: token, | ||
}, | ||
} | ||
) | ||
.then((response) => { | ||
console.log(response); | ||
alert("Perfil editado com sucesso"); | ||
history.push("/perfil"); | ||
}) | ||
.catch((error) => { | ||
alert("Erro ao editar perfil"); | ||
console.error(error); | ||
}); | ||
}; |
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.
Mesma coisa dos últimos dois comentários hehe. Só que aqui a abstração vai pra criação de uma função normal, e não um custom hook
</TabPanel> | ||
<Footer /> | ||
</div> | ||
</ThemeProvider> |
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.
Esse código ficou beeeem grande. Mais de 300 linhas. Quando for assim, pensem em componentizar mais o código.
PR de correção. Não precisa mergeear.