From 8ce4e4808d36133a49a7af8ad61665e9dbbfbc72 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 28 Nov 2023 16:32:56 +0100 Subject: [PATCH] :bug: (share) Fix duplicate folderId issue --- .../builder/src/components/inputs/RadioButtons.tsx | 8 +++++--- .../share/components/SharePopoverContent.tsx | 4 ++-- .../src/features/typebot/api/importTypebot.ts | 2 ++ .../src/pages/typebots/[typebotId]/duplicate.tsx | 1 + apps/docs/openapi/builder/_spec_.json | 14 ++------------ 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/apps/builder/src/components/inputs/RadioButtons.tsx b/apps/builder/src/components/inputs/RadioButtons.tsx index 90345ce07..a31134eca 100644 --- a/apps/builder/src/components/inputs/RadioButtons.tsx +++ b/apps/builder/src/components/inputs/RadioButtons.tsx @@ -1,7 +1,7 @@ import { Box, Flex, - HStack, + Stack, useColorModeValue, useRadio, useRadioGroup, @@ -13,12 +13,14 @@ type Props = { options: (T | { value: T; label: ReactNode })[] value?: T defaultValue?: T + direction?: 'row' | 'column' onSelect: (newValue: T) => void } export const RadioButtons = ({ options, value, defaultValue, + direction = 'row', onSelect, }: Props) => { const { getRootProps, getRadioProps } = useRadioGroup({ @@ -30,7 +32,7 @@ export const RadioButtons = ({ const group = getRootProps() return ( - + {options.map((item) => { const radio = getRadioProps({ value: parseValue(item) }) return ( @@ -39,7 +41,7 @@ export const RadioButtons = ({ ) })} - + ) } diff --git a/apps/builder/src/features/share/components/SharePopoverContent.tsx b/apps/builder/src/features/share/components/SharePopoverContent.tsx index 1dff03b49..d0896cc74 100644 --- a/apps/builder/src/features/share/components/SharePopoverContent.tsx +++ b/apps/builder/src/features/share/components/SharePopoverContent.tsx @@ -1,5 +1,5 @@ import { Stack, Input, InputGroup, InputRightElement } from '@chakra-ui/react' -import React, { useMemo } from 'react' +import React from 'react' import { SwitchWithRelatedSettings } from '@/components/SwitchWithRelatedSettings' import { CopyButton } from '@/components/CopyButton' import { CollaborationList } from '@/features/collaboration/components/CollaborationList' @@ -8,7 +8,7 @@ import { useTypebot } from '@/features/editor/providers/TypebotProvider' export const SharePopoverContent = () => { const { typebot, updateTypebot } = useTypebot() - const currentUrl = useMemo(() => window.location.href.split('?')[0], []) + const currentUrl = `${window.location.origin}/typebots/${typebot?.id}/edit` const updateIsPublicShareEnabled = async (isEnabled: boolean) => { await updateTypebot({ diff --git a/apps/builder/src/features/typebot/api/importTypebot.ts b/apps/builder/src/features/typebot/api/importTypebot.ts index 00c48f127..4aed24c97 100644 --- a/apps/builder/src/features/typebot/api/importTypebot.ts +++ b/apps/builder/src/features/typebot/api/importTypebot.ts @@ -28,6 +28,7 @@ const omittedProps = { resultsTablePreferencesSchema: true, selectedThemeTemplateId: true, publicId: true, + folderId: true, } as const const importingTypebotSchema = z.preprocess( @@ -62,6 +63,7 @@ const migrateImportingTypebot = ( isArchived: false, whatsAppCredentialsId: null, publicId: null, + folderId: null, } satisfies Typebot return migrateTypebot(fullTypebot) } diff --git a/apps/builder/src/pages/typebots/[typebotId]/duplicate.tsx b/apps/builder/src/pages/typebots/[typebotId]/duplicate.tsx index 5ac7a1352..bea946e0d 100644 --- a/apps/builder/src/pages/typebots/[typebotId]/duplicate.tsx +++ b/apps/builder/src/pages/typebots/[typebotId]/duplicate.tsx @@ -42,6 +42,7 @@ const Page = () => { Choose a workspace to duplicate {typebot?.name} in: ({ value: workspace.id, label: ( diff --git a/apps/docs/openapi/builder/_spec_.json b/apps/docs/openapi/builder/_spec_.json index 0c07c8a41..a973b245a 100644 --- a/apps/docs/openapi/builder/_spec_.json +++ b/apps/docs/openapi/builder/_spec_.json @@ -45489,10 +45489,6 @@ "type": "string", "nullable": true }, - "folderId": { - "type": "string", - "nullable": true - }, "resultsTablePreferences": { "type": "object", "properties": { @@ -45536,8 +45532,7 @@ "variables", "theme", "settings", - "icon", - "folderId" + "icon" ], "additionalProperties": false }, @@ -49194,10 +49189,6 @@ "type": "string", "nullable": true }, - "folderId": { - "type": "string", - "nullable": true - }, "resultsTablePreferences": { "type": "object", "properties": { @@ -49242,8 +49233,7 @@ "variables", "theme", "settings", - "icon", - "folderId" + "icon" ], "additionalProperties": false }