* Add zoho-app to the app-store * Update packages/app-store/zohocrm/api/_getAdd.ts Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> * 1. Remove redundant check for `defaultHandler` 2. Restore yarn.lock` * update images * update README with zoho integration * Fix dirname * Fix types * Fix lastname bug * Fix timezone issue * Fix eslint warning for unused args * Revert yarn.lock --------- Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com>
24 lines
993 B
TypeScript
24 lines
993 B
TypeScript
import logger from "@calcom/lib/logger";
|
|
import type { Calendar } from "@calcom/types/Calendar";
|
|
import type { CredentialPayload } from "@calcom/types/Credential";
|
|
|
|
import appStore from "..";
|
|
|
|
const log = logger.getChildLogger({ prefix: ["CalendarManager"] });
|
|
|
|
export const getCalendar = (credential: CredentialPayload | null): Calendar | null => {
|
|
if (!credential || !credential.key) return null;
|
|
let { type: calendarType } = credential;
|
|
if (calendarType?.endsWith("_other_calendar")) {
|
|
calendarType = calendarType.split("_other_calendar")[0];
|
|
}
|
|
const calendarApp = appStore[calendarType.split("_").join("") as keyof typeof appStore];
|
|
if (!(calendarApp && "lib" in calendarApp && "CalendarService" in calendarApp.lib)) {
|
|
log.warn(`calendar of type ${calendarType} is not implemented`);
|
|
return null;
|
|
}
|
|
log.info("calendarApp", calendarApp.lib.CalendarService);
|
|
const CalendarService = calendarApp.lib.CalendarService;
|
|
return new CalendarService(credential);
|
|
};
|