"use client"; import React, { useState, useCallback } from "react"; import { useRouter } from "next/navigation"; import { Box, Typography, Select, MenuItem, FormControl, InputLabel, Alert, } from "@mui/material"; import MatcherBoard from "./MatcherBoard/MatcherBoard"; import { MATCH_CONFIGS } from "./constants"; import { MatchableEntity, MatchConfig } from "./types"; import toast from "react-hot-toast"; interface MatcherPageClientProps { initialSourceItems: MatchableEntity[]; initialTargetItems: MatchableEntity[]; initialMatchType: string; config: MatchConfig; } export default function MatcherPageClient({ initialSourceItems, initialTargetItems, initialMatchType, config: initialConfig, }: MatcherPageClientProps) { const router = useRouter(); const [matchType, setMatchType] = useState(initialMatchType); const currentConfig = MATCH_CONFIGS[matchType] || initialConfig; const handleMatchTypeChange = (newType: string) => { setMatchType(newType); // Update URL and reload page to fetch new data via SSR router.push(`/dashboard/admin/matcher?type=${newType}`); router.refresh(); }; const handleMatch = useCallback( async (sourceId: string, targetId: string) => { try { // TODO: Call API endpoint to save the match // For now, just show a toast toast.success( `Matched ${currentConfig.sourceLabel} to ${currentConfig.targetLabel}` ); console.log("Match:", { sourceId, targetId, matchType, }); } catch (error) { toast.error("Failed to save match"); console.error("Error saving match:", error); } }, [currentConfig, matchType] ); return ( Entity Matcher Match Type Drag items from the left column to the right column to create matches. You can also drag items back to remove matches. ); }