Skip to content

Commit

Permalink
Merge branch 'fixes-for-launch' of https://github.com/adityathakurxd/…
Browse files Browse the repository at this point in the history
…make-real into fixes-for-launch
  • Loading branch information
KaustubhKumar05 committed Mar 11, 2024
2 parents a57a70a + e741459 commit 286c4f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
15 changes: 13 additions & 2 deletions app/components/JoinForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'
import { ArrowRightIcon, Svg100MsLogoIcon } from '@100mslive/react-icons'
import { ArrowRightIcon, RefreshIcon, Svg100MsLogoIcon } from '@100mslive/react-icons'
import { useHMSActions } from '@100mslive/react-sdk'
import Image from 'next/image'
import { useState, ChangeEvent, FormEvent, useEffect } from 'react'
Expand All @@ -21,6 +21,7 @@ const JoinForm = () => {

const searchParams = useSearchParams()
const roomCodeParam = searchParams.get('room') || ''
const [loading, setLoading] = useState(false)

const handleTabClick = (tab) => {
setActiveTabRole(tab)
Expand All @@ -42,6 +43,7 @@ const JoinForm = () => {
// Type the event parameter
const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault()
setLoading(true)

const { name: userName = '', roomCode = '' } = inputValues

Expand Down Expand Up @@ -97,9 +99,11 @@ const JoinForm = () => {
await hmsActions.join({ userName, authToken })
}
} else {
setLoading(false)
alert('Failed to create a new room')
}
} catch (e) {
setLoading(false)
alert('Failed to join room')
}
}
Expand Down Expand Up @@ -152,7 +156,14 @@ const JoinForm = () => {
)}

<button type="submit" className="btn-primary primary">
{roomCodeParam ? 'Accept Invite' : 'Join Room'}
{loading ? (
<RefreshIcon style={{ animation: 'spin 2s linear infinite' }} />
) : roomCodeParam ? (
'Accept Invite'
) : (
'Join Room'
)}

<ArrowRightIcon height={20} width={20} style={{ marginLeft: '4px' }} />
</button>
</form>
Expand Down
15 changes: 13 additions & 2 deletions app/components/PollForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useQuestionContext } from '../context'
import { makeReal } from '../makeReal'
import { useEditor, useToasts } from '@tldraw/tldraw'
import { toast } from 'react-toastify'
import { RefreshIcon } from '@100mslive/react-icons'

interface PollFormProps {
onClose: () => void
Expand All @@ -18,6 +19,7 @@ const PollForm: React.FC<PollFormProps> = ({ onClose }) => {

const { questionData, setQuestionData } = useQuestionContext()
const [localQuestionData, setLocalQuestionData] = useState(questionData)
const [loading, setLoading] = useState(false)

useEffect(() => {
setLocalQuestionData(questionData)
Expand All @@ -33,8 +35,10 @@ const PollForm: React.FC<PollFormProps> = ({ onClose }) => {
},
question
)
setLoading(false)
} catch (e) {
console.error(e)
setLoading(false)
addToast({
icon: 'cross-2',
title: 'Something went wrong',
Expand Down Expand Up @@ -126,9 +130,16 @@ const PollForm: React.FC<PollFormProps> = ({ onClose }) => {
width: 120,
padding: 8,
}}
onClick={() => regenerateQuestion(localQuestionData.question)}
onClick={() => {
setLoading(true)
regenerateQuestion(localQuestionData.question)
}}
>
Regenerate
{loading ? (
<RefreshIcon style={{ animation: 'spin 2s linear infinite' }} />
) : (
'Regenerate'
)}
</button>
<button className="primary" onClick={createPollOnClick}>
Launch Poll
Expand Down

0 comments on commit 286c4f8

Please sign in to comment.