From 92ff4de6a44c18e487c2ce9d5918e83a69753c74 Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 1 Dec 2024 22:52:48 +0200 Subject: [PATCH 1/3] work on notifications --- src/components/sidebar/navHeader.tsx | 2 +- src/hooks/useAdminNotifications.ts | 5 ++++- src/pages/tickets/createTicketModal.tsx | 9 +++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/sidebar/navHeader.tsx b/src/components/sidebar/navHeader.tsx index 73b974a4f..7709e2e7d 100644 --- a/src/components/sidebar/navHeader.tsx +++ b/src/components/sidebar/navHeader.tsx @@ -99,7 +99,7 @@ function NavBar() { const handleShowNotification = () => { const notificationPath = roleName === "superAdmin" || roleName === "admin" ? "/admin/notifications" : "/applicant/notifications"; navigate(notificationPath); - window.location.reload(); + // window.location.reload(); }; const handleShowProfileDropdown = () => setShowProfileDropdown(!showProfileDropdown); diff --git a/src/hooks/useAdminNotifications.ts b/src/hooks/useAdminNotifications.ts index f12aa061f..95be3687a 100644 --- a/src/hooks/useAdminNotifications.ts +++ b/src/hooks/useAdminNotifications.ts @@ -1,5 +1,7 @@ import { useEffect, useState } from "react"; import { initializeAdminPusher, unsubscribeAdminPusher } from "../utils/adminNotifications/pusher"; +import { toastOptions } from "../utils/toast"; +import { toast } from "react-toastify"; interface Notification { _id: string; @@ -9,10 +11,11 @@ interface Notification { } export const useAdminNotifications = () => { const [notifications, setNotifications] = useState([]); - + useEffect(() => { const handleNewNotification = (notification: Notification) => { setNotifications((prev) => [...prev, notification]); + toast.info(`New notification: ${notification.message}`, toastOptions); }; const channel = initializeAdminPusher(handleNewNotification); diff --git a/src/pages/tickets/createTicketModal.tsx b/src/pages/tickets/createTicketModal.tsx index 055369467..6d35f2597 100644 --- a/src/pages/tickets/createTicketModal.tsx +++ b/src/pages/tickets/createTicketModal.tsx @@ -1,6 +1,7 @@ import React, { useState} from "react"; import { toast, ToastContainer } from "react-toastify"; import * as icons from "react-icons/ai"; +import { AiOutlineLoading3Quarters } from "react-icons/ai"; const CreateTicketModal = ({ isOpen, onClose, onSubmit }) => { const [ticket, setTicket] = useState({ @@ -93,7 +94,11 @@ const CreateTicketModal = ({ isOpen, onClose, onSubmit }) => { className="flex bg-primary dark:bg-[#56C870] rounded-md py-2 px-4 text-white font-medium cursor-pointer" disabled={isSubmitting} > - Submit + {isSubmitting ? ( + + ) : ( + "Submit" + )}