From 0b47a1045cc66a40cf39ae81ce2af51daf7aa598 Mon Sep 17 00:00:00 2001 From: xdzqyyds <2292136545@qq.com> Date: Wed, 4 Dec 2024 18:05:06 +0800 Subject: [PATCH] LOGIN --- webapp/components/window.tsx | 28 +++++++++++++++++----------- webapp/lib/api.ts | 5 ++++- 2 files changed, 21 insertions(+), 12 deletions(-) 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 */}