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) {
|
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',
|
method: 'POST',
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`
|
Authorization: `Bearer ${token}`
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
// TODO: handle errors
|
);
|
||||||
// if (res.ok) {
|
|
||||||
// if (!isJoining) {
|
if (res.ok) {
|
||||||
// mutate('groups');
|
mutate('me');
|
||||||
// } else {
|
// TODO REFACTOR
|
||||||
// mutate('me');
|
router.refresh();
|
||||||
// }
|
}
|
||||||
// router.refresh();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Add table
Reference in a new issue