⚡ (engine) Improve engine overall robustness
This commit is contained in:
@ -11,7 +11,8 @@ import {
|
||||
import { AlertIcon } from '@/components/icons'
|
||||
import { Plan, Workspace } from 'db'
|
||||
import React from 'react'
|
||||
import { getChatsLimit, getStorageLimit, parseNumberWithCommas } from 'utils'
|
||||
import { parseNumberWithCommas } from 'utils'
|
||||
import { getChatsLimit, getStorageLimit } from 'utils/pricing'
|
||||
import { storageToReadable } from './helpers'
|
||||
import { useUsage } from '../../../hooks/useUsage'
|
||||
|
||||
|
@ -18,15 +18,15 @@ import { ChevronLeftIcon } from '@/components/icons'
|
||||
import { useWorkspace } from '@/features/workspace'
|
||||
import { Plan } from 'db'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { parseNumberWithCommas } from 'utils'
|
||||
import {
|
||||
chatsLimit,
|
||||
computePrice,
|
||||
formatPrice,
|
||||
getChatsLimit,
|
||||
getStorageLimit,
|
||||
storageLimit,
|
||||
parseNumberWithCommas,
|
||||
formatPrice,
|
||||
computePrice,
|
||||
} from 'utils'
|
||||
} from 'utils/pricing'
|
||||
import { FeaturesList } from './components/FeaturesList'
|
||||
import { MoreInfoTooltip } from '@/components/MoreInfoTooltip'
|
||||
|
||||
|
@ -14,15 +14,15 @@ import { ChevronLeftIcon } from '@/components/icons'
|
||||
import { useWorkspace } from '@/features/workspace'
|
||||
import { Plan } from 'db'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { parseNumberWithCommas } from 'utils'
|
||||
import {
|
||||
chatsLimit,
|
||||
computePrice,
|
||||
formatPrice,
|
||||
getChatsLimit,
|
||||
getStorageLimit,
|
||||
storageLimit,
|
||||
parseNumberWithCommas,
|
||||
computePrice,
|
||||
formatPrice,
|
||||
} from 'utils'
|
||||
} from 'utils/pricing'
|
||||
import { FeaturesList } from './components/FeaturesList'
|
||||
import { MoreInfoTooltip } from '@/components/MoreInfoTooltip'
|
||||
|
||||
|
@ -1,12 +1,7 @@
|
||||
import { loadStripe } from '@stripe/stripe-js/pure'
|
||||
import { Plan, User } from 'db'
|
||||
import {
|
||||
env,
|
||||
guessIfUserIsEuropean,
|
||||
isDefined,
|
||||
isEmpty,
|
||||
sendRequest,
|
||||
} from 'utils'
|
||||
import { env, isDefined, isEmpty, sendRequest } from 'utils'
|
||||
import { guessIfUserIsEuropean } from 'utils/pricing'
|
||||
|
||||
type UpgradeProps = {
|
||||
user: User
|
||||
|
@ -7,9 +7,7 @@ export const executeWebhook = (
|
||||
{ blockId }: { blockId: string }
|
||||
) =>
|
||||
sendRequest<WebhookResponse>({
|
||||
url: `${getViewerUrl({
|
||||
isBuilder: true,
|
||||
})}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
|
||||
url: `${getViewerUrl()}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
|
||||
method: 'POST',
|
||||
body: {
|
||||
variables,
|
||||
|
@ -118,8 +118,7 @@ export const CustomDomainModal = ({
|
||||
<Stack>
|
||||
<Text fontWeight="bold">Value</Text>
|
||||
<Text>
|
||||
{env('VIEWER_INTERNAL_URL') ??
|
||||
getViewerUrl({ isBuilder: true })}
|
||||
{env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}
|
||||
</Text>
|
||||
</Stack>
|
||||
</HStack>
|
||||
|
@ -123,7 +123,7 @@ export const OnboardingModal = ({ totalTypebots }: Props) => {
|
||||
<ModalBody p="10">
|
||||
{typebot && (
|
||||
<TypebotViewer
|
||||
apiHost={getViewerUrl({ isBuilder: true })}
|
||||
apiHost={getViewerUrl()}
|
||||
typebot={parseTypebotToPublicTypebot(typebot)}
|
||||
predefinedVariables={{
|
||||
Name: user?.name?.split(' ')[0] ?? undefined,
|
||||
|
@ -106,7 +106,7 @@ export const PreviewDrawer = () => {
|
||||
pointerEvents={isResizing ? 'none' : 'auto'}
|
||||
>
|
||||
<TypebotViewer
|
||||
apiHost={getViewerUrl({ isBuilder: true })}
|
||||
apiHost={getViewerUrl()}
|
||||
typebot={publicTypebot}
|
||||
onNewGroupVisible={setPreviewingEdge}
|
||||
onNewLog={handleNewLog}
|
||||
|
@ -98,9 +98,7 @@ export const SharePage = () => {
|
||||
</Heading>
|
||||
{typebot && (
|
||||
<EditableUrl
|
||||
hostname={
|
||||
getViewerUrl({ isBuilder: true }) ?? 'https://typebot.io'
|
||||
}
|
||||
hostname={getViewerUrl() ?? 'https://typebot.io'}
|
||||
pathname={publicId}
|
||||
isValid={checkIfPublicIdIsValid}
|
||||
onPathnameChange={handlePublicIdChange}
|
||||
|
@ -20,9 +20,9 @@ export const ChatEmbedCode = ({
|
||||
|
||||
const snippet = prettier.format(
|
||||
createSnippet({
|
||||
url: `${
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl({ isBuilder: true })
|
||||
}/${typebot?.publicId}`,
|
||||
url: `${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}/${
|
||||
typebot?.publicId
|
||||
}`,
|
||||
button,
|
||||
proactiveMessage,
|
||||
}),
|
||||
|
@ -22,9 +22,9 @@ export const ContainerEmbedCode = ({
|
||||
|
||||
const snippet = prettier.format(
|
||||
parseSnippet({
|
||||
url: `${
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl({ isBuilder: true })
|
||||
}/${typebot?.publicId}`,
|
||||
url: `${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}/${
|
||||
typebot?.publicId
|
||||
}`,
|
||||
heightLabel,
|
||||
widthLabel,
|
||||
}),
|
||||
|
@ -13,9 +13,9 @@ export const IframeEmbedCode = ({
|
||||
heightLabel,
|
||||
}: Props & FlexProps) => {
|
||||
const { typebot } = useTypebot()
|
||||
const src = `${
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl({ isBuilder: true })
|
||||
}/${typebot?.publicId}`
|
||||
const src = `${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}/${
|
||||
typebot?.publicId
|
||||
}`
|
||||
const code = `<iframe src="${src}" width="${widthLabel}" height="${heightLabel}" style="border: none"></iframe>`
|
||||
|
||||
return <CodeEditor value={code} lang="html" isReadOnly />
|
||||
|
@ -17,9 +17,9 @@ export const PopupEmbedCode = ({ delay }: PopupEmbedCodeProps & FlexProps) => {
|
||||
const { typebot } = useTypebot()
|
||||
const snippet = prettier.format(
|
||||
createSnippet({
|
||||
url: `${
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl({ isBuilder: true })
|
||||
}/${typebot?.publicId}`,
|
||||
url: `${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}/${
|
||||
typebot?.publicId
|
||||
}`,
|
||||
delay,
|
||||
}),
|
||||
{
|
||||
|
@ -20,9 +20,9 @@ export const StandardReactDiv = ({
|
||||
const { typebot } = useTypebot()
|
||||
const snippet = prettier.format(
|
||||
parseContainerSnippet({
|
||||
url: `${
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl({ isBuilder: true })
|
||||
}/${typebot?.publicId}`,
|
||||
url: `${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}/${
|
||||
typebot?.publicId
|
||||
}`,
|
||||
heightLabel,
|
||||
widthLabel,
|
||||
}),
|
||||
@ -70,9 +70,9 @@ export const PopupReactCode = ({ delay }: PopupEmbedCodeProps & FlexProps) => {
|
||||
const { typebot } = useTypebot()
|
||||
const snippet = prettier.format(
|
||||
parsePopupSnippet({
|
||||
url: `${
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl({ isBuilder: true })
|
||||
}/${typebot?.publicId}`,
|
||||
url: `${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}/${
|
||||
typebot?.publicId
|
||||
}`,
|
||||
delay,
|
||||
}),
|
||||
{
|
||||
@ -119,9 +119,9 @@ export const ChatReactCode = ({
|
||||
const { typebot } = useTypebot()
|
||||
const snippet = prettier.format(
|
||||
parseBubbleSnippet({
|
||||
url: `${
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl({ isBuilder: true })
|
||||
}/${typebot?.publicId}`,
|
||||
url: `${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}/${
|
||||
typebot?.publicId
|
||||
}`,
|
||||
button,
|
||||
proactiveMessage,
|
||||
}),
|
||||
|
@ -40,9 +40,7 @@ const StandardInstructions = ({ publicId }: Pick<ModalProps, 'publicId'>) => {
|
||||
})
|
||||
|
||||
const jsCode = parseInitContainerCode({
|
||||
url: `${
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl({ isBuilder: true })
|
||||
}/${publicId}`,
|
||||
url: `${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}/${publicId}`,
|
||||
})
|
||||
const headCode = `${typebotJsHtml}
|
||||
<script>
|
||||
|
@ -48,15 +48,13 @@ export const NotionModal = ({
|
||||
pr="4.5rem"
|
||||
type={'text'}
|
||||
defaultValue={`${
|
||||
env('VIEWER_INTERNAL_URL') ??
|
||||
getViewerUrl({ isBuilder: true })
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
||||
}/${publicId}`}
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<CopyButton
|
||||
textToCopy={`${
|
||||
env('VIEWER_INTERNAL_URL') ??
|
||||
getViewerUrl({ isBuilder: true })
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
||||
}/${publicId}`}
|
||||
/>
|
||||
</InputRightElement>
|
||||
|
@ -45,9 +45,7 @@ const StandardInstructions = ({ publicId }: Pick<ModalProps, 'publicId'>) => {
|
||||
})
|
||||
|
||||
const jsCode = parseInitContainerCode({
|
||||
url: `${
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl({ isBuilder: true })
|
||||
}/${publicId}`,
|
||||
url: `${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}/${publicId}`,
|
||||
})
|
||||
const headCode = prettier.format(
|
||||
`${typebotJsHtml}<script>${jsCode}</script>`,
|
||||
|
@ -58,15 +58,13 @@ export const WordpressModal = ({
|
||||
pr="4.5rem"
|
||||
type={'text'}
|
||||
defaultValue={`${
|
||||
env('VIEWER_INTERNAL_URL') ??
|
||||
getViewerUrl({ isBuilder: true })
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
||||
}/${publicId}`}
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<CopyButton
|
||||
textToCopy={`${
|
||||
env('VIEWER_INTERNAL_URL') ??
|
||||
getViewerUrl({ isBuilder: true })
|
||||
env('VIEWER_INTERNAL_URL') ?? getViewerUrl()
|
||||
}/${publicId}`}
|
||||
/>
|
||||
</InputRightElement>
|
||||
|
@ -16,7 +16,7 @@ import {
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useMemo } from 'react'
|
||||
import { getChatsLimit, getStorageLimit } from 'utils'
|
||||
import { getChatsLimit, getStorageLimit } from 'utils/pricing'
|
||||
import { useStats } from '../hooks/useStats'
|
||||
import { ResultsProvider } from '../ResultsProvider'
|
||||
import { ResultsTableContainer } from './ResultsTableContainer'
|
||||
|
@ -23,10 +23,7 @@ export const SettingsPage = () => {
|
||||
<SettingsSideMenu />
|
||||
<Flex flex="1">
|
||||
{publicTypebot && (
|
||||
<TypebotViewer
|
||||
apiHost={getViewerUrl({ isBuilder: true })}
|
||||
typebot={publicTypebot}
|
||||
/>
|
||||
<TypebotViewer apiHost={getViewerUrl()} typebot={publicTypebot} />
|
||||
)}
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
@ -76,7 +76,7 @@ export const TemplatesModal = ({ isOpen, onClose, onTypebotChoose }: Props) => {
|
||||
</Heading>
|
||||
{typebot && (
|
||||
<TypebotViewer
|
||||
apiHost={getViewerUrl({ isBuilder: true })}
|
||||
apiHost={getViewerUrl()}
|
||||
typebot={parseTypebotToPublicTypebot(typebot)}
|
||||
key={typebot.id}
|
||||
style={{ borderRadius: '0.25rem' }}
|
||||
|
@ -18,10 +18,7 @@ export const ThemePage = () => {
|
||||
<ThemeSideMenu />
|
||||
<Flex flex="1">
|
||||
{publicTypebot && (
|
||||
<TypebotViewer
|
||||
apiHost={getViewerUrl({ isBuilder: true })}
|
||||
typebot={publicTypebot}
|
||||
/>
|
||||
<TypebotViewer apiHost={getViewerUrl()} typebot={publicTypebot} />
|
||||
)}
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
import { UnlockPlanAlertInfo } from '@/components/UnlockPlanAlertInfo'
|
||||
import { WorkspaceInvitation, WorkspaceRole } from 'db'
|
||||
import React from 'react'
|
||||
import { getSeatsLimit } from 'utils'
|
||||
import { getSeatsLimit } from 'utils/pricing'
|
||||
import { AddMemberForm } from './AddMemberForm'
|
||||
import { checkCanInviteMember } from './helpers'
|
||||
import { MemberItem } from './MemberItem'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Plan } from 'db'
|
||||
import { getSeatsLimit } from 'utils'
|
||||
import { getSeatsLimit } from 'utils/pricing'
|
||||
|
||||
export function checkCanInviteMember({
|
||||
plan,
|
||||
|
@ -3,8 +3,9 @@ import prisma from '@/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { forbidden, methodNotAllowed, notAuthenticated } from 'utils/api'
|
||||
import { getAuthenticatedUser } from '@/features/auth/api'
|
||||
import { env, getSeatsLimit } from 'utils'
|
||||
import { getSeatsLimit } from 'utils/pricing'
|
||||
import { sendWorkspaceMemberInvitationEmail } from 'emails'
|
||||
import { env } from 'utils'
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const user = await getAuthenticatedUser(req)
|
||||
|
Reference in New Issue
Block a user