🐛 Remove publicId and customDomain duplication on imported bots

This commit is contained in:
Baptiste Arnaud
2023-08-17 16:32:37 +02:00
parent 906845bd76
commit 304dfe2dab
17 changed files with 61 additions and 70 deletions

View File

@@ -25,6 +25,7 @@ import { useScopedI18n } from '@/locales'
import { TypebotInDashboard } from '@/features/dashboard/types'
import { isMobile } from '@/helpers/isMobile'
import { trpc, trpcVanilla } from '@/lib/trpc'
import { duplicateName } from '@/features/typebot/helpers/duplicateName'
type Props = {
typebot: TypebotInDashboard
@@ -221,10 +222,3 @@ export const TypebotButton = ({
</Button>
)
}
const duplicateName = (name: string | `${string} (${number})`) => {
const match = name.match(/^(.*) \((\d+)\)$/)
if (!match) return `${name} (1)`
const [, nameWithoutNumber, number] = match
return `${nameWithoutNumber} (${Number(number) + 1})`
}