diff --git a/webapp/components/window.tsx b/webapp/components/window.tsx index 5403292..ecb766f 100644 --- a/webapp/components/window.tsx +++ b/webapp/components/window.tsx @@ -8,14 +8,16 @@ interface InviteWindowProps { inviteeId: string } +interface Invitation { + value: string; +} + export default function InviteWindow({ inviteeId }: InviteWindowProps) { - const [invitation, setInvitation] = useState(null) + const [invitation, setInvitation] = useState(null) const [isOpen, setIsOpen] = useState(false) const [_, setLoc] = useAtom(locationAtom) const [__, setAtomMeetingId] = useAtom(meetingIdAtom) - type invitation = { value: string } - const checkInvitation = async () => { try { const value = await getInvitation(inviteeId) @@ -24,7 +26,9 @@ export default function InviteWindow({ inviteeId }: InviteWindowProps) { setInvitation(value) setIsOpen(true) } - } catch { /* empty */ } + } catch (error) { + console.error('Failed to check invitation:', error) + } } useEffect(() => { @@ -35,12 +39,14 @@ export default function InviteWindow({ inviteeId }: InviteWindowProps) { const handleAccept = () => { console.log('Accepted the invitation') - const invitationValue = invitation?.value - const roomId = invitationValue.split(' ')[0] - setStorageMeeting(roomId) - setAtomMeetingId(roomId) - setLoc(prev => ({ ...prev, pathname: `/${roomId}` })) - setIsOpen(false) + if (invitation) { + const invitationValue = invitation.value + const roomId = invitationValue.split(' ')[0] + setStorageMeeting(roomId) + setAtomMeetingId(roomId) + setLoc(prev => ({ ...prev, pathname: `/${roomId}` })) + setIsOpen(false) + } } const handleReject = () => { @@ -54,7 +60,7 @@ export default function InviteWindow({ inviteeId }: InviteWindowProps) {

You have an invitation!

- {invitation.value} + {invitation.value} {/* 直接访问 value */}