2
0

build: add pnpm

This commit is contained in:
Baptiste Arnaud
2022-08-08 08:21:36 +02:00
parent 8c3b5058f1
commit ee338f62dc
183 changed files with 19442 additions and 18364 deletions

View File

@ -2,11 +2,27 @@ import { setUser } from '@sentry/nextjs'
import { User } from 'db'
import { NextApiRequest } from 'next'
import { getSession } from 'next-auth/react'
import { env } from 'utils'
const mockedUser: User = {
id: 'proUser',
name: 'Pro user',
email: 'pro-user@email.com',
company: null,
createdAt: new Date(),
emailVerified: null,
graphNavigation: 'TRACKPAD',
image: 'https://avatars.githubusercontent.com/u/16015833?v=4',
lastActivityAt: new Date(),
onboardingCategories: [],
updatedAt: new Date(),
}
export const getAuthenticatedUser = async (
req: NextApiRequest
): Promise<User | undefined> => {
const session = await getSession({ req })
if (env('E2E_TEST') === 'true' && !session?.user) return mockedUser
if (!session?.user || !('id' in session.user)) return
const user = session.user as User
setUser({ id: user.id, email: user.email ?? undefined })

View File

@ -18,7 +18,7 @@ export const useFolders = ({
workspaceId ? `/api/folders?${params}` : null,
fetcher,
{
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: env('E2E_TEST') === 'true' ? 0 : undefined,
}
)
if (error) onError(error)

View File

@ -1,4 +1,4 @@
import { env, sendRequest } from 'utils'
import { getViewerUrl, sendRequest } from 'utils'
import { stringify } from 'qs'
import useSWR from 'swr'
import { fetcher } from './utils'
@ -78,9 +78,9 @@ export const executeWebhook = (
{ blockId }: { blockId: string }
) =>
sendRequest<WebhookResponse>({
url: `${env(
'VIEWER_URL'
)}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
url: `${getViewerUrl({
isBuilder: true,
})}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
method: 'POST',
body: {
variables,

View File

@ -1,2 +1 @@
export * from './results'
export * from './typebots'

View File

@ -14,7 +14,7 @@ export const useInvitations = ({
typebotId ? `/api/typebots/${typebotId}/invitations` : null,
fetcher,
{
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: env('E2E_TEST') === 'true' ? 0 : undefined,
}
)
if (error) onError(error)

View File

@ -54,7 +54,7 @@ export const useResults = ({
fetcher,
{
revalidateAll: true,
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: env('E2E_TEST') === 'true' ? 0 : undefined,
}
)
@ -147,15 +147,18 @@ const HeaderIcon = ({ header }: { header: ResultHeaderCell }) =>
<CalendarIcon />
)
export type CellValueType = { element?: JSX.Element; plainText: string }
export type TableData = {
id: Pick<CellValueType, 'plainText'>
} & Record<string, CellValueType>
export const convertResultsToTableData = (
results: ResultWithAnswers[] | undefined,
headerCells: ResultHeaderCell[]
): {
id: string
[key: string]: { element?: JSX.Element; plainText: string } | string
}[] =>
): TableData[] =>
(results ?? []).map((result) => ({
id: result.id,
id: { plainText: result.id },
'Submitted at': {
plainText: parseDateToReadable(result.createdAt),
},

View File

@ -53,6 +53,7 @@ import {
blockTypeHasOption,
blockTypeHasWebhook,
env,
isDefined,
} from 'utils'
import { dequal } from 'dequal'
import { stringify } from 'qs'
@ -61,7 +62,6 @@ import cuid from 'cuid'
import { diff } from 'deep-object-diff'
import { duplicateWebhook } from 'services/webhook'
import { Plan } from 'db'
import { isDefined } from '@chakra-ui/utils'
export type TypebotInDashboard = Pick<
Typebot,
@ -83,7 +83,7 @@ export const useTypebots = ({
{ typebots: TypebotInDashboard[] },
Error
>(workspaceId ? `/api/typebots?${params}` : null, fetcher, {
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: env('E2E_TEST') === 'true' ? 0 : undefined,
})
if (error) onError(error)
return {

View File

@ -25,7 +25,7 @@ export const useApiTokens = ({
userId ? `/api/users/${userId}/api-tokens` : null,
fetcher,
{
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: env('E2E_TEST') === 'true' ? 0 : undefined,
}
)
if (error) onError(error)

View File

@ -14,7 +14,7 @@ export const useMembers = ({ workspaceId }: { workspaceId?: string }) => {
{ members: Member[]; invitations: WorkspaceInvitation[] },
Error
>(workspaceId ? `/api/workspaces/${workspaceId}/members` : null, fetcher, {
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: env('E2E_TEST') === 'true' ? 0 : undefined,
})
return {
members: data?.members,