2023-12-07 18:09:01 +01:00
|
|
|
import { API_BASE } from "@/utils/constants";
|
2023-07-25 19:37:04 +02:00
|
|
|
|
|
|
|
const Invite = {
|
|
|
|
checkInvite: async (inviteCode) => {
|
|
|
|
return await fetch(`${API_BASE}/invite/${inviteCode}`, {
|
|
|
|
method: "GET",
|
|
|
|
})
|
|
|
|
.then((res) => res.json())
|
|
|
|
.catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
return { invite: null, error: e.message };
|
|
|
|
});
|
|
|
|
},
|
|
|
|
acceptInvite: async (inviteCode, newUserInfo = {}) => {
|
|
|
|
return await fetch(`${API_BASE}/invite/${inviteCode}`, {
|
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify(newUserInfo),
|
|
|
|
})
|
|
|
|
.then((res) => res.json())
|
|
|
|
.catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
return { success: false, error: e.message };
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Invite;
|