import { useTypebot } from '@/features/editor/providers/TypebotProvider' import { trpc } from '@/lib/trpc' import { Button, DarkMode, Flex, HStack, SlideFade, Stack, Text, } from '@chakra-ui/react' import { useEffect, useState } from 'react' import { PackageIcon } from './icons' export const NewVersionPopup = () => { const { typebot, save } = useTypebot() const [isReloading, setIsReloading] = useState(false) const { data } = trpc.getAppVersionProcedure.useQuery() const [currentVersion, setCurrentVersion] = useState() const [isNewVersionAvailable, setIsNewVersionAvailable] = useState(false) useEffect(() => { if (!data?.commitSha) return if (currentVersion === data.commitSha) return setCurrentVersion(data.commitSha) if (currentVersion === undefined) return setIsNewVersionAvailable(true) }, [data, currentVersion]) const saveAndReload = async () => { if (isReloading) return setIsReloading(true) if (save) await save() window.location.reload() } return ( {' '} New version available! An improved version of Typebot is available. Please reload now to upgrade. ) }