Added mutate on groupCreate/groupJoin

This commit is contained in:
Théo 2023-04-22 10:34:40 +02:00
parent 6ec7436cdf
commit ae69c4ed08

View file

@ -357,22 +357,22 @@ function GroupForm({ chapter, token }: { chapter: Chapter; token: string }) {
});
async function onSubmit(data: GroupData) {
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/${isJoining ? 'groupJoin' : 'groupCreate'}`, {
const res = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/${isJoining ? 'groupJoin' : 'groupCreate'}`,
{
method: 'POST',
body: JSON.stringify(data),
headers: {
Authorization: `Bearer ${token}`
}
});
// TODO: handle errors
// if (res.ok) {
// if (!isJoining) {
// mutate('groups');
// } else {
// mutate('me');
// }
// router.refresh();
// }
}
);
if (res.ok) {
mutate('me');
// TODO REFACTOR
router.refresh();
}
}
return (