Skip to content

Commit

Permalink
fix: 🐛 Tiny bugs (Sentry)
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 25, 2022
1 parent d21b172 commit 9e08ff5
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test-results
.docusaurus
.cache-loader
build
firebaseServiceAccount.json

# Wordpress
.svn
Expand Down
26 changes: 13 additions & 13 deletions apps/builder/components/shared/CredentialsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ export const CredentialsDropdown = ({
router.push(router.asPath.split('?')[0], undefined, { shallow: true })
}

const handleDeleteDomainClick = (credentialsId: string) => async () => {
if (!user?.id) return
setIsDeleting(credentialsId)
const { error } = await deleteCredentials(user?.id, credentialsId)
setIsDeleting(undefined)
if (error) return toast({ title: error.name, description: error.message })
onCredentialsSelect(undefined)
mutate({ credentials: credentials.filter((c) => c.id !== credentialsId) })
}
const handleDeleteDomainClick =
(credentialsId: string) => async (e: React.MouseEvent) => {
e.stopPropagation()
if (!user?.id) return
setIsDeleting(credentialsId)
const { error } = await deleteCredentials(user?.id, credentialsId)
setIsDeleting(undefined)
if (error) return toast({ title: error.name, description: error.message })
onCredentialsSelect(undefined)
mutate({ credentials: credentials.filter((c) => c.id !== credentialsId) })
}

return (
<Menu isLazy placement="bottom-end" matchWidth>
Expand Down Expand Up @@ -121,16 +123,14 @@ export const CredentialsDropdown = ({
</MenuItem>
)}
{credentialsList.map((credentials) => (
<Button
<MenuItem
role="menuitem"
minH="40px"
key={credentials.id}
onClick={handleMenuItemClick(credentials.id)}
fontSize="16px"
fontWeight="normal"
rounded="none"
colorScheme="gray"
variant="ghost"
justifyContent="space-between"
>
{credentials.name}
Expand All @@ -141,7 +141,7 @@ export const CredentialsDropdown = ({
onClick={handleDeleteDomainClick(credentials.id)}
isLoading={isDeleting === credentials.id}
/>
</Button>
</MenuItem>
))}
<MenuItem
maxW="500px"
Expand Down
1 change: 1 addition & 0 deletions apps/builder/contexts/TypebotContext/actions/edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const deleteEdgeDraft = (
edgeId: string
) => {
const edgeIndex = typebot.edges.findIndex(byId(edgeId))
if (edgeIndex === -1) return
deleteOutgoingEdgeIdProps(typebot, edgeIndex)
typebot.edges.splice(edgeIndex, 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method === 'GET') {
const credentialsId = req.query.credentialsId.toString()
const auth = await getAuthenticatedGoogleClient(user.id, credentialsId)
const { data } = await drive({
const response = await drive({
version: 'v3',
auth,
}).files.list({
q: "mimeType='application/vnd.google-apps.spreadsheet'",
fields: 'nextPageToken, files(id, name)',
})
return res.send(data)
return res.send(response.data)
}
return methodNotAllowed(res)
}
Expand Down
16 changes: 14 additions & 2 deletions apps/viewer/layouts/TypebotPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const TypebotPage = ({
}, [])

const initializeResult = async (variables: VariableWithValue[]) => {
const resultIdFromSession = sessionStorage.getItem(sessionStorageKey)
const resultIdFromSession = getExistingResultFromSession()
if (resultIdFromSession) setResultId(resultIdFromSession)
else {
const { error, data: result } = await createResult(
Expand All @@ -41,7 +41,7 @@ export const TypebotPage = ({
if (error) setError(error)
if (result) {
setResultId(result.id)
sessionStorage.setItem(sessionStorageKey, result.id)
setResultInSession(result.id)
}
}
}
Expand Down Expand Up @@ -79,3 +79,15 @@ export const TypebotPage = ({
</div>
)
}

const getExistingResultFromSession = () => {
try {
return sessionStorage.getItem(sessionStorageKey)
} catch {}
}

const setResultInSession = (resultId: string) => {
try {
return sessionStorage.setItem(sessionStorageKey, resultId)
} catch {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { initMiddleware, methodNotAllowed } from 'utils'
import { badRequest, initMiddleware, methodNotAllowed } from 'utils'
import { GoogleSpreadsheet } from 'google-spreadsheet'
import { getAuthenticatedGoogleClient } from 'libs/google-sheets'
import { Cell } from 'models'
Expand All @@ -17,7 +17,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
column: req.query['referenceCell[column]'],
value: req.query['referenceCell[value]'],
} as Cell
const extractingColumns = req.query.columns as string[]
const extractingColumns = req.query.columns as string[] | undefined
if (!Array.isArray(extractingColumns)) return badRequest(res)
const doc = new GoogleSpreadsheet(spreadsheetId)
doc.useOAuth2Client(await getAuthenticatedGoogleClient(credentialsId))
await doc.loadInfo()
Expand Down
8 changes: 1 addition & 7 deletions packages/scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PrismaClient } from 'db'
import { randomUUID } from 'crypto'
import path from 'path'

require('dotenv').config({
Expand All @@ -10,11 +9,6 @@ require('dotenv').config({
})

const prisma = new PrismaClient()
const main = async () => {
await prisma.user.updateMany({
where: { apiToken: null },
data: { apiToken: randomUUID() },
})
}
const main = async () => {}

main().then()
3 changes: 3 additions & 0 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"devDependencies": {
"db": "*",
"ts-node": "^10.5.0"
},
"dependencies": {
"firebase-admin": "^10.0.2"
}
}

0 comments on commit 9e08ff5

Please sign in to comment.