mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 03:10:17 -04:00
18 lines
566 B
TypeScript
18 lines
566 B
TypeScript
import { useContext, useEffect, useState } from 'react';
|
|
import { getReceivedInvitationsAndRequests } from './api';
|
|
import AuthenticationContext from './Authentication/AuthenticationContext';
|
|
import { IInvitation } from './types';
|
|
|
|
export const useAuth = () => useContext(AuthenticationContext);
|
|
export const useMe = () => useAuth().user;
|
|
|
|
export function useNotifications() {
|
|
const [notifications, setNotifications] = useState<IInvitation[]>([]);
|
|
|
|
useEffect(() => {
|
|
getReceivedInvitationsAndRequests().then(setNotifications);
|
|
}, []);
|
|
|
|
return notifications;
|
|
}
|