feat: add option to ignore guests in HubSpot integration and update related schemas (#25727)
Co-authored-by: Amit Sharma <74371312+Amit91848@users.noreply.github.com>
This commit is contained in:
@@ -4109,5 +4109,6 @@
|
||||
"actor": "Actor",
|
||||
"timestamp": "Timestamp",
|
||||
"json": "JSON",
|
||||
"hubspot_ignore_guests": "Do not create new records for guests added to the booking",
|
||||
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
|
||||
}
|
||||
|
||||
@@ -1,15 +1,28 @@
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
import { useAppContextWithSchema } from "@calcom/app-store/EventTypeAppContext";
|
||||
import AppCard from "@calcom/app-store/_components/AppCard";
|
||||
import useIsAppEnabled from "@calcom/app-store/_utils/useIsAppEnabled";
|
||||
import type { EventTypeAppCardComponent } from "@calcom/app-store/types";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Section } from "@calcom/ui/components/section";
|
||||
import { Switch } from "@calcom/ui/components/form";
|
||||
|
||||
const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({ app, eventType, onAppInstallSuccess }) {
|
||||
import type { appDataSchema } from "../zod";
|
||||
|
||||
const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
|
||||
app,
|
||||
eventType,
|
||||
onAppInstallSuccess,
|
||||
}) {
|
||||
const pathname = usePathname();
|
||||
|
||||
const { t } = useLocale();
|
||||
const { getAppData, setAppData } = useAppContextWithSchema<typeof appDataSchema>();
|
||||
const { enabled, updateEnabled } = useIsAppEnabled(app);
|
||||
|
||||
const ignoreGuests = getAppData("ignoreGuests") ?? false;
|
||||
|
||||
return (
|
||||
<AppCard
|
||||
onAppInstallSuccess={onAppInstallSuccess}
|
||||
@@ -20,9 +33,26 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
|
||||
updateEnabled(e);
|
||||
}}
|
||||
switchChecked={enabled}
|
||||
hideAppCardOptions
|
||||
/>
|
||||
hideSettingsIcon>
|
||||
<Section.Content>
|
||||
<Section.SubSection>
|
||||
<Section.SubSectionHeader
|
||||
icon="user-plus"
|
||||
title={t("hubspot_ignore_guests")}
|
||||
labelFor="ignore-guests">
|
||||
<Switch
|
||||
size="sm"
|
||||
labelOnLeading
|
||||
checked={ignoreGuests}
|
||||
onCheckedChange={(checked) => {
|
||||
setAppData("ignoreGuests", checked);
|
||||
}}
|
||||
/>
|
||||
</Section.SubSectionHeader>
|
||||
</Section.SubSection>
|
||||
</Section.Content>
|
||||
</AppCard>
|
||||
);
|
||||
};
|
||||
|
||||
export default EventTypeAppCard;
|
||||
export default EventTypeAppCard;
|
||||
@@ -6,6 +6,7 @@ import type {
|
||||
SimplePublicObject,
|
||||
SimplePublicObjectInput,
|
||||
} from "@hubspot/api-client/lib/codegen/crm/objects/meetings";
|
||||
import type { z } from "zod";
|
||||
|
||||
import { getLocation } from "@calcom/lib/CalEventParser";
|
||||
import getLabelValueMapFromResponses from "@calcom/lib/bookings/getLabelValueMapFromResponses";
|
||||
@@ -20,6 +21,7 @@ import type { CRM, ContactCreateInput, Contact, CrmEvent } from "@calcom/types/C
|
||||
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
|
||||
import refreshOAuthTokens from "../../_utils/oauth/refreshOAuthTokens";
|
||||
import type { HubspotToken } from "../api/callback";
|
||||
import type { appDataSchema } from "../zod";
|
||||
|
||||
export default class HubspotCalendarService implements CRM {
|
||||
private url = "";
|
||||
@@ -29,8 +31,9 @@ export default class HubspotCalendarService implements CRM {
|
||||
private client_id = "";
|
||||
private client_secret = "";
|
||||
private hubspotClient: hubspot.Client;
|
||||
private appOptions: z.infer<typeof appDataSchema>;
|
||||
|
||||
constructor(credential: CredentialPayload) {
|
||||
constructor(credential: CredentialPayload, appOptions?: z.infer<typeof appDataSchema>) {
|
||||
this.hubspotClient = new hubspot.Client();
|
||||
|
||||
this.integrationName = "hubspot_other_calendar";
|
||||
@@ -38,6 +41,8 @@ export default class HubspotCalendarService implements CRM {
|
||||
this.auth = this.hubspotAuth(credential).then((r) => r);
|
||||
|
||||
this.log = logger.getSubLogger({ prefix: [`[[lib] ${this.integrationName}`] });
|
||||
|
||||
this.appOptions = appOptions || {};
|
||||
}
|
||||
|
||||
private getHubspotMeetingBody = (event: CalendarEvent): string => {
|
||||
@@ -300,7 +305,7 @@ export default class HubspotCalendarService implements CRM {
|
||||
}
|
||||
|
||||
getAppOptions() {
|
||||
console.log("No options implemented");
|
||||
return this.appOptions;
|
||||
}
|
||||
|
||||
async handleAttendeeNoShow() {
|
||||
|
||||
@@ -2,7 +2,9 @@ import { z } from "zod";
|
||||
|
||||
import { eventTypeAppCardZod } from "../eventTypeAppCardZod";
|
||||
|
||||
export const appDataSchema = eventTypeAppCardZod;
|
||||
export const appDataSchema = eventTypeAppCardZod.extend({
|
||||
ignoreGuests: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const appKeysSchema = z.object({
|
||||
client_id: z.string().min(1),
|
||||
|
||||
Reference in New Issue
Block a user