"use client"; import { useState, useEffect } from "react"; import { useMediaQuery } from "../../hooks/useMediaQuery"; import HeaderLockup from "../../components/type/HeaderLockup"; import MultiSelect from "../../components/controls/MultiSelect"; import Alert from "../../components/modals/Alert"; import type { ChipOption } from "../../components/controls/MultiSelect/MultiSelect.types"; import { useCreateFlow } from "../context/CreateFlowContext"; const TITLE = "Do other stakeholders need to be involved in creating your community?"; const DESCRIPTION = "Adding people at this step will invite them to see your proposed CommunityRule and make their own proposals."; const DRAFT_TOAST_TITLE = "Congratulations! You've drafted your CommunityRule!"; /** * Confirm stakeholders step — stacked lockup + MultiSelect (not split columns). * Figma: 21104-46594. */ export default function ConfirmStakeholdersPage() { const { markCreateFlowInteraction } = useCreateFlow(); const [isMounted, setIsMounted] = useState(false); const [toastDismissed, setToastDismissed] = useState(false); const [stakeholderOptions, setStakeholderOptions] = useState( [], ); const isMdOrLarger = useMediaQuery("(min-width: 640px)"); useEffect(() => { // eslint-disable-next-line react-hooks/set-state-in-effect -- intentional: defer layout breakpoint until after mount to prevent flash setIsMounted(true); }, []); const effectiveMdOrLarger = !isMounted || isMdOrLarger; const handleAddStakeholder = () => { markCreateFlowInteraction(); setStakeholderOptions((prev) => [ ...prev, { id: crypto.randomUUID(), label: "", state: "Custom" }, ]); }; const handleCustomChipConfirm = (chipId: string, value: string) => { markCreateFlowInteraction(); setStakeholderOptions((prev) => prev.map((opt) => opt.id === chipId ? { ...opt, label: value, state: "Selected" } : opt, ), ); }; const handleCustomChipClose = (chipId: string) => { markCreateFlowInteraction(); setStakeholderOptions((prev) => prev.filter((opt) => opt.id !== chipId)); }; const handleChipClick = (chipId: string) => { markCreateFlowInteraction(); setStakeholderOptions((prev) => prev.filter((opt) => opt.id !== chipId)); }; return ( <>
{!toastDismissed && (
setToastDismissed(true)} className="w-full !px-[var(--space-600,24px)] !py-[var(--space-400,16px)] md:!py-4" />
)} ); }