Added mutate on groupCreate/groupJoin
This commit is contained in:
parent
6ec7436cdf
commit
ae69c4ed08
1 changed files with 15 additions and 15 deletions
|
@ -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 (
|
||||
|
|
Loading…
Add table
Reference in a new issue