Skip to content

Commit

Permalink
🐛 (usage) Fix storage limit check
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Sep 27, 2022
1 parent 1063429 commit 1e26703
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions apps/builder/pages/api/stripe/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ const updateSubscription = async (req: NextApiRequest) => {
plan,
additionalChatsIndex: additionalChats,
additionalStorageIndex: additionalStorage,
chatsLimitFirstEmailSentAt: null,
chatsLimitSecondEmailSentAt: null,
storageLimitFirstEmailSentAt: null,
storageLimitSecondEmailSentAt: null,
},
})
}
Expand Down
4 changes: 4 additions & 0 deletions apps/builder/pages/api/stripe/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const webhookHandler = async (req: NextApiRequest, res: NextApiResponse) => {
stripeId: session.customer as string,
additionalChatsIndex: parseInt(additionalChats),
additionalStorageIndex: parseInt(additionalStorage),
chatsLimitFirstEmailSentAt: null,
chatsLimitSecondEmailSentAt: null,
storageLimitFirstEmailSentAt: null,
storageLimitSecondEmailSentAt: null,
},
})
return res.status(200).send({ message: 'workspace upgraded in DB' })
Expand Down
2 changes: 2 additions & 0 deletions apps/viewer/assets/styles.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
body {
margin: 0;
overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
}
5 changes: 1 addition & 4 deletions apps/viewer/layouts/ErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ export const ErrorPage = ({ error }: { error: Error }) => {
</h2>
</>
) : (
<>
<h1 style={{ fontWeight: 'bold', fontSize: '30px' }}>{error.name}</h1>
<h2>{error.message}</h2>
</>
<p style={{ fontSize: '24px' }}>{error.message}</p>
)}
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions apps/viewer/layouts/TypebotPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const TypebotPage = ({
const handleNewAnswer = async (
answer: Answer & { uploadedFiles: boolean }
) => {
if (!resultId) return setError(new Error('Result was not created'))
if (!resultId) return setError(new Error('Error: result was not created'))
const { error } = await upsertAnswer({ ...answer, resultId })
if (error) setError(error)
if (chatStarted) return
Expand All @@ -110,7 +110,7 @@ export const TypebotPage = ({
}

const handleCompleted = async () => {
if (!resultId) return setError(new Error('Result was not created'))
if (!resultId) return setError(new Error('Error: result was not created'))
const { error } = await updateResult(resultId, { isCompleted: true })
if (error) setError(error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const checkStorageLimit = async (typebotId: string) => {
if (!totalStorageUsed) return false
const hasSentFirstEmail = workspace.storageLimitFirstEmailSentAt !== null
const hasSentSecondEmail = workspace.storageLimitSecondEmailSentAt !== null
const storageLimit = getStorageLimit(typebot.workspace)
const storageLimit = getStorageLimit(typebot.workspace) * 1024 * 1024 * 1024
if (
totalStorageUsed >= storageLimit * LIMIT_EMAIL_TRIGGER_PERCENT &&
!hasSentFirstEmail &&
Expand Down

0 comments on commit 1e26703

Please sign in to comment.