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) { async function onSubmit(data: GroupData) {
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/${isJoining ? 'groupJoin' : 'groupCreate'}`, { const res = await fetch(
method: 'POST', `${process.env.NEXT_PUBLIC_API_URL}/${isJoining ? 'groupJoin' : 'groupCreate'}`,
body: JSON.stringify(data), {
headers: { method: 'POST',
Authorization: `Bearer ${token}` body: JSON.stringify(data),
headers: {
Authorization: `Bearer ${token}`
}
} }
}); );
// TODO: handle errors
// if (res.ok) { if (res.ok) {
// if (!isJoining) { mutate('me');
// mutate('groups'); // TODO REFACTOR
// } else { router.refresh();
// mutate('me'); }
// }
// router.refresh();
// }
} }
return ( return (