2
0

🧰 Aggregate utils & set up results collection in viewer

This commit is contained in:
Baptiste Arnaud
2021-12-29 10:22:26 +01:00
parent 447172d0cb
commit f088f694b9
42 changed files with 404 additions and 141 deletions

View File

@@ -10,7 +10,7 @@ import { Block, StartBlock } from 'bot-engine'
import { useGraph } from 'contexts/GraphContext'
import { useDnd } from 'contexts/DndContext'
import { StepsList } from './StepsList'
import { isDefined } from 'services/utils'
import { isDefined } from 'utils'
import { useTypebot } from 'contexts/TypebotContext'
import { ContextMenu } from 'components/shared/ContextMenu'
import { BlockNodeContextMenu } from './BlockNodeContextMenu'

View File

@@ -4,7 +4,7 @@ import { Block, StartStep, Step, StepType } from 'bot-engine'
import { SourceEndpoint } from './SourceEndpoint'
import { useGraph } from 'contexts/GraphContext'
import { StepIcon } from 'components/board/StepTypesList/StepIcon'
import { isDefined } from 'services/utils'
import { isDefined } from 'utils'
import { Coordinates } from '@dnd-kit/core/dist/types'
import { TextEditor } from './TextEditor/TextEditor'
import { StepContent } from './StepContent'

View File

@@ -91,7 +91,7 @@ export const PreviewDrawer = () => {
>
<TypebotViewer
typebot={publicTypebot}
onNewBlockVisisble={handleNewBlockVisible}
onNewBlockVisible={handleNewBlockVisible}
/>
</Flex>
)}

View File

@@ -35,11 +35,11 @@ import {
import {
fetcher,
insertItemInList,
isDefined,
omit,
preventUserFromRefreshing,
} from 'services/utils'
import useSWR from 'swr'
import { isDefined } from 'utils'
import { NewBlockPayload, Coordinates } from './GraphContext'
const typebotContext = createContext<{

View File

@@ -9,7 +9,7 @@ import {
useMemo,
useState,
} from 'react'
import { isDefined } from 'services/utils'
import { isDefined } from 'utils'
import { updateUser as updateUserInDb } from 'services/user'
import { useToast } from '@chakra-ui/react'
import { deepEqual } from 'fast-equals'

View File

@@ -0,0 +1,6 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withTM = require('next-transpile-modules')(['utils'])
module.exports = withTM({
reactStrictMode: true,
})

View File

@@ -32,6 +32,7 @@
"framer-motion": "^4",
"htmlparser2": "^7.2.0",
"kbar": "^0.1.0-beta.24",
"micro": "^9.3.4",
"micro-cors": "^0.1.1",
"next": "^12.0.7",
"next-auth": "beta",
@@ -50,7 +51,8 @@
"styled-components": "^5.3.3",
"svg-round-corners": "^0.3.0",
"swr": "^1.1.1",
"use-debounce": "^7.0.1"
"use-debounce": "^7.0.1",
"utils": "*"
},
"devDependencies": {
"@testing-library/cypress": "^8.0.2",
@@ -69,6 +71,7 @@
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-prettier": "^4.0.0",
"next-transpile-modules": "^9.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.4"
}

View File

@@ -2,7 +2,7 @@ import { DashboardFolder, User } from 'db'
import prisma from 'libs/prisma'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const session = await getSession({ req })

View File

@@ -2,7 +2,7 @@ import { DashboardFolder } from 'db'
import prisma from 'libs/prisma'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const session = await getSession({ req })

View File

@@ -1,7 +1,7 @@
import prisma from 'libs/prisma'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const session = await getSession({ req })

View File

@@ -1,7 +1,7 @@
import prisma from 'libs/prisma'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const session = await getSession({ req })

View File

@@ -1,7 +1,7 @@
import aws from 'aws-sdk'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
const maxUploadFileSize = 10485760 // 10 MB
const handler = async (

View File

@@ -1,5 +1,5 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
import Stripe from 'stripe'
const usdPriceIdTest = 'price_1Jc4TQKexUFvKTWyGvsH4Ff5'

View File

@@ -1,7 +1,7 @@
import { User } from 'db'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
import Stripe from 'stripe'
const createCheckoutSession = async (

View File

@@ -1,5 +1,5 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
import Stripe from 'stripe'
import Cors from 'micro-cors'
import { buffer } from 'micro'

View File

@@ -3,7 +3,7 @@ import { User } from 'db'
import prisma from 'libs/prisma'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const session = await getSession({ req })

View File

@@ -1,7 +1,7 @@
import prisma from 'libs/prisma'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const session = await getSession({ req })

View File

@@ -1,7 +1,7 @@
import prisma from 'libs/prisma'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { methodNotAllowed } from 'services/api/utils'
import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const session = await getSession({ req })

View File

@@ -1,4 +0,0 @@
import { NextApiResponse } from 'next'
export const methodNotAllowed = (res: NextApiResponse) =>
res.status(405).json({ message: 'Method Not Allowed' })

View File

@@ -9,7 +9,7 @@ import {
firstStepOffsetY,
} from 'contexts/GraphContext'
import { roundCorners } from 'svg-round-corners'
import { isDefined } from './utils'
import { isDefined } from 'utils'
export const computeFlowChartConnectorPath = ({
sourcePosition,

View File

@@ -39,10 +39,6 @@ export const insertItemInList = <T>(
newItem: T
): T[] => [...arr.slice(0, index), newItem, ...arr.slice(index)]
export const isDefined = <T>(value: T | undefined | null): value is T => {
return <T>value !== undefined && <T>value !== null
}
export const preventUserFromRefreshing = (e: BeforeUnloadEvent) => {
e.preventDefault()
e.returnValue = ''