+ ) : (
+ <>
+
Group not found
+ >
);
}
diff --git a/src/components/Notifications/Notification.tsx b/src/components/Notifications/Notification.tsx
index a10d538..58a927b 100644
--- a/src/components/Notifications/Notification.tsx
+++ b/src/components/Notifications/Notification.tsx
@@ -19,12 +19,12 @@ export default function Notification({
}, [carpoolId, notification.user.id]);
const acceptInv = useCallback(() => {
- acceptInvite(carpoolId, notification.user.id);
- }, [carpoolId, notification.user.id]);
+ acceptInvite(carpoolId);
+ }, [carpoolId]);
const rejectInv = useCallback(() => {
- denyInvite(carpoolId, notification.user.id);
- }, [carpoolId, notification.user.id]);
+ denyInvite(carpoolId);
+ }, [carpoolId]);
const sentTime = new Date(notification.sentTime);
diff --git a/src/components/api.ts b/src/components/api.ts
index b8c9de0..2ef6b22 100644
--- a/src/components/api.ts
+++ b/src/components/api.ts
@@ -138,16 +138,16 @@ export async function acceptRequest(carpoolId: number, userId: number) {
return await post(`/carpools/${carpoolId}/accept_request`, { userId });
}
-export async function acceptInvite(carpoolId: number, userId: number) {
- return await post(`/carpools/${carpoolId}/accept_invite`, { userId });
+export async function acceptInvite(carpoolId: number) {
+ return await post(`/carpools/${carpoolId}/accept_invite`, {});
}
export async function denyRequest(carpoolId: number, userId: number) {
return await post(`/carpools/${carpoolId}/deny_request`, { userId });
}
-export async function denyInvite(carpoolId: number, userId: number) {
- return await post(`/carpools/${carpoolId}/deny_invite`, { userId });
+export async function denyInvite(carpoolId: number) {
+ return await post(`/carpools/${carpoolId}/deny_invite`, {});
}
export async function getMe() {
diff --git a/src/state/Notifications/NotificationsProvider.tsx b/src/state/Notifications/NotificationsProvider.tsx
index 4556f09..7afe2b0 100644
--- a/src/state/Notifications/NotificationsProvider.tsx
+++ b/src/state/Notifications/NotificationsProvider.tsx
@@ -7,11 +7,17 @@ export const NotificationsContext = createContext({
invitedCarpoolIds: {} as Record,
requestedCarpoolIds: {} as Record,
- sendCarpoolRequest: (carpoolId: number) =>
+ sendCarpoolRequest: async (carpoolId: number) =>
console.error('not implemented: sendCarpoolRequest'),
- cancelCarpoolRequest: (carpoolId: number) =>
+ cancelCarpoolRequest: async (carpoolId: number) =>
console.error('not implemented: cancelCarpoolRequest'),
+
+ acceptCarpoolInvite: async (carpoolId: number) =>
+ console.error('not implemented: acceptCarpoolInvite'),
+
+ denyCarpoolInvite: async (carpoolId: number) =>
+ console.error('not implemented: denyCarpoolInvite'),
});
export default function NotificationsProvider({
@@ -44,23 +50,41 @@ export default function NotificationsProvider({
}, [setInvitedCarpoolIds, setRequestedCarpoolIds]);
const sendCarpoolRequest = useCallback(
- (carpoolId: number) => {
- api.sendCarpoolRequest(carpoolId).then(() => {
- requestedCarpoolIds[carpoolId] = true;
- });
+ async (carpoolId: number) => {
+ await api.sendCarpoolRequest(carpoolId);
+
+ requestedCarpoolIds[carpoolId] = true;
},
[requestedCarpoolIds]
);
const cancelCarpoolRequest = useCallback(
- (carpoolId: number) => {
- api.cancelCarpoolRequest(carpoolId).then(() => {
- delete requestedCarpoolIds[carpoolId];
- });
+ async (carpoolId: number) => {
+ await api.cancelCarpoolRequest(carpoolId);
+
+ delete requestedCarpoolIds[carpoolId];
},
[requestedCarpoolIds]
);
+ const acceptCarpoolInvite = useCallback(
+ async (carpoolId: number) => {
+ await api.acceptInvite(carpoolId);
+
+ delete invitedCarpoolIds[carpoolId];
+ },
+ [invitedCarpoolIds]
+ );
+
+ const denyCarpoolInvite = useCallback(
+ async (carpoolId: number) => {
+ await api.denyInvite(carpoolId);
+
+ delete invitedCarpoolIds[carpoolId];
+ },
+ [invitedCarpoolIds]
+ );
+
return (
{children}