diff --git a/app/(main)/dashboard/page.tsx b/app/(main)/dashboard/page.tsx index a6d5a80..e90ad5b 100644 --- a/app/(main)/dashboard/page.tsx +++ b/app/(main)/dashboard/page.tsx @@ -12,6 +12,7 @@ import { LayoutContext } from '../../../layout/context/layoutcontext'; //import { Demo } from '@/types'; import { ChartData, ChartOptions } from 'chart.js'; import { Toast } from 'primereact/toast'; +import AppMessages, { AppMessage } from '@/components/AppMessages'; const lineData: ChartData = { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], @@ -41,7 +42,7 @@ const Dashboard = () => { const menu2 = useRef(null); const [lineOptions, setLineOptions] = useState({}); const { layoutConfig } = useContext(LayoutContext); - const toast = useRef(null); + const appMsg = useRef(null); const applyLightTheme = () => { const lineOptions: ChartOptions = { @@ -108,20 +109,11 @@ const Dashboard = () => { }; const invitationResponse = (isSucceeded: boolean) => { - let summary = 'Success'; - let detail = 'We have successfully enrolled you into the class'; - if (!isSucceeded) { - summary = 'Error Enrolling'; - detail = 'Please contact customer support for more info.'; + appMsg.current?.showError("Error enrolling to the class. Please contact customer support for more info.") + } else { + appMsg.current?.showSuccess("We have successfully enrolled you into the class"); } - - toast.current?.show({ - severity: isSucceeded ? 'success' : 'error', - summary: summary, - detail: detail, - life: 5000 //3 secs - }); }; useEffect(() => { @@ -138,7 +130,7 @@ const Dashboard = () => { invitationResponse(invitationResult); } }, 500); - }, [layoutConfig.colorScheme, toast]); + }, [layoutConfig.colorScheme]); const formatCurrency = (value: number) => { return value?.toLocaleString('en-US', { @@ -149,7 +141,7 @@ const Dashboard = () => { return (
- +