Skip to content

Commit

Permalink
fix accept RSVP with refresh token
Browse files Browse the repository at this point in the history
  • Loading branch information
J164 committed Feb 9, 2025
1 parent eeb8a35 commit 2e7dadf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/AcceptRSVPForm/AcceptRSVPForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as yup from "yup";
import Checkboxes from "@/components/Form/Checkboxes/Checkboxes";
import TextInput from "@/components/Form/TextInput/TextInput";
import AvatarSelector from "../AvatarSelector/AvatarSelector";
import { setProfile } from "@/util/api";
import { refreshToken, setProfile } from "@/util/api";
import Link from "next/link";
import { RSVPDecideAccept } from "@/util/api";
import Loading from "@/components/Loading/Loading";
Expand Down Expand Up @@ -42,6 +42,7 @@ const AcceptRSVPForm: React.FC<AcceptRSVPFormProps> = ({ closeModal }) => {
setIsLoading(true);

await RSVPDecideAccept();
await refreshToken();
await setProfile({ displayName, discordTag, avatarId });

window.location.reload();
Expand Down
7 changes: 7 additions & 0 deletions util/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ export async function RSVPDecideAccept() {
return res;
}

export async function refreshToken() {
const res = await requestv2("GET", "/auth/token/refresh/").catch(
handleError
);
localStorage.setItem("token", res.token);
}

export async function RSVPDecideDecline() {
const res = await requestv2("PUT", "/admission/rsvp/decline").catch(
handleError
Expand Down

0 comments on commit 2e7dadf

Please sign in to comment.