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 <[email protected]>
This commit is contained in:
1 parent
f98a3c9b69
commit
d4edd30a07
1 file changed
+65
-65
@@ -223,55 +223,55 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
|||||||
return (
|
return (
|
||||||
<Dialog open={isOpenDialog} onOpenChange={(open) => setShowLocationModal(open)}>
|
<Dialog open={isOpenDialog} onOpenChange={(open) => setShowLocationModal(open)}>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<div className="flex flex-row space-x-3">
|
<Form
|
||||||
<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">
|
form={locationFormMethods}
|
||||||
<Icon name="map-pin" className="text-emphasis h-6 w-6" />
|
handleSubmit={async (values) => {
|
||||||
</div>
|
const { locationType: newLocationType } = values;
|
||||||
<div className="w-full">
|
let newLocation;
|
||||||
<div className="mt-3 text-center sm:mt-0 sm:text-left">
|
// For the locations that require organizer to type-in some values, we need the value
|
||||||
<h3 className="text-emphasis text-lg font-medium leading-6" id="modal-title">
|
if (eventLocationType?.organizerInputType) {
|
||||||
{t("edit_location")}
|
newLocation = values[eventLocationType.variable];
|
||||||
</h3>
|
} 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>
|
||||||
<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 mt-6 text-sm font-bold">{t("current_location")}:</p>
|
||||||
<p className="text-emphasis mb-2 ml-1 break-all text-sm">
|
<p className="text-emphasis mb-2 ml-1 break-all text-sm">
|
||||||
{getHumanReadableLocationValue(booking.location, t)}
|
{getHumanReadableLocationValue(booking.location, t)}
|
||||||
</p>
|
</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);
|
|
||||||
}
|
|
||||||
}}>
|
|
||||||
<QueryCell
|
<QueryCell
|
||||||
query={locationsQuery}
|
query={locationsQuery}
|
||||||
success={({ data }) => {
|
success={({ data }) => {
|
||||||
@@ -328,25 +328,25 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{selectedLocation && SelectedLocationInput}
|
{selectedLocation && SelectedLocationInput}
|
||||||
<DialogFooter showDivider className="mt-8">
|
</div>
|
||||||
<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>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user