Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: location change during rescheduling #15810

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

const ManagedEventTypeDialog = dynamic(() => import("@components/eventtype/ManagedEventDialog"));

const AssignmentWarningDialog = dynamic(() => import("@components/eventtype/AssignmentWarningDialog"));

Check warning on line 120 in apps/web/modules/event-types/views/event-types-single-view.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/modules/event-types/views/event-types-single-view.tsx#L120

[@typescript-eslint/no-unused-vars] 'AssignmentWarningDialog' is assigned a value but never used. Allowed unused vars must match /^_/u.

export type Host = { isFixed: boolean; userId: number; priority: number };

Expand Down Expand Up @@ -223,10 +223,11 @@
});

const { eventType, locationOptions, team, teamMembers, currentUserMembership, destinationCalendar } = props;
const [isOpenAssignmentWarnDialog, setIsOpenAssignmentWarnDialog] = useState<boolean>(false);

Check warning on line 226 in apps/web/modules/event-types/views/event-types-single-view.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/modules/event-types/views/event-types-single-view.tsx#L226

[@typescript-eslint/no-unused-vars] 'isOpenAssignmentWarnDialog' is assigned a value but never used. Allowed unused elements of array destructuring patterns must match /^_/u.

Check warning on line 226 in apps/web/modules/event-types/views/event-types-single-view.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/modules/event-types/views/event-types-single-view.tsx#L226

[@typescript-eslint/no-unused-vars] 'setIsOpenAssignmentWarnDialog' is assigned a value but never used. Allowed unused elements of array destructuring patterns must match /^_/u.
const [pendingRoute, setPendingRoute] = useState("");

Check warning on line 227 in apps/web/modules/event-types/views/event-types-single-view.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/modules/event-types/views/event-types-single-view.tsx#L227

[@typescript-eslint/no-unused-vars] 'pendingRoute' is assigned a value but never used. Allowed unused elements of array destructuring patterns must match /^_/u.

Check warning on line 227 in apps/web/modules/event-types/views/event-types-single-view.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/modules/event-types/views/event-types-single-view.tsx#L227

[@typescript-eslint/no-unused-vars] 'setPendingRoute' is assigned a value but never used. Allowed unused elements of array destructuring patterns must match /^_/u.
const leaveWithoutAssigningHosts = useRef(false);

Check warning on line 228 in apps/web/modules/event-types/views/event-types-single-view.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/modules/event-types/views/event-types-single-view.tsx#L228

[@typescript-eslint/no-unused-vars] 'leaveWithoutAssigningHosts' is assigned a value but never used. Allowed unused vars must match /^_/u.
const [animationParentRef] = useAutoAnimate<HTMLDivElement>();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this whitespace change.

const updateMutation = trpc.viewer.eventTypes.update.useMutation({
onSuccess: async () => {
const currentValues = formMethods.getValues();
Expand Down Expand Up @@ -268,7 +269,7 @@
},
});

const router = useRouter();

Check warning on line 272 in apps/web/modules/event-types/views/event-types-single-view.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/modules/event-types/views/event-types-single-view.tsx#L272

[@typescript-eslint/no-unused-vars] 'router' is assigned a value but never used. Allowed unused vars must match /^_/u.

const [periodDates] = useState<{ startDate: Date; endDate: Date }>({
startDate: new Date(eventType.periodStartDate || Date.now()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export type SelectLikeComponentProps<
}
? TVal["value"]
: TVal;
optionValue?: string;
}[];
} & CommonProps<TVal>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ export const BookingFields = ({
return null;
}

// Attendee location field can be edited during reschedule
if (field.name === SystemField.Enum.location) {
if (locationResponse?.value === "attendeeInPerson" || "phone") {
readOnly = false;
}
// TODO: We need to ensure that location field is properly updated in Booking Success Page, email, calendar, webhook after reschedule
readOnly = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this change because if (locationResponse?.value === "attendeeInPerson" || "phone") { condition is faulty.

It is always truthy. So, it seems like location change is enabled for attendeeInPerson and phone but in fact it is enabled in all cases.

Introduced in #11651

I think with this PR we should intend to be able to make any change to location field and test it accordingly.

}

// Dynamically populate location field options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function getLocationsOptionsForSelect(
label: translatedLocation || locationString,
value: type,
inputPlaceholder: t(eventLocation?.attendeeInputPlaceholder || ""),
optionValue: location?.link || location?.address || "",
};
})
.filter(notEmpty);
Expand Down
4 changes: 2 additions & 2 deletions packages/features/form-builder/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export const Components: Record<FieldType, Component> = {
if (!value) {
setValue({
value: options[0]?.value,
optionValue: "",
optionValue: options[0]?.optionValue || "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this and other change in this component.

optionValue can only be updated through ComponentForField at line 469.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The booking view expects the optionValue to have the a valid value.

"optionValue" in bookingInfo.responses.location

Currently the optionValue is always empty regardless of the option selected.

});
}
}, [options, setValue, value]);
Expand Down Expand Up @@ -429,7 +429,7 @@ export const Components: Record<FieldType, Component> = {
onChange={(e) => {
setValue({
value: e.target.value,
optionValue: "",
optionValue: option?.optionValue || "",
});
}}
checked={value?.value === option.value}
Expand Down
10 changes: 6 additions & 4 deletions packages/features/form-builder/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ const fieldTypeEnum = z.enum([
export type FieldType = z.infer<typeof fieldTypeEnum>;

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
"system", // Deletable-No, CanChangeIdentifier-No, Toggleable-No, CanMarkOptional-No.
"system-but-optional", // Deletable-No, CanChangeIdentifier-No, Toggleable-Yes, CanMarkOptional-Yes
// TODO: Seems to be unused and could probably be deleted
"system-but-hidden", // Deletable-No, CanChangeIdentifier-No, Always Hidden and thus Optional
"user", // Fully editable. Deletable-Yes, CanChangeIdentifier-Yes, Toggleable-Yes, CanMarkOptional-Yes
// TODO: Seems to be unused and could probably be deleted
Comment on lines +31 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the comments to make it more readable.

"user-readonly", // All fields are readOnly.
]);

Expand Down
Loading