2
0

refactor: ♻️ Toast component

This commit is contained in:
Baptiste Arnaud
2022-06-02 07:54:48 +02:00
parent 43fb8a7be0
commit 12f2e40152
26 changed files with 148 additions and 177 deletions

View File

@ -5,7 +5,6 @@ import {
ModalContent,
ModalOverlay,
useDisclosure,
useToast,
} from '@chakra-ui/react'
import { TypebotViewer } from 'bot-engine'
import { useUser } from 'contexts/UserContext'
@ -14,6 +13,7 @@ import React, { useEffect, useRef, useState } from 'react'
import { parseTypebotToPublicTypebot } from 'services/publicTypebot'
import { sendRequest } from 'utils'
import confetti from 'canvas-confetti'
import { useToast } from 'components/shared/hooks/useToast'
type Props = { totalTypebots: number }
@ -26,10 +26,7 @@ export const OnboardingModal = ({ totalTypebots }: Props) => {
const [chosenCategories, setChosenCategories] = useState<string[]>([])
const [openedOnce, setOpenedOnce] = useState(false)
const toast = useToast({
position: 'top-right',
status: 'error',
})
const { showToast } = useToast()
useEffect(() => {
fetchTemplate()
@ -77,7 +74,8 @@ export const OnboardingModal = ({ totalTypebots }: Props) => {
const fetchTemplate = async () => {
const { data, error } = await sendRequest(`/bots/onboarding.json`)
if (error) return toast({ title: error.name, description: error.message })
if (error)
return showToast({ title: error.name, description: error.message })
setTypebot(data as Typebot)
}