diff --git a/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx b/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx index 5a2402234f..901bc21be0 100644 --- a/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx +++ b/packages/app-store/routing-forms/pages/form-edit/[...appPages].tsx @@ -18,7 +18,7 @@ import { Skeleton, TextField, } from "@calcom/ui"; -import { Plus, FileText, X } from "@calcom/ui/components/icon"; +import { Plus, FileText, X, ArrowUp, ArrowDown } from "@calcom/ui/components/icon"; import type { inferSSRProps } from "@lib/types/inferSSRProps"; @@ -29,7 +29,7 @@ import SingleForm, { export { getServerSideProps }; type HookForm = UseFormReturn; -type SelectOption = { placeholder: string; value: string }; +type SelectOption = { placeholder: string; value: string; id: string }; export const FieldTypes = [ { @@ -88,12 +88,13 @@ function Field({ appUrl: string; }) { const { t } = useLocale(); + const [animationRef] = useAutoAnimate(); const [options, setOptions] = useState([ - { placeholder: "< 10", value: "" }, - { placeholder: "10-100", value: "" }, - { placeholder: "100-500", value: "" }, - { placeholder: "> 500", value: "" }, + { placeholder: "< 10", value: "", id: uuidv4() }, + { placeholder: "10-100", value: "", id: uuidv4() }, + { placeholder: "100-500", value: "", id: uuidv4() }, + { placeholder: "> 500", value: "", id: uuidv4() }, ]); const handleRemoveOptions = (index: number) => { @@ -108,6 +109,7 @@ function Field({ { placeholder: "New Option", value: "", + id: uuidv4(), }, ]); }; @@ -118,6 +120,7 @@ function Field({ const values: SelectOption[] = originalValues.split("\n").map((fieldValue) => ({ value: fieldValue, placeholder: "", + id: uuidv4(), })); setOptions(values); } @@ -132,6 +135,7 @@ function Field({ ...opt, ...(index === optionIndex ? { value: e.target.value } : {}), })); + setOptions(updatedOptions); updateSelectText(updatedOptions); }; @@ -156,6 +160,19 @@ function Field({ name: `${hookFieldNamespace}.identifier`, }); + function move(index: number, increment: 1 | -1) { + const newList = [...options]; + + const type = options[index]; + const tmp = options[index + increment]; + if (tmp) { + newList[index] = tmp; + newList[index + increment] = type; + } + setOptions(newList); + updateSelectText(newList); + } + return (
{t("options")} - {options.map((field, index) => ( -
- handleChange(e, index)} - addOnSuffix={ - - } - /> -
- ))} +
    + {options.map((field, index) => ( +
  • +
    + {options.length && index !== 0 ? ( + + ) : null} + {options.length && index !== options.length - 1 ? ( + + ) : null} +
    +
    + handleChange(e, index)} + addOnSuffix={ + + } + /> +
    +
  • + ))} +