// @ts-ignore import React, { useMemo, useState } from 'react'; import { FileDownloadOutlined, Share } from '@mui/icons-material'; import { toast } from 'react-hot-toast'; import { CircularProgress, Divider } from '@mui/material'; import { useColorPalates } from '@samagra-x/stencil-hooks'; import { useUiConfig } from '@samagra-x/stencil-hooks'; const ShareButtons = () => { const config = useUiConfig('component', 'shareButton'); const theme = useColorPalates(); // @ts-ignore const secondaryColor = useMemo(() => { return theme?.primary?.light; }, [theme?.primary?.light]); const primaryColor = useMemo(() => { return theme?.primary?.main; }, [theme?.primary?.main]); const [shareLoader, setShareLoader] = useState(false); const [downloadLoader, setDownloadLoader] = useState(false); // @ts-ignore const downloadChat = async (type: string) => { // perform your download chat logic here }; const downloadShareHandler = async (type: string) => { try { if (type === 'download') { setDownloadLoader(true); } else { setShareLoader(true); } if (type === 'download') { setDownloadLoader(false); setTimeout(() => { toast.success('Downloading...'); }, 2000); } else if (type === 'share') { setShareLoader(false); setTimeout(() => { toast.success('Share successful'); }, 2000); } else { toast.error("Your system doesn't support sharing this file."); setDownloadLoader(false); setShareLoader(false); } } catch (error: any) { setDownloadLoader(false); setShareLoader(false); toast.error('Error while performing'); } }; return ( <> {(config?.allowDownloadChat || config?.allowShareChat) && (
Share
Download
Share
Download