feat: CustomEventType placeholder and API fixes (#446)
* feat: add optional placeholder for text/multi-line text custom inputs on event types * fix: delete associations of event type first * fix: remove unneeded check * fix: minor tweak Co-authored-by: mihaic195 <mihai@sortlist.com> Co-authored-by: Bailey Pumfleet <pumfleet@hey.com>
This commit is contained in:
parent
44e0af9641
commit
3894ee12d1
5 changed files with 40 additions and 2 deletions
|
@ -286,7 +286,7 @@ export default function Book(props: any): JSX.Element {
|
||||||
required={input.required}
|
required={input.required}
|
||||||
rows={3}
|
rows={3}
|
||||||
className="shadow-sm dark:bg-black dark:text-white dark:border-gray-900 focus:ring-black focus:border-black block w-full sm:text-sm border-gray-300 rounded-md"
|
className="shadow-sm dark:bg-black dark:text-white dark:border-gray-900 focus:ring-black focus:border-black block w-full sm:text-sm border-gray-300 rounded-md"
|
||||||
placeholder=""
|
placeholder={input.placeholder}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{input.type === EventTypeCustomInputType.TEXT && (
|
{input.type === EventTypeCustomInputType.TEXT && (
|
||||||
|
@ -296,7 +296,7 @@ export default function Book(props: any): JSX.Element {
|
||||||
id={"custom_" + input.id}
|
id={"custom_" + input.id}
|
||||||
required={input.required}
|
required={input.required}
|
||||||
className="shadow-sm dark:bg-black dark:text-white dark:border-gray-900 focus:ring-black focus:border-black block w-full sm:text-sm border-gray-300 rounded-md"
|
className="shadow-sm dark:bg-black dark:text-white dark:border-gray-900 focus:ring-black focus:border-black block w-full sm:text-sm border-gray-300 rounded-md"
|
||||||
placeholder=""
|
placeholder={input.placeholder}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{input.type === EventTypeCustomInputType.NUMBER && (
|
{input.type === EventTypeCustomInputType.NUMBER && (
|
||||||
|
|
|
@ -35,6 +35,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
type: input.type,
|
type: input.type,
|
||||||
label: input.label,
|
label: input.label,
|
||||||
required: input.required,
|
required: input.required,
|
||||||
|
placeholder: input.placeholder,
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
update: req.body.customInputs
|
update: req.body.customInputs
|
||||||
|
@ -44,6 +45,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
type: input.type,
|
type: input.type,
|
||||||
label: input.label,
|
label: input.label,
|
||||||
required: input.required,
|
required: input.required,
|
||||||
|
placeholder: input.placeholder,
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
id: input.id,
|
id: input.id,
|
||||||
|
@ -107,6 +109,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.method == "DELETE") {
|
if (req.method == "DELETE") {
|
||||||
|
// Delete associations first
|
||||||
|
await prisma.eventTypeCustomInput.deleteMany({
|
||||||
|
where: {
|
||||||
|
eventTypeId: req.body.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
await prisma.eventType.delete({
|
await prisma.eventType.delete({
|
||||||
where: {
|
where: {
|
||||||
id: req.body.id,
|
id: req.body.id,
|
||||||
|
|
|
@ -347,12 +347,14 @@ export default function EventTypePage({
|
||||||
|
|
||||||
const customInput: EventTypeCustomInput = {
|
const customInput: EventTypeCustomInput = {
|
||||||
label: e.target.label.value,
|
label: e.target.label.value,
|
||||||
|
placeholder: e.target.placeholder?.value,
|
||||||
required: e.target.required.checked,
|
required: e.target.required.checked,
|
||||||
type: e.target.type.value,
|
type: e.target.type.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (selectedCustomInput) {
|
if (selectedCustomInput) {
|
||||||
selectedCustomInput.label = customInput.label;
|
selectedCustomInput.label = customInput.label;
|
||||||
|
selectedCustomInput.placeholder = customInput.placeholder;
|
||||||
selectedCustomInput.required = customInput.required;
|
selectedCustomInput.required = customInput.required;
|
||||||
selectedCustomInput.type = customInput.type;
|
selectedCustomInput.type = customInput.type;
|
||||||
} else {
|
} else {
|
||||||
|
@ -645,6 +647,13 @@ export default function EventTypePage({
|
||||||
<div>
|
<div>
|
||||||
<span className="ml-2 text-sm">Label: {customInput.label}</span>
|
<span className="ml-2 text-sm">Label: {customInput.label}</span>
|
||||||
</div>
|
</div>
|
||||||
|
{customInput.placeholder && (
|
||||||
|
<div>
|
||||||
|
<span className="ml-2 text-sm">
|
||||||
|
Placeholder: {customInput.placeholder}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div>
|
<div>
|
||||||
<span className="ml-2 text-sm">Type: {customInput.type}</span>
|
<span className="ml-2 text-sm">Type: {customInput.type}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1015,6 +1024,23 @@ export default function EventTypePage({
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{(selectedInputOption.value === EventTypeCustomInputType.TEXT ||
|
||||||
|
selectedInputOption.value === EventTypeCustomInputType.TEXTLONG) && (
|
||||||
|
<div className="mb-2">
|
||||||
|
<label htmlFor="placeholder" className="block text-sm font-medium text-gray-700">
|
||||||
|
Placeholder
|
||||||
|
</label>
|
||||||
|
<div className="mt-1">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="placeholder"
|
||||||
|
id="placeholder"
|
||||||
|
className="shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-300 rounded-sm"
|
||||||
|
defaultValue={selectedCustomInput?.placeholder}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="flex items-center h-5">
|
<div className="flex items-center h-5">
|
||||||
<input
|
<input
|
||||||
id="required"
|
id="required"
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "EventTypeCustomInput" ADD COLUMN "placeholder" TEXT NOT NULL DEFAULT E'';
|
|
@ -177,6 +177,7 @@ model EventTypeCustomInput {
|
||||||
label String
|
label String
|
||||||
type EventTypeCustomInputType
|
type EventTypeCustomInputType
|
||||||
required Boolean
|
required Boolean
|
||||||
|
placeholder String @default("")
|
||||||
}
|
}
|
||||||
|
|
||||||
model ResetPasswordRequest {
|
model ResetPasswordRequest {
|
||||||
|
|
Loading…
Reference in a new issue