disable guests field when offer seats is enabled (#10132)

Co-authored-by: rkreddy99 <[email protected]>
This commit is contained in:
Rama Krishna Reddyandrkreddy99 authored and GitHub committed 2023-07-13 13:57:30 +02:00
1 parent 0093b6faa5
commit 26afc077a7
3 files changed
+8 -9

No files matched your search

@@ -299,8 +299,9 @@ export const FormBuilder = function FormBuilder({
const fieldType = FieldTypesMap[field.type];
const isRequired = field.required;
const isFieldEditableSystemButOptional = field.editable === "system-but-optional";
const isFieldEditableSystemButHidden = field.editable === "system-but-hidden";
const isFieldEditableSystem = field.editable === "system";
const isUserField = !isFieldEditableSystem && !isFieldEditableSystemButOptional;
const isUserField = !isFieldEditableSystem && !isFieldEditableSystemButOptional && !isFieldEditableSystemButHidden;
if (!fieldType) {
throw new Error(`Invalid field type - ${field.type}`);
@@ -368,7 +369,7 @@ export const FormBuilder = function FormBuilder({
</div>
{field.editable !== "user-readonly" && !disabled && (
<div className="flex items-center space-x-2">
{!isFieldEditableSystem && !disabled && (
{!isFieldEditableSystem && !isFieldEditableSystemButHidden && !disabled && (
<Switch
data-testid="toggle-field"
disabled={isFieldEditableSystem}
@@ -20,6 +20,7 @@ const fieldTypeEnum = z.enum([
export const EditableSchema = z.enum([
"system", // Can't be deleted, can't be hidden, name can't be edited, can't be marked optional
"system-but-optional", // Can't be deleted. Name can't be edited. But can be hidden or be marked optional
"system-but-hidden", // Can't be deleted, name can't be edited, will be shown
"user", // Fully editable
"user-readonly", // All fields are readOnly.
]);
@@ -70,13 +71,7 @@ const fieldSchema = z.object({
required: z.boolean().default(false).optional(),
hidden: z.boolean().optional(),
editable: z
.enum([
"system", // Can't be deleted, can't be hidden, name can't be edited, can't be marked optional
"system-but-optional", // Can't be deleted. Name can't be edited. But can be hidden or be marked optional
"user", // Fully editable
"user-readonly", // All fields are readOnly.
])
editable: EditableSchema
.default("user")
.optional(),
sources: z