Fix/conflicts of custom input Name, with system field (#7856)
* Dont conflict with system fields * Allow considering a field that has system fields name to be fully editablepull/7862/head
parent
d27817ad51
commit
389633394b
|
@ -55,16 +55,6 @@ export const SystemField = z.enum([
|
||||||
"smsReminderNumber",
|
"smsReminderNumber",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const SystemFieldsEditability: Record<z.infer<typeof SystemField>, Fields[number]["editable"]> = {
|
|
||||||
name: "system",
|
|
||||||
email: "system",
|
|
||||||
location: "system",
|
|
||||||
notes: "system-but-optional",
|
|
||||||
guests: "system-but-optional",
|
|
||||||
rescheduleReason: "system-but-optional",
|
|
||||||
smsReminderNumber: "system",
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This fn is the key to ensure on the fly mapping of customInputs to bookingFields and ensuring that all the systems fields are present and correctly ordered in bookingFields
|
* This fn is the key to ensure on the fly mapping of customInputs to bookingFields and ensuring that all the systems fields are present and correctly ordered in bookingFields
|
||||||
*/
|
*/
|
||||||
|
@ -165,6 +155,7 @@ export const ensureBookingInputsHaveSystemFields = ({
|
||||||
defaultLabel: "your_name",
|
defaultLabel: "your_name",
|
||||||
type: "name",
|
type: "name",
|
||||||
name: "name",
|
name: "name",
|
||||||
|
editable: "system",
|
||||||
required: true,
|
required: true,
|
||||||
sources: [
|
sources: [
|
||||||
{
|
{
|
||||||
|
@ -179,6 +170,7 @@ export const ensureBookingInputsHaveSystemFields = ({
|
||||||
type: "email",
|
type: "email",
|
||||||
name: "email",
|
name: "email",
|
||||||
required: true,
|
required: true,
|
||||||
|
editable: "system",
|
||||||
sources: [
|
sources: [
|
||||||
{
|
{
|
||||||
label: "Default",
|
label: "Default",
|
||||||
|
@ -191,6 +183,7 @@ export const ensureBookingInputsHaveSystemFields = ({
|
||||||
defaultLabel: "location",
|
defaultLabel: "location",
|
||||||
type: "radioInput",
|
type: "radioInput",
|
||||||
name: "location",
|
name: "location",
|
||||||
|
editable: "system",
|
||||||
required: false,
|
required: false,
|
||||||
// Populated on the fly from locations. I don't want to duplicate storing locations and instead would like to be able to refer to locations in eventType.
|
// Populated on the fly from locations. I don't want to duplicate storing locations and instead would like to be able to refer to locations in eventType.
|
||||||
// options: `eventType.locations`
|
// options: `eventType.locations`
|
||||||
|
@ -222,6 +215,7 @@ export const ensureBookingInputsHaveSystemFields = ({
|
||||||
defaultLabel: "additional_notes",
|
defaultLabel: "additional_notes",
|
||||||
type: "textarea",
|
type: "textarea",
|
||||||
name: "notes",
|
name: "notes",
|
||||||
|
editable: "system-but-optional",
|
||||||
required: additionalNotesRequired,
|
required: additionalNotesRequired,
|
||||||
defaultPlaceholder: "share_additional_notes",
|
defaultPlaceholder: "share_additional_notes",
|
||||||
sources: [
|
sources: [
|
||||||
|
@ -235,6 +229,7 @@ export const ensureBookingInputsHaveSystemFields = ({
|
||||||
{
|
{
|
||||||
defaultLabel: "additional_guests",
|
defaultLabel: "additional_guests",
|
||||||
type: "multiemail",
|
type: "multiemail",
|
||||||
|
editable: "system-but-optional",
|
||||||
name: "guests",
|
name: "guests",
|
||||||
required: false,
|
required: false,
|
||||||
hidden: disableGuests,
|
hidden: disableGuests,
|
||||||
|
@ -249,6 +244,7 @@ export const ensureBookingInputsHaveSystemFields = ({
|
||||||
{
|
{
|
||||||
defaultLabel: "reschedule_reason",
|
defaultLabel: "reschedule_reason",
|
||||||
type: "textarea",
|
type: "textarea",
|
||||||
|
editable: "system-but-optional",
|
||||||
name: "rescheduleReason",
|
name: "rescheduleReason",
|
||||||
defaultPlaceholder: "reschedule_placeholder",
|
defaultPlaceholder: "reschedule_placeholder",
|
||||||
required: false,
|
required: false,
|
||||||
|
@ -338,17 +334,5 @@ export const ensureBookingInputsHaveSystemFields = ({
|
||||||
|
|
||||||
bookingFields = bookingFields.concat(missingSystemAfterFields);
|
bookingFields = bookingFields.concat(missingSystemAfterFields);
|
||||||
|
|
||||||
bookingFields = bookingFields.map((field) => {
|
|
||||||
const foundEditableMap = SystemFieldsEditability[field.name as keyof typeof SystemFieldsEditability];
|
|
||||||
if (!foundEditableMap) {
|
|
||||||
return field;
|
|
||||||
}
|
|
||||||
// Ensure that system fields editability, even if modified to something else in DB(accidentally), get's reset to what's in the code.
|
|
||||||
return {
|
|
||||||
...field,
|
|
||||||
editable: foundEditableMap,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return eventTypeBookingFields.brand<"HAS_SYSTEM_FIELDS">().parse(bookingFields);
|
return eventTypeBookingFields.brand<"HAS_SYSTEM_FIELDS">().parse(bookingFields);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue