Edit location dialog new select component (#5647)
This commit is contained in:
1 parent
7df04c1d50
commit
454311dd52
9 files changed
+175
-29
No files matched your search
@@ -12,6 +12,7 @@ export type DefaultEventLocationType = {
|
||||
type: DefaultEventLocationTypeEnum;
|
||||
label: string;
|
||||
messageForOrganizer: string;
|
||||
category: string;
|
||||
|
||||
iconUrl: string;
|
||||
|
||||
@@ -71,6 +72,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
|
||||
attendeeInputPlaceholder: `Enter Address`,
|
||||
defaultValueVariable: "attendeeAddress",
|
||||
iconUrl: "/map-pin.svg",
|
||||
category: "in person",
|
||||
},
|
||||
{
|
||||
default: true,
|
||||
@@ -82,6 +84,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
|
||||
variable: "locationAddress",
|
||||
defaultValueVariable: "address",
|
||||
iconUrl: "/map-pin.svg",
|
||||
category: "in person",
|
||||
},
|
||||
{
|
||||
default: true,
|
||||
@@ -92,6 +95,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
|
||||
messageForOrganizer: "Provide a Meeting Link",
|
||||
defaultValueVariable: "link",
|
||||
iconUrl: "/link.svg",
|
||||
category: "other",
|
||||
},
|
||||
{
|
||||
default: true,
|
||||
@@ -106,6 +110,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
|
||||
// This isn't inputType phone because organizer doesn't need to provide it.
|
||||
// inputType: "phone"
|
||||
iconUrl: "/phone.svg",
|
||||
category: "phone",
|
||||
},
|
||||
{
|
||||
default: true,
|
||||
@@ -116,6 +121,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
|
||||
variable: "locationPhoneNumber",
|
||||
defaultValueVariable: "hostPhoneNumber",
|
||||
iconUrl: "/phone.svg",
|
||||
category: "phone",
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -72,6 +72,62 @@ export function getLocationOptions(integrations: ReturnType<typeof getApps>, t:
|
||||
return translateLocations(locations, t);
|
||||
}
|
||||
|
||||
export function getLocationGroupedOptions(integrations: ReturnType<typeof getApps>, t: TFunction) {
|
||||
const apps: Record<string, { label: string; value: string; disabled?: boolean; icon?: string }[]> = {};
|
||||
integrations.forEach((app) => {
|
||||
if (app.locationOption) {
|
||||
const category = app.category;
|
||||
const option = { ...app.locationOption, icon: app.imageSrc };
|
||||
if (apps[category]) {
|
||||
apps[category] = [...apps[category], option];
|
||||
} else {
|
||||
apps[category] = [option];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
defaultLocations.forEach((l) => {
|
||||
const category = l.category;
|
||||
if (apps[category]) {
|
||||
apps[category] = [
|
||||
...apps[category],
|
||||
{
|
||||
label: l.label,
|
||||
value: l.type,
|
||||
icon: l.iconUrl,
|
||||
},
|
||||
];
|
||||
} else {
|
||||
apps[category] = [
|
||||
{
|
||||
label: l.label,
|
||||
value: l.type,
|
||||
icon: l.iconUrl,
|
||||
},
|
||||
];
|
||||
}
|
||||
});
|
||||
const locations = [];
|
||||
|
||||
// Translating labels and pushing into array
|
||||
for (const category in apps) {
|
||||
const tmp = { label: category, options: apps[category] };
|
||||
if (tmp.label === "in person") {
|
||||
tmp.options.map((l) => ({ ...l, label: t(l.value) }));
|
||||
} else {
|
||||
tmp.options.map((l) => ({
|
||||
...l,
|
||||
label: t(l.label.toLowerCase().split(" ").join("_")),
|
||||
}));
|
||||
}
|
||||
|
||||
tmp.label = t(tmp.label);
|
||||
|
||||
locations.push(tmp);
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* This should get all available apps to the user based on his saved
|
||||
* credentials, this should also get globally available apps.
|
||||
|
||||
@@ -8,7 +8,7 @@ import ethRouter from "@calcom/app-store/rainbow/trpc/router";
|
||||
import { deleteStripeCustomer } from "@calcom/app-store/stripepayment/lib/customer";
|
||||
import { getCustomerAndCheckoutSession } from "@calcom/app-store/stripepayment/lib/getCustomerAndCheckoutSession";
|
||||
import stripe, { closePayments } from "@calcom/app-store/stripepayment/lib/server";
|
||||
import getApps, { getLocationOptions } from "@calcom/app-store/utils";
|
||||
import getApps, { getLocationGroupedOptions } from "@calcom/app-store/utils";
|
||||
import { cancelScheduledJobs } from "@calcom/app-store/zapier/lib/nodeScheduler";
|
||||
import { getCalendarCredentials, getConnectedCalendars } from "@calcom/core/CalendarManager";
|
||||
import { DailyLocationType } from "@calcom/core/location";
|
||||
@@ -769,12 +769,11 @@ const loggedInViewerRouter = router({
|
||||
appId: true,
|
||||
},
|
||||
});
|
||||
|
||||
const integrations = getApps(credentials);
|
||||
|
||||
const t = await getTranslation(ctx.user.locale ?? "en", "common");
|
||||
|
||||
const locationOptions = getLocationOptions(integrations, t);
|
||||
const locationOptions = getLocationGroupedOptions(integrations, t);
|
||||
|
||||
return locationOptions;
|
||||
}),
|
||||
|
||||
@@ -206,6 +206,8 @@ const PlainForm = <T extends FieldValues>(props: FormProps<T>, ref: Ref<HTMLForm
|
||||
ref={ref}
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
form
|
||||
.handleSubmit(handleSubmit)(event)
|
||||
.catch((err) => {
|
||||
|
||||
Reference in new issue
Block a user