From 31711dc24d79b3cc2e967234360e247258ffe3a4 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Wed, 22 Feb 2023 16:59:04 +0100 Subject: [PATCH] :lipstick: Improve new version popup animation --- .../src/components/NewVersionPopup.tsx | 88 +++++++++++-------- .../TypebotProvider/TypebotProvider.tsx | 2 +- apps/builder/src/hooks/useTypebotQuery.ts | 4 +- apps/builder/src/pages/_app.tsx | 21 ++--- 4 files changed, 61 insertions(+), 54 deletions(-) diff --git a/apps/builder/src/components/NewVersionPopup.tsx b/apps/builder/src/components/NewVersionPopup.tsx index 6258bd003..d6862a758 100644 --- a/apps/builder/src/components/NewVersionPopup.tsx +++ b/apps/builder/src/components/NewVersionPopup.tsx @@ -1,5 +1,13 @@ import { useTypebot } from '@/features/editor' -import { Button, Flex, HStack, Stack, Text } from '@chakra-ui/react' +import { + Button, + DarkMode, + Flex, + HStack, + SlideFade, + Stack, + Text, +} from '@chakra-ui/react' import { useEffect, useState } from 'react' import { sendRequest } from 'utils' import { PackageIcon } from './icons' @@ -42,43 +50,51 @@ export const NewVersionPopup = () => { window.location.reload() } - if (!isNewVersionAvailable) return null - return ( - - - - - - {' '} - New version available! - + + + + + + + + {' '} + New version available! + - - An improved version of Typebot is available. Please reload now to - upgrade. - - - - - + + An improved version of Typebot is available. Please reload now + to upgrade. + + + + + + + - - + + ) } diff --git a/apps/builder/src/features/editor/providers/TypebotProvider/TypebotProvider.tsx b/apps/builder/src/features/editor/providers/TypebotProvider/TypebotProvider.tsx index 15518df36..0fc75648e 100644 --- a/apps/builder/src/features/editor/providers/TypebotProvider/TypebotProvider.tsx +++ b/apps/builder/src/features/editor/providers/TypebotProvider/TypebotProvider.tsx @@ -102,7 +102,7 @@ export const TypebotProvider = ({ typebotId, }: { children: ReactNode - typebotId: string + typebotId?: string }) => { const { status } = useSession() const { push } = useRouter() diff --git a/apps/builder/src/hooks/useTypebotQuery.ts b/apps/builder/src/hooks/useTypebotQuery.ts index d94c26c32..28b307215 100644 --- a/apps/builder/src/hooks/useTypebotQuery.ts +++ b/apps/builder/src/hooks/useTypebotQuery.ts @@ -7,7 +7,7 @@ export const useTypebotQuery = ({ typebotId, onError, }: { - typebotId: string + typebotId?: string onError?: (error: Error) => void }) => { const { data, error, mutate } = useSWR< @@ -18,7 +18,7 @@ export const useTypebotQuery = ({ isReadOnly?: boolean }, Error - >(`/api/typebots/${typebotId}`, fetcher, { + >(typebotId ? `/api/typebots/${typebotId}` : null, fetcher, { dedupingInterval: env('E2E_TEST') === 'true' ? 0 : undefined, }) if (error && onError) onError(error) diff --git a/apps/builder/src/pages/_app.tsx b/apps/builder/src/pages/_app.tsx index b9e403634..74f273448 100644 --- a/apps/builder/src/pages/_app.tsx +++ b/apps/builder/src/pages/_app.tsx @@ -26,7 +26,7 @@ const App = ({ pageProps: { session, ...pageProps }, }: AppProps<{ session?: Session }>) => { useRouterProgressBar() - const { query, pathname, isReady } = useRouter() + const { query, pathname } = useRouter() useEffect(() => { pathname.endsWith('/edit') @@ -38,13 +38,12 @@ const App = ({ const newPlan = query.stripe?.toString() if (newPlan === Plan.STARTER || newPlan === Plan.PRO) toast({ - position: 'bottom-right', + position: 'top-right', status: 'success', title: 'Upgrade success!', description: `Workspace upgraded to ${toTitleCase(newPlan)} 🎉`, }) - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isReady]) + }, [query.stripe]) const typebotId = query.typebotId?.toString() @@ -54,21 +53,13 @@ const App = ({ - {typebotId ? ( - - - - - - - - ) : ( - + + - )} +