'use client'; import { useState } from 'react'; import dynamic from 'next/dynamic'; import { Form, Input, Button, message } from 'antd'; const Modal = dynamic(() => import('antd/lib/modal'), { ssr: false }); interface CreateRoomModalProps { onClose: () => void; onSubmit: (data: { name: string; objective: string; participants: { id: string }[] }) => void; currentSecondMeId: string; } function CreateRoomModal({ onClose, onSubmit, currentSecondMeId }: CreateRoomModalProps) { const [form] = Form.useForm(); const [participants, setParticipants] = useState([{ id: currentSecondMeId }]); const handleSubmit = () => { if (participants.length < 2) { message.error('A room must have at least 2 participants.'); return; } // Verify all participants have valid URLs const invalidParticipants = participants.filter( (p) => !p.id.startsWith('https://secondme.com/') ); if (invalidParticipants.length > 0) { message.error('All participants must have valid SecondMe URLs (https://secondme.com/xxxxx)'); return; } form.validateFields().then((values) => { onSubmit({ name: values.name, objective: values.objective, participants }); }); }; const addParticipant = () => { setParticipants([...participants, { id: '' }]); }; const updateParticipant = (index: number, id: string) => { const newParticipants = [...participants]; newParticipants[index] = { id }; setParticipants(newParticipants); }; return ( Cancel , ]} onCancel={onClose} open={true} title="Create New Room" width={600} >

Participants

At least 2 participants required

{participants.map((participant, index) => (
Enter the full URL of the SecondMe instance (e.g., https://secondme.com/23581)
updateParticipant(index, e.target.value)} placeholder="https://secondme.com/xxxxx" value={participant.id} />
))}
); } export default dynamic(() => Promise.resolve(CreateRoomModal), { ssr: false });