fix: layout of dialog (edit location) on bookings page (#20268)

* refactor: streamline DialogFooter structure in EditLocationDialog component

* refactor: enhance form handling and structure in EditLocationDialog component

* refactor: update icon styling and layout in EditLocationDialog component

* revert: size to h,w

---------

Co-authored-by: Tushar Bhatt <95581504+TusharBhatt1@users.noreply.github.com>
This commit is contained in:
Gaurav Verma
2025-03-26 09:35:05 +05:30
committed by GitHub
co-authored by Tushar Bhatt
parent f98a3c9b69
commit d4edd30a07
@@ -223,55 +223,55 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
return (
<Dialog open={isOpenDialog} onOpenChange={(open) => setShowLocationModal(open)}>
<DialogContent>
<div className="flex flex-row space-x-3">
<div className="bg-subtle mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full sm:mx-0 sm:h-10 sm:w-10">
<Icon name="map-pin" className="text-emphasis h-6 w-6" />
</div>
<div className="w-full">
<div className="mt-3 text-center sm:mt-0 sm:text-left">
<h3 className="text-emphasis text-lg font-medium leading-6" id="modal-title">
{t("edit_location")}
</h3>
<Form
form={locationFormMethods}
handleSubmit={async (values) => {
const { locationType: newLocationType } = values;
let newLocation;
// For the locations that require organizer to type-in some values, we need the value
if (eventLocationType?.organizerInputType) {
newLocation = values[eventLocationType.variable];
} else {
// locationType itself can be used here e.g. For zoom we use the type itself which is "integrations:zoom". For Organizer's Default Conferencing App, it is OrganizerDefaultConferencingAppType constant
newLocation = newLocationType;
}
setIsLocationUpdating(true);
try {
await saveLocation({
newLocation,
credentialId: values.credentialId ?? null,
});
setIsLocationUpdating(false);
setShowLocationModal(false);
setSelectedLocation?.(undefined);
locationFormMethods.unregister([
"locationType",
"locationLink",
"locationAddress",
"locationPhoneNumber",
]);
} catch (error) {
// Let the user retry
setIsLocationUpdating(false);
}
}}>
<div className="flex flex-row space-x-3">
<div className="bg-subtle mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full sm:mx-0 sm:h-10 sm:w-10">
<Icon name="map-pin" className="text-emphasis h-6 w-6" />
</div>
<div className="mt-3 text-center sm:mt-0 sm:text-left" />
<div className="w-full">
<div className="mt-3 text-center sm:mt-0 sm:text-left">
<h3 className="text-emphasis text-lg font-medium leading-6" id="modal-title">
{t("edit_location")}
</h3>
</div>
<div className="mt-3 text-center sm:mt-0 sm:text-left" />
<p className="text-emphasis mb-2 ml-1 mt-6 text-sm font-bold">{t("current_location")}:</p>
<p className="text-emphasis mb-2 ml-1 break-all text-sm">
{getHumanReadableLocationValue(booking.location, t)}
</p>
<Form
form={locationFormMethods}
handleSubmit={async (values) => {
const { locationType: newLocationType } = values;
let newLocation;
// For the locations that require organizer to type-in some values, we need the value
if (eventLocationType?.organizerInputType) {
newLocation = values[eventLocationType.variable];
} else {
// locationType itself can be used here e.g. For zoom we use the type itself which is "integrations:zoom". For Organizer's Default Conferencing App, it is OrganizerDefaultConferencingAppType constant
newLocation = newLocationType;
}
setIsLocationUpdating(true);
try {
await saveLocation({
newLocation,
credentialId: values.credentialId ?? null,
});
setIsLocationUpdating(false);
setShowLocationModal(false);
setSelectedLocation?.(undefined);
locationFormMethods.unregister([
"locationType",
"locationLink",
"locationAddress",
"locationPhoneNumber",
]);
} catch (error) {
// Let the user retry
setIsLocationUpdating(false);
}
}}>
<p className="text-emphasis mb-2 ml-1 mt-6 text-sm font-bold">{t("current_location")}:</p>
<p className="text-emphasis mb-2 ml-1 break-all text-sm">
{getHumanReadableLocationValue(booking.location, t)}
</p>
<QueryCell
query={locationsQuery}
success={({ data }) => {
@@ -328,25 +328,25 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
}}
/>
{selectedLocation && SelectedLocationInput}
<DialogFooter showDivider className="mt-8">
<Button
onClick={() => {
setShowLocationModal(false);
setSelectedLocation?.(undefined);
setEditingLocationType?.("");
locationFormMethods.unregister(["locationType", "locationLink"]);
}}
type="button"
color="secondary">
{t("cancel")}
</Button>
<Button data-testid="update-location" type="submit" disabled={isLocationUpdating}>
{t("update")}
</Button>
</DialogFooter>
</Form>
</div>
</div>
</div>
<DialogFooter showDivider className="mt-8">
<Button
onClick={() => {
setShowLocationModal(false);
setSelectedLocation?.(undefined);
setEditingLocationType?.("");
locationFormMethods.unregister(["locationType", "locationLink"]);
}}
type="button"
color="secondary">
{t("cancel")}
</Button>
<Button data-testid="update-location" type="submit" disabled={isLocationUpdating}>
{t("update")}
</Button>
</DialogFooter>
</Form>
</DialogContent>
</Dialog>
);