2022-11-23 02:55:25 +00:00
|
|
|
import { PencilAltIcon, PlusIcon, XIcon } from "@heroicons/react/solid";
|
2022-05-01 20:42:35 +00:00
|
|
|
import { useState } from "react";
|
|
|
|
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2022-11-23 02:55:25 +00:00
|
|
|
import { Button } from "@calcom/ui";
|
2022-05-01 20:42:35 +00:00
|
|
|
|
|
|
|
import { SearchDialog } from "./SearchDialog";
|
|
|
|
|
|
|
|
interface ISelectGifInput {
|
|
|
|
defaultValue?: string | null;
|
|
|
|
onChange: (url: string) => void;
|
|
|
|
}
|
|
|
|
export default function SelectGifInput(props: ISelectGifInput) {
|
|
|
|
const { t } = useLocale();
|
|
|
|
const [selectedGif, setSelectedGif] = useState(props.defaultValue);
|
|
|
|
const [showDialog, setShowDialog] = useState(false);
|
|
|
|
|
|
|
|
return (
|
2023-01-04 07:38:45 +00:00
|
|
|
<div className="flex flex-col items-start space-x-2 space-y-2 rtl:space-x-reverse">
|
2022-05-01 20:42:35 +00:00
|
|
|
{selectedGif && (
|
2022-05-30 16:23:23 +00:00
|
|
|
<div className="min-h-[200px]">
|
2022-07-12 17:50:04 +00:00
|
|
|
<img alt="Selected Gif Image" src={selectedGif} />
|
2022-05-01 20:42:35 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div className="flex">
|
2022-05-30 16:23:23 +00:00
|
|
|
{selectedGif ? (
|
|
|
|
<Button color="minimal" type="button" StartIcon={PencilAltIcon} onClick={() => setShowDialog(true)}>
|
|
|
|
Change
|
|
|
|
</Button>
|
|
|
|
) : (
|
|
|
|
<Button color="minimal" type="button" StartIcon={PlusIcon} onClick={() => setShowDialog(true)}>
|
|
|
|
Add from Giphy
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
|
2022-05-01 20:42:35 +00:00
|
|
|
{selectedGif && (
|
|
|
|
<Button
|
2022-11-23 02:55:25 +00:00
|
|
|
color="destructive"
|
2022-05-01 20:42:35 +00:00
|
|
|
type="button"
|
2022-05-30 16:23:23 +00:00
|
|
|
StartIcon={XIcon}
|
2022-05-01 20:42:35 +00:00
|
|
|
onClick={() => {
|
|
|
|
setSelectedGif("");
|
|
|
|
props.onChange("");
|
|
|
|
}}>
|
|
|
|
{t("remove")}
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
<SearchDialog
|
|
|
|
isOpenDialog={showDialog}
|
|
|
|
setIsOpenDialog={setShowDialog}
|
|
|
|
onSave={(url) => {
|
|
|
|
setSelectedGif(url);
|
|
|
|
props.onChange(url);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|