diff --git a/src/components/dashboard/Officer_EventRequestForm.astro b/src/components/dashboard/Officer_EventRequestForm.astro index 85398ea..433f2c3 100644 --- a/src/components/dashboard/Officer_EventRequestForm.astro +++ b/src/components/dashboard/Officer_EventRequestForm.astro @@ -3,9 +3,8 @@ import { Authentication } from "../../scripts/pocketbase/Authentication"; import { Update } from "../../scripts/pocketbase/Update"; import { FileManager } from "../../scripts/pocketbase/FileManager"; import { Get } from "../../scripts/pocketbase/Get"; -import { toast } from "react-hot-toast"; -import Toast from "./universal/Toast"; -import { Icon } from "@iconify/react"; +import { toast, Toaster } from "react-hot-toast"; + // Form sections import PRSection from "./Officer_EventRequestForm/PRSection"; @@ -58,7 +57,7 @@ if (auth.isAuthenticated()) { ---
- +

@@ -291,7 +290,6 @@ if (auth.isAuthenticated()) { import { FileManager } from "../../scripts/pocketbase/FileManager"; import { Get } from "../../scripts/pocketbase/Get"; import { toast } from "react-hot-toast"; - import { showLoadingToast, showSuccessToast, showErrorToast } from "./Officer_EventRequestForm/ToastNotifications"; // Add TypeScript interfaces interface EventRequest { @@ -346,7 +344,7 @@ if (auth.isAuthenticated()) { } // Show loading toast - const loadingToastId = toast.custom(showLoadingToast, { duration: 0 }); + const loadingToastId = toast.loading('Submitting event request...'); // Get graphics need value const needsGraphics = form.querySelector('input[name="needsGraphics"]:checked')?.value === "yes"; @@ -421,19 +419,15 @@ if (auth.isAuthenticated()) { } } - // Dismiss loading toast + // Dismiss loading toast and show success toast.dismiss(loadingToastId); - - // Show success toast - toast.custom(() => showSuccessToast('Event request submitted successfully!')); + toast.success('Event request submitted successfully!'); // Reset form form.reset(); } catch (error) { console.error("Error submitting form:", error); - - // Show error toast - toast.custom(() => showErrorToast('Failed to submit event request. Please try again.')); + toast.error('Failed to submit event request. Please try again.'); } }); @@ -465,13 +459,10 @@ if (auth.isAuthenticated()) { } await update.updateFields("event_request", data.id || "", data); - - // Show success toast - toast.custom(() => showSuccessToast('Draft saved successfully!')); + toast.success('Draft saved successfully!'); } catch (error) { console.error("Error saving draft:", error); - // Show error toast - toast.custom(() => showErrorToast('Error saving draft. Please try again.')); + toast.error('Error saving draft. Please try again.'); } }); @@ -522,7 +513,7 @@ if (auth.isAuthenticated()) { }) .catch((error: Error) => { console.error("Failed to load request:", error); - alert("Failed to load request. Please try again."); + toast.error("Failed to load request. Please try again."); }); }; @@ -557,7 +548,7 @@ if (auth.isAuthenticated()) { }) .catch((error: Error) => { console.error("Failed to load request:", error); - alert("Failed to load request details. Please try again."); + toast.error("Failed to load request details. Please try again."); }); }; diff --git a/src/components/dashboard/Officer_EventRequestForm/ToastNotifications.tsx b/src/components/dashboard/Officer_EventRequestForm/ToastNotifications.tsx deleted file mode 100644 index 8ec7580..0000000 --- a/src/components/dashboard/Officer_EventRequestForm/ToastNotifications.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import { Icon } from '@iconify/react'; - -export const showLoadingToast = () => ( -
- - Submitting event request... -
-); - -export const showSuccessToast = (message: string) => ( -
- - {message} -
-); - -export const showErrorToast = (message: string) => ( -
- - {message} -
-); - -export const showWarningToast = (message: string) => ( -
- - {message} -
-); - -export const showInfoToast = (message: string) => ( -
- - {message} -
-); \ No newline at end of file diff --git a/src/components/dashboard/universal/Toast.tsx b/src/components/dashboard/universal/Toast.tsx deleted file mode 100644 index 79dc2e2..0000000 --- a/src/components/dashboard/universal/Toast.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import React from 'react'; -import { Toaster } from 'react-hot-toast'; - -// This is just a wrapper component to make react-hot-toast work with Astro -const Toast: React.FC = () => { - return ( - - ); -}; - -export default Toast; \ No newline at end of file