From 14fa867cd52a627dc4c694460c471a5684c1f53a Mon Sep 17 00:00:00 2001 From: odapX Date: Fri, 5 Apr 2024 22:52:45 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20migrate=20form=20to=20ui?= =?UTF-8?q?=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlablaFormEditor/FieldsInput.tsx | 66 +- .../components/BlablaFormEditor/index.tsx | 85 --- .../dashboard/components/BlablaFormViewer.tsx | 156 +---- apps/dashboard/components/ChatBox.tsx | 19 +- apps/dashboard/components/FileUploader.tsx | 5 +- apps/dashboard/components/TraditionalForm.tsx | 563 ----------------- .../components/TraditionalFormWrapper.tsx | 37 ++ apps/dashboard/pages/forms/index.tsx | 13 +- packages/lib/accepted-mime-types.ts | 7 + packages/lib/forms/templates.ts | 159 ++++- packages/lib/types/dtos.ts | 7 +- packages/ui/package.json | 1 + .../ui/src}/FileUploaderDropZone.tsx | 8 +- packages/ui/src/TraditionalForm.tsx | 285 +++++++++ .../ui/src}/VisuallyHiddenInput.tsx | 0 packages/ui/src/hooks/useFileUpload.ts | 93 +++ packages/ui/src/types/form.ts | 23 + packages/ui/src/utils/fieldTypesMap.tsx | 224 +++++++ pnpm-lock.yaml | 582 +++++++++++++----- 19 files changed, 1288 insertions(+), 1045 deletions(-) delete mode 100644 apps/dashboard/components/TraditionalForm.tsx create mode 100644 apps/dashboard/components/TraditionalFormWrapper.tsx rename {apps/dashboard/components => packages/ui/src}/FileUploaderDropZone.tsx (93%) create mode 100644 packages/ui/src/TraditionalForm.tsx rename {apps/dashboard/components => packages/ui/src}/VisuallyHiddenInput.tsx (100%) create mode 100644 packages/ui/src/hooks/useFileUpload.ts create mode 100644 packages/ui/src/types/form.ts create mode 100644 packages/ui/src/utils/fieldTypesMap.tsx diff --git a/apps/dashboard/components/BlablaFormEditor/FieldsInput.tsx b/apps/dashboard/components/BlablaFormEditor/FieldsInput.tsx index f2d2f8379..5f01d179e 100644 --- a/apps/dashboard/components/BlablaFormEditor/FieldsInput.tsx +++ b/apps/dashboard/components/BlablaFormEditor/FieldsInput.tsx @@ -30,9 +30,9 @@ import { import { CreateFormSchema } from '@chaindesk/lib/types/dtos'; import Input from '@chaindesk/ui/Input'; +import { FieldType } from '@chaindesk/ui/types/form'; import { SortableList } from '../dnd/SortableList'; -import { FieldType } from '../TraditionalForm'; import { forceSubmit } from './utils'; @@ -45,6 +45,7 @@ const fieldTypes = [ 'email', 'phoneNumber', 'text', + 'number', 'textArea', 'select', 'file', @@ -313,69 +314,6 @@ function FieldsInput({ type = 'traditional' }: Props) { )} /> )} - {type == formType.conversational && - fieldsValues?.map((field, index) => ( -
- - ( - - )} - > - { - remove(index); - forceSubmit(); - }} - > - - - } - /> - - - {fieldsValues?.[index]?.type === 'multiple_choice' && ( - - - actionLabel="Add Choice" - name={`draftConfig.fields.${index}.choices` as any} - /> - - )} -
- ))}