🧐 Improve suspendWorkspace script
This commit is contained in:
@@ -15,24 +15,29 @@ const suspendWorkspace = async () => {
|
|||||||
console.log(e.duration, 'ms')
|
console.log(e.duration, 'ms')
|
||||||
})
|
})
|
||||||
|
|
||||||
const type = (await p.select({
|
const type = await p.select({
|
||||||
message: 'Select way',
|
message: 'Select way',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'Typebot public ID', value: 'typebotId' },
|
{ label: 'Typebot ID', value: 'id' },
|
||||||
|
{ label: 'Typebot public ID', value: 'publicId' },
|
||||||
{ label: 'Workspace ID', value: 'workspaceId' },
|
{ label: 'Workspace ID', value: 'workspaceId' },
|
||||||
],
|
],
|
||||||
})) as 'typebotId' | 'workspaceId'
|
})
|
||||||
|
|
||||||
const val = (await p.text({
|
if (!type || typeof type !== 'string') return
|
||||||
|
|
||||||
|
const val = await p.text({
|
||||||
message: 'Enter value',
|
message: 'Enter value',
|
||||||
})) as string
|
})
|
||||||
|
|
||||||
|
if (!val || typeof val !== 'string') return
|
||||||
|
|
||||||
let workspaceId = type === 'workspaceId' ? val : undefined
|
let workspaceId = type === 'workspaceId' ? val : undefined
|
||||||
|
|
||||||
if (!workspaceId) {
|
if (!workspaceId) {
|
||||||
const typebot = await prisma.typebot.findUnique({
|
const typebot = await prisma.typebot.findFirst({
|
||||||
where: {
|
where: {
|
||||||
publicId: val,
|
[type]: val,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
workspaceId: true,
|
workspaceId: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user