import { ChangeEvent, FormEvent, useState } from 'react'
import { Button, HStack, Input, Stack } from '@chakra-ui/react'
import { SearchContextManager } from '@giphy/react-components'
import { UploadButton } from '../buttons/UploadButton'
import { GiphySearch } from './GiphySearch'
import { useTypebot } from 'contexts/TypebotContext'
import { ImageBubbleContent } from 'models'
type Props = {
content?: ImageBubbleContent
onSubmit: (content: ImageBubbleContent) => void
}
export const ImageUploadContent = ({ content, onSubmit }: Props) => {
const [currentTab, setCurrentTab] = useState<'link' | 'upload' | 'giphy'>(
'upload'
)
const handleSubmit = (url: string) => onSubmit({ url })
return (
{process.env.NEXT_PUBLIC_GIPHY_API_KEY && (
)}
)
}
const BodyContent = ({
tab,
url,
onSubmit,
}: {
tab: 'upload' | 'link' | 'giphy'
url?: string
onSubmit: (url: string) => void
}) => {
switch (tab) {
case 'upload':
return
case 'link':
return
case 'giphy':
return
}
}
type ContentProps = { initialUrl?: string; onNewUrl: (url: string) => void }
const UploadFileContent = ({ onNewUrl }: ContentProps) => {
const { typebot } = useTypebot()
return (
Choose an image
)
}
const EmbedLinkContent = ({ initialUrl, onNewUrl }: ContentProps) => {
const [imageUrl, setImageUrl] = useState(initialUrl ?? '')
const handleImageUrlChange = (e: ChangeEvent) =>
setImageUrl(e.target.value)
const handleUrlSubmit = (e: FormEvent) => {
e.preventDefault()
onNewUrl(imageUrl)
}
return (
)
}
const GiphyContent = ({ onNewUrl }: ContentProps) => (
)