2022-01-20 17:45:25 +01:00
|
|
|
import { Stack, Text } from '@chakra-ui/react'
|
2023-10-12 14:48:52 +02:00
|
|
|
import {
|
|
|
|
VariableString,
|
|
|
|
VideoBubbleContent,
|
|
|
|
VideoBubbleContentType,
|
|
|
|
} from '@typebot.io/schemas'
|
|
|
|
import { NumberInput, TextInput } from '@/components/inputs'
|
2023-10-27 09:23:50 +02:00
|
|
|
import { useTranslate } from '@tolgee/react'
|
2023-10-03 11:44:51 +02:00
|
|
|
import { parseVideoUrl } from '@typebot.io/lib/parseVideoUrl'
|
2023-07-21 08:02:15 +02:00
|
|
|
|
2022-01-20 17:45:25 +01:00
|
|
|
type Props = {
|
|
|
|
content?: VideoBubbleContent
|
|
|
|
onSubmit: (content: VideoBubbleContent) => void
|
|
|
|
}
|
|
|
|
|
|
|
|
export const VideoUploadContent = ({ content, onSubmit }: Props) => {
|
2023-10-27 09:23:50 +02:00
|
|
|
const { t } = useTranslate()
|
2023-10-12 14:48:52 +02:00
|
|
|
const updateUrl = (url: string) => {
|
2023-07-21 08:02:15 +02:00
|
|
|
const info = parseVideoUrl(url)
|
|
|
|
return onSubmit({
|
|
|
|
type: info.type,
|
|
|
|
url,
|
|
|
|
id: info.id,
|
|
|
|
})
|
2022-01-20 17:45:25 +01:00
|
|
|
}
|
2023-10-12 14:48:52 +02:00
|
|
|
const updateHeight = (height?: number | VariableString) => {
|
|
|
|
return onSubmit({
|
|
|
|
...content,
|
|
|
|
height,
|
|
|
|
})
|
|
|
|
}
|
2022-01-20 17:45:25 +01:00
|
|
|
return (
|
2023-10-12 14:48:52 +02:00
|
|
|
<Stack p="2" spacing={4}>
|
|
|
|
<Stack>
|
|
|
|
<TextInput
|
2023-10-27 09:23:50 +02:00
|
|
|
placeholder={t(
|
|
|
|
'editor.blocks.bubbles.video.settings.worksWith.placeholder'
|
|
|
|
)}
|
2023-10-12 14:48:52 +02:00
|
|
|
defaultValue={content?.url ?? ''}
|
|
|
|
onChange={updateUrl}
|
|
|
|
/>
|
|
|
|
<Text fontSize="sm" color="gray.400" textAlign="center">
|
2023-10-27 09:23:50 +02:00
|
|
|
{t('editor.blocks.bubbles.video.settings.worksWith.text')}
|
2023-10-12 14:48:52 +02:00
|
|
|
</Text>
|
|
|
|
</Stack>
|
|
|
|
|
|
|
|
{content?.type !== VideoBubbleContentType.URL && (
|
|
|
|
<NumberInput
|
|
|
|
label="Height:"
|
|
|
|
defaultValue={content?.height ?? 400}
|
|
|
|
onValueChange={updateHeight}
|
2023-10-27 09:23:50 +02:00
|
|
|
suffix={t('editor.blocks.bubbles.video.settings.numberInput.unit')}
|
2023-10-12 14:48:52 +02:00
|
|
|
width="150px"
|
|
|
|
/>
|
|
|
|
)}
|
2022-01-20 17:45:25 +01:00
|
|
|
</Stack>
|
|
|
|
)
|
|
|
|
}
|