2023-09-12 18:44:15 +03:00
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
|
|
|
import { useChatContext } from "@/lib/context";
|
|
|
|
|
|
|
|
import { checkIfHasPendingRequest } from "../utils/checkIfHasPendingRequest";
|
2023-09-05 11:49:29 +03:00
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
|
export const useActionBar = () => {
|
2023-09-07 11:00:45 +03:00
|
|
|
const [shouldDisplayUploadCard, setShouldDisplayUploadCard] = useState(false);
|
2023-09-05 11:49:29 +03:00
|
|
|
|
2023-09-12 18:44:15 +03:00
|
|
|
const [hasPendingRequests, setHasPendingRequests] = useState(false);
|
|
|
|
const { notifications } = useChatContext();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setHasPendingRequests(checkIfHasPendingRequest(notifications));
|
|
|
|
}, [notifications]);
|
|
|
|
|
2023-09-05 11:49:29 +03:00
|
|
|
return {
|
2023-09-07 11:00:45 +03:00
|
|
|
shouldDisplayUploadCard,
|
|
|
|
setShouldDisplayUploadCard,
|
2023-09-12 18:44:15 +03:00
|
|
|
hasPendingRequests,
|
2023-09-12 19:00:46 +03:00
|
|
|
setHasPendingRequests,
|
2023-09-05 11:49:29 +03:00
|
|
|
};
|
|
|
|
};
|