Adds getLocationOptions
parent
35ffa78e92
commit
10dde1bbf3
|
@ -2,6 +2,7 @@ import { Prisma } from "@prisma/client";
|
|||
import _ from "lodash";
|
||||
|
||||
import appStore from "@calcom/app-store";
|
||||
import { LocationType } from "@calcom/lib/location";
|
||||
import type { App } from "@calcom/types/App";
|
||||
|
||||
import { APPS as CalendarApps } from "@lib/apps/calendar/config";
|
||||
|
@ -23,6 +24,28 @@ type CredentialData = Prisma.CredentialGetPayload<typeof credentialData>;
|
|||
|
||||
export const ALL_APPS = Object.values(ALL_APPS_MAP);
|
||||
|
||||
type OptionTypeBase = {
|
||||
label: string;
|
||||
value: LocationType;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
export function getLocationOptions() {
|
||||
const defaultLocations: OptionTypeBase[] = [
|
||||
{ value: LocationType.InPerson, label: "in_person_meeting" },
|
||||
{ value: LocationType.Jitsi, label: "Jitsi Meet" },
|
||||
{ value: LocationType.Phone, label: "phone_call" },
|
||||
];
|
||||
|
||||
Object.values(appStore).forEach((app) => {
|
||||
if ("locationOption" in app.lib) {
|
||||
defaultLocations.push(app.lib.locationOption);
|
||||
}
|
||||
});
|
||||
|
||||
return defaultLocations;
|
||||
}
|
||||
|
||||
function getApps(userCredentials: CredentialData[]) {
|
||||
const apps = ALL_APPS.map((app) => {
|
||||
const credentials = userCredentials
|
||||
|
|
|
@ -28,7 +28,7 @@ import { JSONObject } from "superjson/dist/types";
|
|||
|
||||
import { StripeData } from "@ee/lib/stripe/server";
|
||||
|
||||
import getApps, { hasIntegration } from "@lib/apps/utils/AppUtils";
|
||||
import getApps, { getLocationOptions, hasIntegration } from "@lib/apps/utils/AppUtils";
|
||||
import { asStringOrThrow, asStringOrUndefined } from "@lib/asStringOrNull";
|
||||
import { getSession } from "@lib/auth";
|
||||
import { HttpError } from "@lib/core/http/error";
|
||||
|
@ -108,19 +108,17 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
|
|||
prefix: t("indefinitely_into_future"),
|
||||
},
|
||||
];
|
||||
const { eventType, locationOptions, availability, team, teamMembers, hasPaymentIntegration, currency } =
|
||||
props;
|
||||
|
||||
/** Appending default locations */
|
||||
|
||||
const defaultLocations = [
|
||||
{ value: LocationType.InPerson, label: t("in_person_meeting") },
|
||||
{ value: LocationType.Jitsi, label: "Jitsi Meet" },
|
||||
{ value: LocationType.Phone, label: t("phone_call") },
|
||||
];
|
||||
|
||||
addDefaultLocationOptions(defaultLocations, locationOptions);
|
||||
const {
|
||||
eventType,
|
||||
locationOptions: untraslatedLocationOptions,
|
||||
availability,
|
||||
team,
|
||||
teamMembers,
|
||||
hasPaymentIntegration,
|
||||
currency,
|
||||
} = props;
|
||||
|
||||
const locationOptions = untraslatedLocationOptions.map((l) => ({ ...l, label: t(l.label) }));
|
||||
const router = useRouter();
|
||||
|
||||
const updateMutation = trpc.useMutation("viewer.eventTypes.update", {
|
||||
|
@ -1665,17 +1663,8 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||
}
|
||||
|
||||
const integrations = getApps(credentials);
|
||||
const locationOptions = getLocationOptions();
|
||||
|
||||
/** TODO: Find a way to get locations dynamically */
|
||||
const locationOptions: OptionTypeBase[] = [];
|
||||
|
||||
if (hasIntegration(integrations, "zoom_video")) {
|
||||
locationOptions.push({
|
||||
value: LocationType.Zoom,
|
||||
label: "Zoom Video",
|
||||
disabled: true,
|
||||
});
|
||||
}
|
||||
const hasPaymentIntegration = hasIntegration(integrations, "stripe_payment");
|
||||
if (hasIntegration(integrations, "google_calendar")) {
|
||||
locationOptions.push({
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
export { default as locationOption } from "./locationOption";
|
||||
export { default as VideoApiAdapter } from "./VideoApiAdapter";
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import { LocationType } from "@calcom/lib/location";
|
||||
|
||||
const locationOption = {
|
||||
value: LocationType.Zoom,
|
||||
label: "Zoom Video",
|
||||
disabled: false,
|
||||
};
|
||||
|
||||
export default locationOption;
|
|
@ -1,3 +1,4 @@
|
|||
/** TODO: These should all come from each individual App Store package, and merge them here. */
|
||||
export enum LocationType {
|
||||
InPerson = "inPerson",
|
||||
Phone = "phone",
|
||||
|
|
Loading…
Reference in New Issue