diff --git a/lib/eventTypeInput.ts b/lib/eventTypeInput.ts
deleted file mode 100644
index e8c76e42..00000000
--- a/lib/eventTypeInput.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-export enum EventTypeCustomInputType {
- Text = 'text',
- TextLong = 'textLong',
- Number = 'number',
- Bool = 'bool',
-}
-
-export interface EventTypeCustomInput {
- id?: number;
- type: EventTypeCustomInputType;
- label: string;
- required: boolean;
-}
diff --git a/pages/[user]/book.tsx b/pages/[user]/book.tsx
index 74e2c785..92a27ef9 100644
--- a/pages/[user]/book.tsx
+++ b/pages/[user]/book.tsx
@@ -3,6 +3,7 @@ import Link from "next/link";
import { useRouter } from "next/router";
import { CalendarIcon, ClockIcon, ExclamationIcon, LocationMarkerIcon } from "@heroicons/react/solid";
import prisma, { whereAndSelect } from "../../lib/prisma";
+import { EventTypeCustomInputType } from "@prisma/client";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "../../lib/telemetry";
import { useEffect, useState } from "react";
import dayjs from "dayjs";
@@ -13,7 +14,6 @@ import PhoneInput from "react-phone-number-input";
import { LocationType } from "../../lib/location";
import Avatar from "../../components/Avatar";
import Button from "../../components/ui/Button";
-import { EventTypeCustomInputType } from "../../lib/eventTypeInput";
import Theme from "@components/Theme";
import { ReactMultiEmail } from "react-multi-email";
import "react-multi-email/style.css";
@@ -71,7 +71,7 @@ export default function Book(props: any): JSX.Element {
.map((input) => {
const data = event.target["custom_" + input.id];
if (data) {
- if (input.type === EventTypeCustomInputType.Bool) {
+ if (input.type === EventTypeCustomInputType.BOOL) {
return input.label + "\n" + (data.checked ? "Yes" : "No");
} else {
return input.label + "\n" + data.value;
@@ -273,14 +273,14 @@ export default function Book(props: any): JSX.Element {
.sort((a, b) => a.id - b.id)
.map((input) => (
- {input.type !== EventTypeCustomInputType.Bool && (
+ {input.type !== EventTypeCustomInputType.BOOL && (
)}
- {input.type === EventTypeCustomInputType.TextLong && (
+ {input.type === EventTypeCustomInputType.TEXTLONG && (
)}
- {input.type === EventTypeCustomInputType.Text && (
+ {input.type === EventTypeCustomInputType.TEXT && (
)}
- {input.type === EventTypeCustomInputType.Number && (
+ {input.type === EventTypeCustomInputType.NUMBER && (
)}
- {input.type === EventTypeCustomInputType.Bool && (
+ {input.type === EventTypeCustomInputType.BOOL && (
("horizontal");
@@ -342,28 +342,19 @@ export default function EventTypePage({
type: e.target.type.value,
};
- if (e.target.id?.value) {
- const index = customInputs.findIndex((inp) => inp.id === +e.target.id?.value);
- if (index >= 0) {
- const input = customInputs[index];
- input.label = customInput.label;
- input.required = customInput.required;
- input.type = customInput.type;
- setCustomInputs(customInputs);
- }
+ if (selectedCustomInput) {
+ selectedCustomInput.label = customInput.label;
+ selectedCustomInput.required = customInput.required;
+ selectedCustomInput.type = customInput.type;
} else {
setCustomInputs(customInputs.concat(customInput));
}
closeAddCustomModal();
};
- const removeCustom = (customInput, e) => {
- e.preventDefault();
- const index = customInputs.findIndex((inp) => inp.id === customInput.id);
- if (index >= 0) {
- customInputs.splice(index, 1);
- setCustomInputs([...customInputs]);
- }
+ const removeCustom = (index: number) => {
+ customInputs.splice(index, 1);
+ setCustomInputs([...customInputs]);
};
return (
@@ -638,8 +629,8 @@ export default function EventTypePage({
- {customInputs.map((customInput) => (
- -
+ {customInputs.map((customInput: EventTypeCustomInput, idx: number) => (
+
-
@@ -661,7 +652,7 @@ export default function EventTypePage({
className="mr-2 text-sm text-primary-600">
Edit
-
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 62e93561..fe1f869f 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -162,12 +162,19 @@ model SelectedCalendar {
@@id([userId,integration,externalId])
}
+enum EventTypeCustomInputType {
+ TEXT @map("text")
+ TEXTLONG @map("textLong")
+ NUMBER @map("number")
+ BOOL @map("bool")
+}
+
model EventTypeCustomInput {
id Int @id @default(autoincrement())
eventTypeId Int
eventType EventType @relation(fields: [eventTypeId], references: [id])
label String
- type String
+ type EventTypeCustomInputType
required Boolean
}