2
0

fix: 🐛 Smash tiny bugs

This commit is contained in:
Baptiste Arnaud
2022-02-22 16:30:41 +01:00
parent 6d455a3861
commit 1dc2264bdf
4 changed files with 33 additions and 21 deletions

View File

@@ -153,7 +153,9 @@ export const TypebotHeader = () => {
</HStack> </HStack>
<HStack right="40px" pos="absolute"> <HStack right="40px" pos="absolute">
{router.pathname.includes('/edit') && (
<Button onClick={handlePreviewClick}>Preview</Button> <Button onClick={handlePreviewClick}>Preview</Button>
)}
<PublishButton /> <PublishButton />
</HStack> </HStack>
</Flex> </Flex>

View File

@@ -17,6 +17,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
pass: password, pass: password,
}, },
}) })
try {
const info = await transporter.sendMail({ const info = await transporter.sendMail({
from: `"${from.name}" <${from.email}>`, from: `"${from.name}" <${from.email}>`,
to, to,
@@ -24,6 +25,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
text: 'This email has been sent to test out your SMTP config.\n\nIf your read this then it has been successful.🚀', text: 'This email has been sent to test out your SMTP config.\n\nIf your read this then it has been successful.🚀',
}) })
res.status(200).send({ message: 'Email sent!', info }) res.status(200).send({ message: 'Email sent!', info })
} catch (err) {
res.status(500).send(err)
}
} }
} }

View File

@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next' import { NextApiRequest, NextApiResponse } from 'next'
import { GoogleSpreadsheet } from 'google-spreadsheet' import { GoogleSpreadsheet } from 'google-spreadsheet'
import { getAuthenticatedGoogleClient } from 'libs/google-sheets' import { getAuthenticatedGoogleClient } from 'libs/google-sheets'
import { methodNotAllowed } from 'utils' import { isDefined, methodNotAllowed } from 'utils'
import { getSession } from 'next-auth/react' import { getSession } from 'next-auth/react'
import { User } from 'db' import { User } from 'db'
import { withSentry } from '@sentry/nextjs' import { withSentry } from '@sentry/nextjs'
@@ -23,17 +23,23 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
) )
await doc.loadInfo() await doc.loadInfo()
return res.send({ return res.send({
sheets: await Promise.all( sheets: (
await Promise.all(
Array.from(Array(doc.sheetCount)).map(async (_, idx) => { Array.from(Array(doc.sheetCount)).map(async (_, idx) => {
const sheet = doc.sheetsByIndex[idx] const sheet = doc.sheetsByIndex[idx]
try {
await sheet.loadHeaderRow() await sheet.loadHeaderRow()
} catch (err) {
return
}
return { return {
id: sheet.sheetId, id: sheet.sheetId,
name: sheet.title, name: sheet.title,
columns: sheet.headerValues, columns: sheet.headerValues,
} }
}) })
), )
).filter(isDefined),
}) })
} }
return methodNotAllowed(res) return methodNotAllowed(res)

View File

@@ -66,7 +66,7 @@ const executeWebhook =
const basicAuthHeaderIdx = webhook.headers.findIndex( const basicAuthHeaderIdx = webhook.headers.findIndex(
(h) => (h) =>
h.key?.toLowerCase() === 'authorization' && h.key?.toLowerCase() === 'authorization' &&
h.value?.toLowerCase().includes('basic') h.value?.toLowerCase()?.includes('basic')
) )
if (basicAuthHeaderIdx !== -1) { if (basicAuthHeaderIdx !== -1) {
const [username, password] = const [username, password] =