- Redesign landing page with unified Omnibox search - Add ComparisonToast for better comparison flow visibility - Add visual 'Added' state to SchoolCard - Add info tooltips to educational metrics - Optimize mobile map view with Bottom Sheet - Standardize distance display to miles
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
import Link from 'next/link';
|
|
import { useComparison } from '@/hooks/useComparison';
|
|
import { usePathname } from 'next/navigation';
|
|
import styles from './ComparisonToast.module.css';
|
|
|
|
export function ComparisonToast() {
|
|
const { selectedSchools, clearAll } = useComparison();
|
|
const [mounted, setMounted] = useState(false);
|
|
const pathname = usePathname();
|
|
|
|
useEffect(() => {
|
|
setMounted(true);
|
|
}, []);
|
|
|
|
if (!mounted) return null;
|
|
|
|
// Don't show toast on the compare page itself
|
|
if (pathname === '/compare') return null;
|
|
|
|
if (selectedSchools.length === 0) return null;
|
|
|
|
return (
|
|
<div className={styles.toastContainer}>
|
|
<div className={styles.toastContent}>
|
|
<div className={styles.toastInfo}>
|
|
<span className={styles.toastBadge}>{selectedSchools.length}</span>
|
|
<span className={styles.toastText}>
|
|
{selectedSchools.length === 1 ? 'school' : 'schools'} selected
|
|
</span>
|
|
</div>
|
|
<div className={styles.toastActions}>
|
|
<button onClick={clearAll} className={styles.btnClear}>
|
|
Clear
|
|
</button>
|
|
<Link href="/compare" className={styles.btnCompare}>
|
|
Compare Now
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|