Skip to content

Commit

Permalink
don't allow dismissing incomplete tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfcosta committed Jan 2, 2025
1 parent 78fe70f commit 0f543e9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions apps/api/src/v1/workspaces/workspace/tutorials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '../../../tutorials.js'
import { broadcastTutorialStepStates } from '../../../websocket/workspace/tutorial.js'
import { logger } from '../../../logger.js'
import prisma from '@briefer/database'

export default function tutorialsRouter(socketServer: IOServer) {
const router = Router({ mergeParams: true })
Expand Down Expand Up @@ -80,6 +81,20 @@ export default function tutorialsRouter(socketServer: IOServer) {
return
}

const tutorial = await prisma().onboardingTutorial.findUnique({
where: {
workspaceId,
},
})

if (!tutorial) {
return res.sendStatus(404)
}

if (!tutorial.isComplete) {
return res.sendStatus(400)
}

try {
const tutorialState = await dismissTutorial(workspaceId, tutorialType)

Expand Down

0 comments on commit 0f543e9

Please sign in to comment.