🚸(frontend) align later meeting modal

Duplicated sources, bad practice, should be a unique and reusable
component. Debt, needs to be refactored.
This commit is contained in:
lebaudantoine
2024-09-09 18:26:33 +02:00
committed by aleb_the_flash
parent 80cc7c723f
commit b537cdfd93
4 changed files with 75 additions and 45 deletions

View File

@@ -1,8 +1,9 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { getRouteUrl } from '@/navigation/getRouteUrl' import { getRouteUrl } from '@/navigation/getRouteUrl'
import { Div, Button, Dialog, Input, type DialogProps, P } from '@/primitives' import { Button, Dialog, type DialogProps, P, Text } from '@/primitives'
import { HStack } from '@/styled-system/jsx' import { HStack } from '@/styled-system/jsx'
import { RiCheckLine, RiFileCopyLine, RiSpam2Fill } from '@remixicon/react'
// fixme - duplication with the InviteDialog // fixme - duplication with the InviteDialog
export const LaterMeetingDialog = ({ export const LaterMeetingDialog = ({
@@ -11,19 +12,17 @@ export const LaterMeetingDialog = ({
}: { roomId: string } & Omit<DialogProps, 'title'>) => { }: { roomId: string } & Omit<DialogProps, 'title'>) => {
const { t } = useTranslation('home') const { t } = useTranslation('home')
const roomUrl = getRouteUrl('room', roomId) const roomUrl = getRouteUrl('room', roomId)
const copyLabel = t('laterMeetingDialog.copy')
const copiedLabel = t('laterMeetingDialog.copied') const [isCopied, setIsCopied] = useState(false)
const [copyLinkLabel, setCopyLinkLabel] = useState(copyLabel)
useEffect(() => { useEffect(() => {
if (copyLinkLabel == copiedLabel) { if (isCopied) {
const timeout = setTimeout(() => { const timeout = setTimeout(() => setIsCopied(false), 3000)
setCopyLinkLabel(copyLabel) return () => clearTimeout(timeout)
}, 5000)
return () => {
clearTimeout(timeout)
}
} }
}, [copyLinkLabel, copyLabel, copiedLabel]) }, [isCopied])
const [isHovered, setIsHovered] = useState(false)
return ( return (
<Dialog <Dialog
@@ -32,31 +31,62 @@ export const LaterMeetingDialog = ({
title={t('laterMeetingDialog.heading')} title={t('laterMeetingDialog.heading')}
> >
<P>{t('laterMeetingDialog.description')}</P> <P>{t('laterMeetingDialog.description')}</P>
<HStack alignItems="stretch" gap="gutter"> <Button
<Div flex="1"> variant={isCopied ? 'success' : 'primary'}
<Input size="sm"
type="text" fullWidth
aria-label={t('laterMeetingDialog.inputLabel')} aria-label={t('laterMeetingDialog.copy')}
value={roomUrl} style={{
readOnly justifyContent: 'start',
onClick={(e) => { }}
e.currentTarget.select() onPress={() => {
}} navigator.clipboard.writeText(roomUrl)
/> setIsCopied(true)
</Div> }}
<Div minWidth="8rem"> onHoverChange={setIsHovered}
<Button >
variant="primary" {isCopied ? (
size="sm" <>
fullWidth <RiCheckLine size={18} style={{ marginRight: '8px' }} />
onPress={() => { {t('laterMeetingDialog.copied')}
navigator.clipboard.writeText(roomUrl) </>
setCopyLinkLabel(copiedLabel) ) : (
}} <>
> <RiFileCopyLine
{copyLinkLabel} size={18}
</Button> style={{ marginRight: '8px', minWidth: '18px' }}
</Div> />
{isHovered ? (
t('laterMeetingDialog.copy')
) : (
<div
style={{
textOverflow: 'ellipsis',
overflow: 'hidden',
userSelect: 'none',
textWrap: 'nowrap',
}}
>
{roomUrl.replace(/^https?:\/\//, '')}
</div>
)}
</>
)}
</Button>
<HStack>
<div
style={{
backgroundColor: '#d9e5ff',
borderRadius: '50%',
padding: '4px',
marginTop: '1rem',
}}
>
<RiSpam2Fill size={22} style={{ fill: '#4c84fc' }} />
</div>
<Text variant="sm" style={{ marginTop: '1rem' }}>
{t('laterMeetingDialog.permissions')}
</Text>
</HStack> </HStack>
</Dialog> </Dialog>
) )

View File

@@ -17,8 +17,8 @@
"laterMeetingDialog": { "laterMeetingDialog": {
"heading": "", "heading": "",
"description": "", "description": "",
"copied": "",
"copy": "", "copy": "",
"inputLabel": "" "copied": "",
"permissions": ""
} }
} }

View File

@@ -17,8 +17,8 @@
"laterMeetingDialog": { "laterMeetingDialog": {
"heading": "Your connection details", "heading": "Your connection details",
"description": "Send this link to the people you want to invite to the meeting. They will be able to join without Agent Connect.", "description": "Send this link to the people you want to invite to the meeting. They will be able to join without Agent Connect.",
"copied": "Copied", "copy": "Copy the meeting link",
"copy": "Copy", "copied": "Link copied to clipboard",
"inputLabel": "Meeting link" "permissions": "People with this link do not need your permission to join this meeting."
} }
} }

View File

@@ -17,8 +17,8 @@
"laterMeetingDialog": { "laterMeetingDialog": {
"heading": "Vos informations de connexion", "heading": "Vos informations de connexion",
"description": "Envoyez ce lien aux personnes que vous souhaitez inviter à la réunion. Ils pourront la rejoindre sans Agent Connect.", "description": "Envoyez ce lien aux personnes que vous souhaitez inviter à la réunion. Ils pourront la rejoindre sans Agent Connect.",
"copied": "Lien copié", "copy": "Copier le lien de la réunion",
"copy": "Copier le lien", "copied": "Lien copié dans le presse-papiers",
"inputLabel": "Lien vers la réunion" "permissions": "Les personnes disposant de ce lien n'ont pas besoin de votre autorisation pour rejoindre cette réunion."
} }
} }