Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count meetings and associate feedback #118

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 39 additions & 23 deletions app/components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
import { VisuallyHidden } from '@radix-ui/react-visually-hidden'
import type { FC } from 'react'
import { useState } from 'react'
import {
type ComponentProps,
type ElementRef,
forwardRef,
type ReactNode,
useState,
} from 'react'
import { useTimeoutFn } from 'react-use'
import { useRoomUrl } from '~/hooks/useRoomUrl'
import { Button } from './Button'
import { Icon } from './Icon/Icon'
import { Tooltip } from './Tooltip'

interface CopyButtonProps {}

export const CopyButton: FC<CopyButtonProps> = () => {
const [copied, setCopied] = useState(false)
interface CopyButtonProps extends ComponentProps<'button'> {
contentValue: string
copiedMessage?: ReactNode
}

const roomUrl = useRoomUrl()
export const CopyButton = forwardRef<ElementRef<'button'>, CopyButtonProps>(
(
{
children = <VisuallyHidden>Copy</VisuallyHidden>,
copiedMessage = <VisuallyHidden>Copied!</VisuallyHidden>,
contentValue,
onClick,
...rest
},
ref
) => {
const [copied, setCopied] = useState(false)

const [_isReady, _cancel, reset] = useTimeoutFn(() => {
setCopied(false)
}, 2000)
const [_isReady, _cancel, reset] = useTimeoutFn(() => {
setCopied(false)
}, 2000)

return (
<Tooltip
content={copied ? 'Copied!' : 'Copy URL'}
open={copied ? true : undefined}
>
return (
<Button
displayType="secondary"
onClick={() => {
navigator.clipboard.writeText(roomUrl)
onClick={(e) => {
onClick && onClick(e)
navigator.clipboard.writeText(contentValue)
setCopied(true)
reset()
}}
ref={ref}
className="flex items-center gap-2 text-xs"
{...rest}
>
<Icon
type={copied ? 'ClipboardDocumentCheckIcon' : 'ClipboardDocumentIcon'}
className="text-xl"
/>
<VisuallyHidden>{copied ? 'Copied!' : 'Copy URL'}</VisuallyHidden>
{copied ? copiedMessage : children}
</Button>
</Tooltip>
)
}
)
}
)

CopyButton.displayName = 'CopyButton'
8 changes: 7 additions & 1 deletion app/components/LeaveRoomButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ import { Tooltip } from './Tooltip'

interface LeaveRoomButtonProps {
navigateToFeedbackPage: boolean
meetingId?: string
}

export const LeaveRoomButton: FC<LeaveRoomButtonProps> = ({
navigateToFeedbackPage,
meetingId,
}) => {
const navigate = useNavigate()
return (
<Tooltip content="Leave">
<Button
displayType="danger"
onClick={() => {
navigate(navigateToFeedbackPage ? '/call-quality-feedback' : '/')
const params = new URLSearchParams()
if (meetingId) params.set('meetingId', meetingId)
navigate(
navigateToFeedbackPage ? `/call-quality-feedback?${params}` : '/'
)
}}
>
<VisuallyHidden>Leave</VisuallyHidden>
Expand Down
Loading
Loading