Skip to content
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

Open
wants to merge 92 commits into
base: correcao-projeto
Choose a base branch
from

Conversation

pedro-severo
Copy link

PR de correção. Não precisa mergeear.

felipepolato and others added 30 commits December 7, 2020 11:11
router com todas as paginas
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
Augustoluna and others added 24 commits December 9, 2020 17:01
adicionei header e footer nas paginas e acertei alguns tokens que est…
header footer route cart varias paradas
tentando mandar dados para o carrinho
icones de edição funcionando para as páginas adequadas.
pagina de edicao de endereco OK
Comment on lines +35 to +70
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);
});
};
Copy link
Author

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.

Comment on lines +18 to +40
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);
});
};
Copy link
Author

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

Comment on lines +26 to +56
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);
});
};
Copy link
Author

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>
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants