🚸 (publish) Improve invalid public ID feedback
Also remove the 4 char min length rule for self-hosted versions Closes #267
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { badRequest, methodNotAllowed, notAuthenticated } from 'utils/api'
|
||||
import { methodNotAllowed, notAuthenticated } from 'utils/api'
|
||||
import { getAuthenticatedUser } from '@/features/auth/api'
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
@ -8,8 +8,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
if (!user) return notAuthenticated(res)
|
||||
if (req.method === 'GET') {
|
||||
const publicId = req.query.publicId as string | undefined
|
||||
if (!publicId) return badRequest(res, 'publicId is required')
|
||||
const exists = await prisma.typebot.count({ where: { publicId } })
|
||||
const exists = await prisma.typebot.count({
|
||||
where: { publicId: publicId ?? '' },
|
||||
})
|
||||
return res.send({ isAvailable: Boolean(!exists) })
|
||||
}
|
||||
return methodNotAllowed(res)
|
||||
|
@ -51,7 +51,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
})
|
||||
const typebots = await prisma.typebot.updateMany({
|
||||
where: canWriteTypebots(typebotId, user),
|
||||
data: { isArchived: true },
|
||||
data: { isArchived: true, publicId: null },
|
||||
})
|
||||
return res.send({ typebots })
|
||||
}
|
||||
|
Reference in New Issue
Block a user