fix: 🐛 Fix duplication when customDomain is set
This commit is contained in:
@@ -45,7 +45,6 @@
|
||||
"deep-object-diff": "^1.1.7",
|
||||
"fast-equals": "^3.0.0",
|
||||
"focus-visible": "^5.2.0",
|
||||
"form-data": "^4.0.0",
|
||||
"framer-motion": "^4",
|
||||
"google-auth-library": "^7.12.0",
|
||||
"google-spreadsheet": "^3.2.0",
|
||||
@@ -54,7 +53,6 @@
|
||||
"immer": "^9.0.12",
|
||||
"js-video-url-parser": "^0.5.1",
|
||||
"kbar": "^0.1.0-beta.27",
|
||||
"mailgun.js": "^4.2.1",
|
||||
"micro": "^9.3.4",
|
||||
"micro-cors": "^0.1.1",
|
||||
"models": "*",
|
||||
@@ -100,7 +98,6 @@
|
||||
"eslint-config-next": "12.0.10",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"firebase-admin": "^10.0.2",
|
||||
"next-transpile-modules": "^9.0.0",
|
||||
"prettier": "^2.5.1",
|
||||
"typescript": "^4.5.5"
|
||||
|
||||
@@ -20,6 +20,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
ownerId: user.id,
|
||||
folderId,
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
select: { name: true, publishedTypebotId: true, id: true },
|
||||
})
|
||||
return res.send({ typebots })
|
||||
|
||||
@@ -75,14 +75,19 @@ const parseWhereFilter = (
|
||||
OR: [
|
||||
{
|
||||
id: typebotId,
|
||||
ownerId: user.email === adminEmail ? undefined : user.id,
|
||||
ownerId:
|
||||
(type === 'read' && user.email === adminEmail) ||
|
||||
process.env.NEXT_PUBLIC_E2E_TEST
|
||||
? undefined
|
||||
: user.id,
|
||||
},
|
||||
{
|
||||
id: typebotId,
|
||||
collaborators: {
|
||||
every: {
|
||||
some: {
|
||||
userId: user.id,
|
||||
type: type === 'write' ? CollaborationType.WRITE : undefined,
|
||||
type:
|
||||
type === 'write' ? CollaborationType.WRITE : CollaborationType.READ,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -166,6 +166,7 @@ const parseTestTypebot = (partialTypebot: Partial<Typebot>): Typebot => ({
|
||||
settings: defaultSettings,
|
||||
publicId: null,
|
||||
updatedAt: new Date(),
|
||||
createdAt: new Date(),
|
||||
publishedTypebotId: null,
|
||||
customDomain: null,
|
||||
variables: [{ id: 'var1', name: 'var1' }],
|
||||
|
||||
@@ -92,13 +92,16 @@ export const createTypebot = async ({
|
||||
}
|
||||
|
||||
export const importTypebot = async (typebot: Typebot) => {
|
||||
const typebotToImport: Omit<Typebot, 'id'> = omit(
|
||||
const typebotToImport: Omit<Typebot, 'id' | 'updatedAt' | 'createdAt'> = omit(
|
||||
{
|
||||
...typebot,
|
||||
publishedTypebotId: null,
|
||||
publicId: null,
|
||||
customDomain: null,
|
||||
},
|
||||
'id'
|
||||
'id',
|
||||
'updatedAt',
|
||||
'createdAt'
|
||||
)
|
||||
return sendRequest<Typebot>({
|
||||
url: `/api/typebots`,
|
||||
@@ -111,15 +114,19 @@ export const duplicateTypebot = async (typebotId: string) => {
|
||||
const { data } = await getTypebot(typebotId)
|
||||
const typebotToDuplicate = data?.typebot
|
||||
if (!typebotToDuplicate) return { error: new Error('Typebot not found') }
|
||||
const duplicatedTypebot: Omit<Typebot, 'id'> = omit(
|
||||
{
|
||||
...typebotToDuplicate,
|
||||
name: `${typebotToDuplicate.name} copy`,
|
||||
publishedTypebotId: null,
|
||||
publicId: null,
|
||||
},
|
||||
'id'
|
||||
)
|
||||
const duplicatedTypebot: Omit<Typebot, 'id' | 'updatedAt' | 'createdAt'> =
|
||||
omit(
|
||||
{
|
||||
...typebotToDuplicate,
|
||||
name: `${typebotToDuplicate.name} copy`,
|
||||
publishedTypebotId: null,
|
||||
publicId: null,
|
||||
customDomain: null,
|
||||
},
|
||||
'id',
|
||||
'updatedAt',
|
||||
'createdAt'
|
||||
)
|
||||
return sendRequest<Typebot>({
|
||||
url: `/api/typebots`,
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user