diff --git a/apps/web/components/AdditionalCalendarSelector.tsx b/apps/web/components/AdditionalCalendarSelector.tsx index 43d2fe338c..ce9a2597a7 100644 --- a/apps/web/components/AdditionalCalendarSelector.tsx +++ b/apps/web/components/AdditionalCalendarSelector.tsx @@ -45,7 +45,7 @@ const AdditionalCalendarSelector = ({ isLoading }: AdditionalCalendarSelectorPro const options = data.items.map((item) => ({ label: item.name, slug: item.slug, - image: item.imageSrc, + image: item.logo, type: item.type, })); return ( diff --git a/apps/web/components/Embed.tsx b/apps/web/components/Embed.tsx index 264c374bee..5b1b1f3de6 100644 --- a/apps/web/components/Embed.tsx +++ b/apps/web/components/Embed.tsx @@ -6,9 +6,6 @@ import { components, ControlProps } from "react-select"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; -import { EventType } from "@calcom/prisma/client"; -import { trpc } from "@calcom/trpc/react"; -import { SVGComponent } from "@calcom/types/SVGComponent"; import { Button, Switch } from "@calcom/ui"; import { Dialog, DialogClose, DialogContent } from "@calcom/ui/Dialog"; import { Icon } from "@calcom/ui/Icon"; @@ -41,7 +38,7 @@ type PreviewState = { brandColor: string; }; }; -const queryParamsForDialog = ["embedType", "tabName", "eventTypeId"]; +const queryParamsForDialog = ["embedType", "tabName", "embedUrl"]; const getDimension = (dimension: string) => { if (dimension.match(/^\d+$/)) { @@ -626,11 +623,11 @@ const ChooseEmbedTypesDialogContent = () => { }; const EmbedTypeCodeAndPreviewDialogContent = ({ - eventTypeId, embedType, + embedUrl, }: { - eventTypeId: EventType["id"]; embedType: EmbedType; + embedUrl: string; }) => { const { t } = useLocale(); const router = useRouter(); @@ -645,13 +642,6 @@ const EmbedTypeCodeAndPreviewDialogContent = ({ const refOfEmbedCodesRefs = useRef(embedCodeRefs); const embed = embeds.find((embed) => embed.type === embedType); - const { data: eventType, isLoading } = trpc.useQuery([ - "viewer.eventTypes.get", - { - id: +eventTypeId, - }, - ]); - const [isEmbedCustomizationOpen, setIsEmbedCustomizationOpen] = useState(true); const [isBookingCustomizationOpen, setIsBookingCustomizationOpen] = useState(true); const [previewState, setPreviewState] = useState({ @@ -693,18 +683,12 @@ const EmbedTypeCodeAndPreviewDialogContent = ({ }); } - if (isLoading) { - return null; - } - - if (!embed || !eventType) { + if (!embed || !embedUrl) { close(); return null; } - const calLink = `${eventType.team ? `team/${eventType.team.slug}` : eventType.users[0].username}/${ - eventType.slug - }`; + const calLink = decodeURIComponent(embedUrl); const addToPalette = (update: typeof previewState["palette"]) => { setPreviewState((previewState) => { @@ -1118,41 +1102,46 @@ const EmbedTypeCodeAndPreviewDialogContent = ({ export const EmbedDialog = () => { const router = useRouter(); - const eventTypeId: EventType["id"] = +(router.query.eventTypeId as string); + const embedUrl: string = router.query.embedUrl as string; return ( - + { + if (!open) window.resetEmbedStatus(); + }}> {!router.query.embedType ? ( ) : ( )} ); }; - -export const EmbedButton = ({ - eventTypeId, - StartIcon, - children, - className = "", - ...props -}: { - eventTypeId: EventType["id"]; - StartIcon?: SVGComponent; +type EmbedButtonProps = { + embedUrl: string; children?: React.ReactNode; className: string; -}) => { - const { t } = useLocale(); + as?: T; +}; + +export const EmbedButton = ({ + embedUrl, + children, + className = "", + as, + ...props +}: EmbedButtonProps & React.ComponentPropsWithoutRef) => { const router = useRouter(); className = classNames(className, "hidden lg:flex"); const openEmbedModal = () => { const query = { ...router.query, dialog: "embed", - eventTypeId, + embedUrl, }; router.push( { @@ -1163,19 +1152,16 @@ export const EmbedButton = ({ { shallow: true } ); }; + const Component = as ?? Button; return ( - + ); }; diff --git a/apps/web/components/integrations/CalendarListContainer.tsx b/apps/web/components/integrations/CalendarListContainer.tsx index 2dd99a1310..a6b7f42cc4 100644 --- a/apps/web/components/integrations/CalendarListContainer.tsx +++ b/apps/web/components/integrations/CalendarListContainer.tsx @@ -106,10 +106,11 @@ function CalendarList(props: Props) { {data.items.map((item) => (
{ // eslint-disable-next-line @next/next/no-img-element - props.imageSrc && {props.title} + props.logo && {title} }
- {props.title} + {props.name || title} {props.description}
diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 9c85b73600..330cdf0700 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -109,6 +109,10 @@ const nextConfig = { source: "/forms/:formId", destination: "/apps/routing_forms/routing-link/:formId", }, + { + source: "/router", + destination: "/apps/routing_forms/router", + }, /* TODO: have these files being served from another deployment or CDN { source: "/embed/embed.js", destination: process.env.NEXT_PUBLIC_EMBED_LIB_URL?, diff --git a/apps/web/pages/_document.tsx b/apps/web/pages/_document.tsx index 453f4d7d30..8d244f7980 100644 --- a/apps/web/pages/_document.tsx +++ b/apps/web/pages/_document.tsx @@ -7,6 +7,9 @@ function toRunBeforeReactOnClient() { window.isEmbed = () => { return window.sessionStorage.getItem("calEmbedMode") === "true"; }; + window.resetEmbedStatus = () => { + window.sessionStorage.removeItem("calEmbedMode"); + }; window.getEmbedTheme = () => { const url = new URL(document.URL); diff --git a/apps/web/pages/apps/[slug]/[...pages].tsx b/apps/web/pages/apps/[slug]/[...pages].tsx index 0b4020d77e..a3ad82ec06 100644 --- a/apps/web/pages/apps/[slug]/[...pages].tsx +++ b/apps/web/pages/apps/[slug]/[...pages].tsx @@ -2,38 +2,47 @@ import { GetServerSidePropsContext } from "next"; import { NextRouter, useRouter } from "next/router"; import RoutingFormsRoutingConfig from "@calcom/app-store/ee/routing_forms/pages/app-routing.config"; +import TypeformRoutingConfig from "@calcom/app-store/typeform/pages/app-routing.config"; import prisma from "@calcom/prisma"; import { AppGetServerSideProps } from "@calcom/types/AppGetServerSideProps"; import { inferSSRProps } from "@calcom/types/inferSSRProps"; import { getSession } from "@lib/auth"; +type AppPage = { + getServerSideProps: AppGetServerSideProps; + // A component than can accept any properties + // eslint-disable-next-line @typescript-eslint/no-explicit-any + default: ((props: any) => JSX.Element) & { isThemeSupported?: boolean }; +}; + +type Found = { + notFound: false; + Component: AppPage["default"]; + getServerSideProps: AppPage["getServerSideProps"]; +}; + +type NotFound = { + notFound: true; +}; + // TODO: It is a candidate for apps.*.generated.* const AppsRouting = { routing_forms: RoutingFormsRoutingConfig, + typeform: TypeformRoutingConfig, }; function getRoute(appName: string, pages: string[]) { - const routingConfig = AppsRouting[appName as keyof typeof AppsRouting]; - type NotFound = { - notFound: true; - }; + const routingConfig = AppsRouting[appName as keyof typeof AppsRouting] as Record; if (!routingConfig) { return { notFound: true, } as NotFound; } - const mainPage = pages[0]; - const appPage = routingConfig[mainPage as keyof typeof routingConfig]; - type Found = { - notFound: false; - // A component than can accept any properties - // eslint-disable-next-line @typescript-eslint/no-explicit-any - Component: ((props: any) => JSX.Element) & { isThemeSupported?: boolean }; - getServerSideProps: AppGetServerSideProps; - }; + const appPage = routingConfig[mainPage] as AppPage; + if (!appPage) { return { notFound: true, diff --git a/apps/web/pages/apps/installed.tsx b/apps/web/pages/apps/installed.tsx index 13f0dc1449..3ffc1a66a9 100644 --- a/apps/web/pages/apps/installed.tsx +++ b/apps/web/pages/apps/installed.tsx @@ -118,10 +118,11 @@ const IntegrationsContainer = ({ variant, className = "" }: IntegrationsContaine {data.items.map((item) => ( ; -} - type OptionTypeBase = { label: string; value: LocationType; @@ -401,9 +391,8 @@ const EventTypePage = (props: inferSSRProps) => { endDate: new Date(eventType.periodEndDate || Date.now()), }); - const permalink = `${CAL_URL}/${team ? `team/${team.slug}` : eventType.users[0].username}/${ - eventType.slug - }`; + const embedLink = `${team ? `team/${team.slug}` : eventType.users[0].username}/${eventType.slug}`; + const permalink = `${CAL_URL}/${embedLink}`; const placeholderHashedLink = `${CAL_URL}/d/${hashedUrl}/${eventType.slug}`; @@ -1944,9 +1933,13 @@ const EventTypePage = (props: inferSSRProps) => { )} + embedUrl={encodeURIComponent(embedLink)}> + {/* This will only show if the user is not a member (ADMIN,OWNER) and if there is no current membership - meaning you are within an eventtype that does not belong to a team */} {(props.currentUserMembership?.role !== "MEMBER" || !props.currentUserMembership) && ( diff --git a/apps/web/pages/event-types/index.tsx b/apps/web/pages/event-types/index.tsx index 4a911bc2fa..bfc21d94f9 100644 --- a/apps/web/pages/event-types/index.tsx +++ b/apps/web/pages/event-types/index.tsx @@ -224,199 +224,238 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL return (
    - {types.map((type, index) => ( -
  • -
    + {types.map((type, index) => { + const embedLink = `${group.profile.slug}/${type.slug}`; + const calLink = `${CAL_URL}/${embedLink}`; + return ( +
  • - {types.length > 1 && !type.$disabled && ( - <> - +
    + {types.length > 1 && !type.$disabled && ( + <> + - - - )} - -
    -
    - {type.users?.length > 1 && ( - ({ - alt: organizer.name || "", - image: `${WEBAPP_URL}/${organizer.username}/avatar.png`, - title: organizer.name || "", - }))} - /> - )} -
    - - + + )} + +
    +
    + {type.users?.length > 1 && ( + ({ + alt: organizer.name || "", + image: `${WEBAPP_URL}/${organizer.username}/avatar.png`, + title: organizer.name || "", + }))} /> - + )} +
    + +
    - - -
    + + + + + + - - + + + + {t("embed")} + + + + {/* readonly is only set when we are on a team - if we are on a user event type null will be the value. */} + {(group.metadata?.readOnly === false || group.metadata.readOnly === null) && ( + + + + )} + + +
    +
    +
    +
    + + + + + + + + + {isNativeShare ? ( - - - {t("embed")} - - - - {/* readonly is only set when we are on a team - if we are on a user event type null will be the value. */} - {(group.metadata?.readOnly === false || group.metadata.readOnly === null) && ( - - - - )} - - -
    -
    -
    -
    - - - - - - - - - {isNativeShare ? ( + - ) : null} - - - - - - - - - - - - + + + + + + +
    -
- - ))} + + ); + })} { return ( url.pathname === basePage && url.searchParams.get("dialog") === "embed" && - url.searchParams.get("eventTypeId") === eventTypeId + url.searchParams.get("embedUrl") === embedUrl ); }, }); @@ -45,17 +45,17 @@ async function expectToBeNavigatingToEmbedTypesDialog( async function expectToBeNavigatingToEmbedCodeAndPreviewDialog( page: Page, - { eventTypeId, embedType, basePage }: { eventTypeId: string | null; embedType: string; basePage: string } + { embedUrl, embedType, basePage }: { embedUrl: string | null; embedType: string; basePage: string } ) { - if (!eventTypeId) { - throw new Error("Couldn't find eventTypeId"); + if (!embedUrl) { + throw new Error("Couldn't find embedUrl"); } await page.waitForNavigation({ url: (url) => { return ( url.pathname === basePage && url.searchParams.get("dialog") === "embed" && - url.searchParams.get("eventTypeId") === eventTypeId && + url.searchParams.get("embedUrl") === embedUrl && url.searchParams.get("embedType") === embedType && url.searchParams.get("tabName") === "embed-code" ); @@ -93,16 +93,16 @@ test.describe("Embed Code Generator Tests", () => { }); test("open Embed Dialog and choose Inline for First Event Type", async ({ page }) => { - const eventTypeId = await clickFirstEventTypeEmbedButton(page); + const embedUrl = await clickFirstEventTypeEmbedButton(page); await expectToBeNavigatingToEmbedTypesDialog(page, { - eventTypeId, + embedUrl, basePage: "/event-types", }); chooseEmbedType(page, "inline"); await expectToBeNavigatingToEmbedCodeAndPreviewDialog(page, { - eventTypeId, + embedUrl, embedType: "inline", basePage: "/event-types", }); @@ -115,17 +115,17 @@ test.describe("Embed Code Generator Tests", () => { }); test("open Embed Dialog and choose floating-popup for First Event Type", async ({ page }) => { - const eventTypeId = await clickFirstEventTypeEmbedButton(page); + const embedUrl = await clickFirstEventTypeEmbedButton(page); await expectToBeNavigatingToEmbedTypesDialog(page, { - eventTypeId, + embedUrl, basePage: "/event-types", }); chooseEmbedType(page, "floating-popup"); await expectToBeNavigatingToEmbedCodeAndPreviewDialog(page, { - eventTypeId, + embedUrl, embedType: "floating-popup", basePage: "/event-types", }); @@ -136,17 +136,17 @@ test.describe("Embed Code Generator Tests", () => { }); test("open Embed Dialog and choose element-click for First Event Type", async ({ page }) => { - const eventTypeId = await clickFirstEventTypeEmbedButton(page); + const embedUrl = await clickFirstEventTypeEmbedButton(page); await expectToBeNavigatingToEmbedTypesDialog(page, { - eventTypeId, + embedUrl, basePage: "/event-types", }); chooseEmbedType(page, "element-click"); await expectToBeNavigatingToEmbedCodeAndPreviewDialog(page, { - eventTypeId, + embedUrl, embedType: "element-click", basePage: "/event-types", }); @@ -165,17 +165,17 @@ test.describe("Embed Code Generator Tests", () => { }); test("open Embed Dialog for the Event Type", async ({ page }) => { - const eventTypeId = await clickEmbedButton(page); + const embedUrl = await clickEmbedButton(page); await expectToBeNavigatingToEmbedTypesDialog(page, { - eventTypeId, + embedUrl, basePage: `/event-types/${sixtyMinProEventId}`, }); chooseEmbedType(page, "inline"); await expectToBeNavigatingToEmbedCodeAndPreviewDialog(page, { - eventTypeId, + embedUrl, basePage: `/event-types/${sixtyMinProEventId}`, embedType: "inline", }); diff --git a/package.json b/package.json index 77226f7f64..e56b4b66e2 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "scripts": { "app-e2e-quick": "turbo run app-e2e-quick", "app-store:build": "yarn workspace @calcom/app-store-cli build", + "app-store:watch": "yarn workspace @calcom/app-store-cli watch", "app-store": "yarn workspace @calcom/app-store-cli cli", "build": "turbo run build --scope=\"@calcom/web\" --include-dependencies", "clean": "find . -name node_modules -o -name .next -o -name .turbo -o -name dist -type d -prune | xargs rm -rf", diff --git a/packages/app-store-cli/src/CliApp.tsx b/packages/app-store-cli/src/CliApp.tsx index 4504eb124c..7dfd393e7a 100644 --- a/packages/app-store-cli/src/CliApp.tsx +++ b/packages/app-store-cli/src/CliApp.tsx @@ -50,7 +50,6 @@ const BaseAppFork = { appDescription, appName, slug, - appTitle, publisherName, publisherEmail, }) { @@ -70,7 +69,6 @@ const BaseAppFork = { let config = { "/*": "Don't modify slug - If required, do it using cli edit command", name: appName, - title: appTitle, // Plan to remove it. DB already has it and name of dir is also the same. slug: slug, type: `${slug}_${category}`, @@ -91,6 +89,10 @@ const BaseAppFork = { ...config, }; fs.writeFileSync(`${appDirPath}/config.json`, JSON.stringify(config, null, 2)); + fs.writeFileSync( + `${appDirPath}/README.mdx`, + fs.readFileSync(`${appDirPath}/README.mdx`).toString().replace("_DESCRIPTION_", appDescription) + ); message = !editMode ? "Forked base app" : "Updated app"; yield message; }, @@ -103,10 +105,16 @@ const BaseAppFork = { const Seed = { seedConfigPath: absolutePath("../prisma/seed-app-store.config.json"), update: function ({ slug, category, noDbUpdate }) { - const seedConfig = JSON.parse(fs.readFileSync(this.seedConfigPath).toString()); + let configContent = "[]"; + try { + if (fs.statSync(this.seedConfigPath)) { + configContent = fs.readFileSync(this.seedConfigPath).toString(); + } + } catch (e) {} + const seedConfig = JSON.parse(configContent); + if (!seedConfig.find((app) => app.slug === slug)) { seedConfig.push({ - "/*": "This file is auto-generated and managed by `yarn app-store`. Don't edit manually but it is to be committed", dirName: slug, categories: [category], slug: slug, @@ -114,6 +122,10 @@ const Seed = { }); } + // Add the message as a property to first item so that it stays always at the top + seedConfig[0]["/*"] = + "This file is auto-generated and updated by `yarn app-store create/edit`. Don't edit it manually"; + fs.writeFileSync(this.seedConfigPath, JSON.stringify(seedConfig, null, 2)); if (!noDbUpdate) { execSync(`cd ${workspaceDir} && yarn db-seed`); @@ -139,8 +151,7 @@ const CreateApp = ({ noDbUpdate, slug = null, editMode = false }) => { const [appInputData, setAppInputData] = useState({}); const [inputIndex, setInputIndex] = useState(0); const fields = [ - { label: "App Name", name: "appName", type: "text" }, - { label: "App Title", name: "appTitle", type: "text" }, + { label: "App Title", name: "appName", type: "text" }, { label: "App Description", name: "appDescription", type: "text" }, { label: "Category of App", @@ -164,13 +175,12 @@ const CreateApp = ({ noDbUpdate, slug = null, editMode = false }) => { const fieldValue = appInputData[fieldName] || ""; const appName = appInputData["appName"]; const category = appInputData["appCategory"]; - const appTitle = appInputData["appTitle"]; const appDescription = appInputData["appDescription"]; const publisherName = appInputData["publisherName"]; const publisherEmail = appInputData["publisherEmail"]; - const [result, setResult] = useState("..."); + const [status, setStatus] = useState<"inProgress" | "done">("inProgress"); const allFieldsFilled = inputIndex === fields.length; - + const [progressUpdate, setProgressUpdate] = useState(""); useEffect(() => { // When all fields have been filled if (allFieldsFilled) { @@ -179,12 +189,11 @@ const CreateApp = ({ noDbUpdate, slug = null, editMode = false }) => { appDescription, appName, slug, - appTitle, publisherName, publisherEmail, }); for (const item of it) { - setResult(item); + setProgressUpdate(item); } Seed.update({ slug, category, noDbUpdate }); @@ -193,11 +202,7 @@ const CreateApp = ({ noDbUpdate, slug = null, editMode = false }) => { // FIXME: Even after CLI showing this message, it is stuck doing work before exiting // So we ask the user to wait for some time - setResult( - `App has been given slug: ${slug}. Just wait for a few seconds for the process to complete and start editing ${getAppDirPath( - slug - )} to work on your app.` - ); + setStatus("done"); } }); @@ -211,18 +216,61 @@ const CreateApp = ({ noDbUpdate, slug = null, editMode = false }) => { if (allFieldsFilled) { return ( - <> + {editMode ? `Editing app with slug ${slug}` : `Creating app with name '${appName}' of type '${category}'`} - {result} - - Please note that you should use cli only to rename an app directory as it needs to be updated in DB - as well + {progressUpdate} + {status === "done" ? ( + + + Just wait for few seconds to process to exit and you are good to go. Your App code exists at $ + {getAppDirPath(slug)} + + + App Summary: + + + + Slug: + {slug} + + + App URL: + {`http://localhost:3000/apps/${slug}`} + + + Name: + {appName} + + + Description: + {appDescription} + + + Category: + {category} + + + Publisher Name: + {publisherName} + + + Publisher Email: + {publisherEmail} + + + + ) : ( + Please wait... + )} + + Note: You should not rename app directory manually. Use cli only to do that as it needs to be + updated in DB as well - + ); } @@ -235,44 +283,51 @@ const CreateApp = ({ noDbUpdate, slug = null, editMode = false }) => { ); } return ( - - {`${fieldLabel}:`} - {field.type == "text" ? ( - { - if (!value) { - return; - } - setInputIndex((index) => { - return index + 1; - }); - }} - onChange={(value) => { - setAppInputData((appInputData) => { - return { - ...appInputData, - [fieldName]: value, - }; - }); - }} - /> - ) : ( - - items={field.options} - onSelect={(item) => { - setAppInputData((appInputData) => { - return { - ...appInputData, - [fieldName]: item.value, - }; - }); - setInputIndex((index) => { - return index + 1; - }); - }} - /> - )} + + + {`${fieldLabel}:`} + {field.type == "text" ? ( + { + if (!value) { + return; + } + setInputIndex((index) => { + return index + 1; + }); + }} + onChange={(value) => { + setAppInputData((appInputData) => { + return { + ...appInputData, + [fieldName]: value, + }; + }); + }} + /> + ) : ( + + items={field.options} + onSelect={(item) => { + setAppInputData((appInputData) => { + return { + ...appInputData, + [fieldName]: item.value, + }; + }); + setInputIndex((index) => { + return index + 1; + }); + }} + /> + )} + + + + {field.explainer} + + ); }; diff --git a/packages/app-store/_baseApp/README.mdx b/packages/app-store/_baseApp/README.mdx index c10da2e9e0..892444a43c 100644 --- a/packages/app-store/_baseApp/README.mdx +++ b/packages/app-store/_baseApp/README.mdx @@ -1 +1,13 @@ -Edit README.mdx file to update it. \ No newline at end of file +--- +description: _DESCRIPTION_ +--- +{/* Feel free to edit description or add other frontmatter. Frontmatter would be available in the components here as variables by same name */} + +
+{description} +
+
+
+
Edit README.mdx file to update the content.
+
Edit config.json to update logo
+
diff --git a/packages/app-store/_baseApp/api/_getAdd.ts b/packages/app-store/_baseApp/api/_getAdd.ts deleted file mode 100644 index 4a6e1b4ba8..0000000000 --- a/packages/app-store/_baseApp/api/_getAdd.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from "next"; - -import { defaultResponder } from "@calcom/lib/server"; - -import checkSession from "../../_utils/auth"; -import { checkInstalled, createDefaultInstallation } from "../../_utils/installation"; -import appConfig from "../config.json"; - -export async function getHandler(req: NextApiRequest, res: NextApiResponse) { - const session = checkSession(req); - const slug = appConfig.slug; - const appType = appConfig.type; - - await checkInstalled(slug, session.user.id); - await createDefaultInstallation({ - appType, - userId: session.user.id, - slug, - key: {}, - }); - - return { url: "/apps/installed" }; -} - -export default defaultResponder(getHandler); diff --git a/packages/app-store/_baseApp/api/add.ts b/packages/app-store/_baseApp/api/add.ts index 912126e232..a3fb710df3 100644 --- a/packages/app-store/_baseApp/api/add.ts +++ b/packages/app-store/_baseApp/api/add.ts @@ -1,5 +1,17 @@ -import { defaultHandler } from "@calcom/lib/server"; +import { AppDeclarativeHandler } from "@calcom/types/AppHandler"; -export default defaultHandler({ - GET: import("./_getAdd"), -}); +import { createDefaultInstallation } from "../../_utils/installation"; +import appConfig from "../config.json"; + +const handler: AppDeclarativeHandler = { + // Instead of passing appType and slug from here, api/integrations/[..args] should be able to derive and pass these directly to createCredential + appType: appConfig.type, + slug: appConfig.slug, + supportsMultipleInstalls: false, + handlerType: "add", + redirectUrl: "/apps/installed", + createCredential: ({ appType, user, slug }) => + createDefaultInstallation({ appType, userId: user.id, slug, key: {} }), +}; + +export default handler; diff --git a/packages/app-store/_baseApp/components/.gitkeep b/packages/app-store/_baseApp/components/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/app-store/_baseApp/components/InstallAppButton.tsx b/packages/app-store/_baseApp/components/InstallAppButton.tsx deleted file mode 100644 index e5c3fd105c..0000000000 --- a/packages/app-store/_baseApp/components/InstallAppButton.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import type { InstallAppButtonProps } from "@calcom/app-store/types"; - -import useAddAppMutation from "../../_utils/useAddAppMutation"; -import appConfig from "../config.json"; - -export default function InstallAppButton(props: InstallAppButtonProps) { - const mutation = useAddAppMutation(appConfig.type); - - return ( - <> - {props.render({ - onClick() { - mutation.mutate(""); - }, - loading: mutation.isLoading, - })} - - ); -} diff --git a/packages/app-store/_baseApp/components/icon.tsx b/packages/app-store/_baseApp/components/icon.tsx deleted file mode 100644 index b4c2401ca1..0000000000 --- a/packages/app-store/_baseApp/components/icon.tsx +++ /dev/null @@ -1,15 +0,0 @@ -export default function Icon() { - return ( - - - - ); -} diff --git a/packages/app-store/_baseApp/components/index.ts b/packages/app-store/_baseApp/components/index.ts deleted file mode 100644 index e191e97eec..0000000000 --- a/packages/app-store/_baseApp/components/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as InstallAppButton } from "./InstallAppButton"; -export { default as Icon } from "./icon"; diff --git a/packages/app-store/_baseApp/config.json b/packages/app-store/_baseApp/config.json index 0967ef424b..b2a5255bf3 100644 --- a/packages/app-store/_baseApp/config.json +++ b/packages/app-store/_baseApp/config.json @@ -1 +1,3 @@ -{} +{ + "/*": "This file would be automatically updated by cli according to the inputs" +} \ No newline at end of file diff --git a/packages/app-store/_baseApp/index.ts b/packages/app-store/_baseApp/index.ts index a698d1f5c5..5d372ceda3 100644 --- a/packages/app-store/_baseApp/index.ts +++ b/packages/app-store/_baseApp/index.ts @@ -1,3 +1,2 @@ export * as api from "./api"; -export * as components from "./components"; export { metadata } from "./_metadata"; diff --git a/packages/app-store/apps.browser.generated.tsx b/packages/app-store/apps.browser.generated.tsx index 9791ae2d9d..de5c7960ac 100644 --- a/packages/app-store/apps.browser.generated.tsx +++ b/packages/app-store/apps.browser.generated.tsx @@ -26,6 +26,7 @@ import { metadata as riverside_meta } from "./riverside/_metadata"; import { metadata as slackmessaging_meta } from "./slackmessaging/_metadata"; import { metadata as stripepayment_meta } from "./stripepayment/_metadata"; import { metadata as tandemvideo_meta } from "./tandemvideo/_metadata"; +import { metadata as typeform_meta } from "./typeform/_metadata"; import { metadata as vital_meta } from "./vital/_metadata"; import { metadata as whereby_meta } from "./whereby/_metadata"; import { metadata as wipemycalother_meta } from "./wipemycalother/_metadata"; @@ -55,6 +56,7 @@ export const appStoreMetadata = { slackmessaging: slackmessaging_meta, stripepayment: stripepayment_meta, tandemvideo: tandemvideo_meta, + typeform: typeform_meta, vital: vital_meta, whereby: whereby_meta, wipemycalother: wipemycalother_meta, diff --git a/packages/app-store/apps.server.generated.ts b/packages/app-store/apps.server.generated.ts index ca5561e575..9a4f6abe62 100644 --- a/packages/app-store/apps.server.generated.ts +++ b/packages/app-store/apps.server.generated.ts @@ -23,6 +23,7 @@ export const apiHandlers = { slackmessaging: import("./slackmessaging/api"), stripepayment: import("./stripepayment/api"), tandemvideo: import("./tandemvideo/api"), + typeform: import("./typeform/api"), vital: import("./vital/api"), whereby: import("./whereby/api"), wipemycalother: import("./wipemycalother/api"), diff --git a/packages/app-store/ee/routing_forms/api/responses/[formId].ts b/packages/app-store/ee/routing_forms/api/responses/[formId].ts index af73e86941..1a37022d2f 100644 --- a/packages/app-store/ee/routing_forms/api/responses/[formId].ts +++ b/packages/app-store/ee/routing_forms/api/responses/[formId].ts @@ -2,7 +2,7 @@ import type { NextApiRequest, NextApiResponse } from "next"; import prisma from "@calcom/prisma"; -import { Response } from "../../pages/routing-link/[...appPages]"; +import { Response } from "../../types/types"; function escapeCsvText(str: string) { return str.replace(/,/, "%2C"); diff --git a/packages/app-store/ee/routing_forms/components/RoutingNavBar.tsx b/packages/app-store/ee/routing_forms/components/RoutingNavBar.tsx index 7eb792ecd4..8b32c94ea3 100644 --- a/packages/app-store/ee/routing_forms/components/RoutingNavBar.tsx +++ b/packages/app-store/ee/routing_forms/components/RoutingNavBar.tsx @@ -1,6 +1,6 @@ import NavTabs from "@components/NavTabs"; -import { getSerializableForm } from "../utils"; +import { getSerializableForm } from "../lib/getSerializableForm"; export default function RoutingNavBar({ form, diff --git a/packages/app-store/ee/routing_forms/components/RoutingShell.tsx b/packages/app-store/ee/routing_forms/components/RoutingShell.tsx index 30e21604bb..7de5bfd4df 100644 --- a/packages/app-store/ee/routing_forms/components/RoutingShell.tsx +++ b/packages/app-store/ee/routing_forms/components/RoutingShell.tsx @@ -3,7 +3,7 @@ import { ReactNode } from "react"; import Shell from "@calcom/ui/Shell"; import RoutingNavBar from "../components/RoutingNavBar"; -import { getSerializableForm } from "../utils"; +import { getSerializableForm } from "../lib/getSerializableForm"; const RoutingShell: React.FC<{ form: ReturnType; diff --git a/packages/app-store/ee/routing_forms/components/SideBar.tsx b/packages/app-store/ee/routing_forms/components/SideBar.tsx index 0ebbd44b23..2868971e90 100644 --- a/packages/app-store/ee/routing_forms/components/SideBar.tsx +++ b/packages/app-store/ee/routing_forms/components/SideBar.tsx @@ -1,6 +1,6 @@ -import { ExternalLinkIcon, LinkIcon, DownloadIcon, TrashIcon } from "@heroicons/react/solid"; import { useRouter } from "next/router"; +import { CopyRedirectUrlButton } from "@calcom/app-store/typeform/components"; import { CAL_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; @@ -8,8 +8,11 @@ import { trpc } from "@calcom/trpc/react"; import { Switch } from "@calcom/ui"; import ConfirmationDialogContent from "@calcom/ui/ConfirmationDialogContent"; import { DialogTrigger, Dialog } from "@calcom/ui/Dialog"; +import { Icon } from "@calcom/ui/Icon"; -import { getSerializableForm } from "../utils"; +import { EmbedButton, EmbedDialog } from "@components/Embed"; + +import { getSerializableForm } from "../lib/getSerializableForm"; export default function SideBar({ form, @@ -19,6 +22,7 @@ export default function SideBar({ appUrl: string; }) { const { t } = useLocale(); + const utils = trpc.useContext(); const router = useRouter(); const mutation = trpc.useMutation("viewer.app_routing_forms.form", { @@ -42,11 +46,12 @@ export default function SideBar({ }, }); - const formLink = `${CAL_URL}/forms/${form.id}`; + const embedLink = `forms/${form.id}`; + const formLink = `${CAL_URL}/${embedLink}`; return (
-
+
{ @@ -61,9 +66,10 @@ export default function SideBar({ target="_blank" rel="noreferrer" className="text-md inline-flex items-center rounded-sm px-2 py-1 text-sm font-medium text-neutral-700 hover:bg-gray-200 hover:text-gray-900"> -
); diff --git a/packages/app-store/ee/routing_forms/components/react-awesome-query-builder/widgets.tsx b/packages/app-store/ee/routing_forms/components/react-awesome-query-builder/widgets.tsx index a149df73b0..b15454314a 100644 --- a/packages/app-store/ee/routing_forms/components/react-awesome-query-builder/widgets.tsx +++ b/packages/app-store/ee/routing_forms/components/react-awesome-query-builder/widgets.tsx @@ -83,8 +83,9 @@ const MultiSelectWidget = ({ setValue, value, ...remainingProps -}: SelectWidgetProps & { +}: Omit & { listValues: { title: string; value: string }[]; + value?: string[]; }) => { //TODO: Use Select here. //TODO: Let's set listValue itself as label and value instead of using title. @@ -98,7 +99,7 @@ const MultiSelectWidget = ({ }; }); - const defaultValue = selectItems.filter((item) => value?.value?.includes(item.value)); + const defaultValue = selectItems.filter((item) => value?.includes(item.value)); return ( setUserChangedIdentifier(e.target.value)} className="block w-full rounded-sm border-gray-300 text-sm" diff --git a/packages/app-store/ee/routing_forms/pages/forms/[...appPages].tsx b/packages/app-store/ee/routing_forms/pages/forms/[...appPages].tsx index 9d58ebfb18..fe722aee1c 100644 --- a/packages/app-store/ee/routing_forms/pages/forms/[...appPages].tsx +++ b/packages/app-store/ee/routing_forms/pages/forms/[...appPages].tsx @@ -1,17 +1,10 @@ // TODO: i18n -import { - TrashIcon, - DotsHorizontalIcon, - DuplicateIcon, - PencilIcon, - PlusIcon, - LinkIcon, - ExternalLinkIcon, - CollectionIcon, -} from "@heroicons/react/solid"; import Link from "next/link"; import { useRouter } from "next/router"; +import { useState } from "react"; +import { useForm } from "react-hook-form"; import { v4 as uuidv4 } from "uuid"; +import { z } from "zod"; import classNames from "@calcom/lib/classNames"; import { CAL_URL } from "@calcom/lib/constants"; @@ -20,39 +13,40 @@ import showToast from "@calcom/lib/notification"; import { trpc } from "@calcom/trpc/react"; import { AppGetServerSidePropsContext, AppPrisma, AppUser } from "@calcom/types/AppGetServerSideProps"; import { Button, EmptyScreen, Tooltip } from "@calcom/ui"; +import ConfirmationDialogContent from "@calcom/ui/ConfirmationDialogContent"; +import { Dialog, DialogClose, DialogContent } from "@calcom/ui/Dialog"; import Dropdown, { DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@calcom/ui/Dropdown"; +import { CollectionIcon, Icon } from "@calcom/ui/Icon"; import Shell from "@calcom/ui/Shell"; +import { Form, TextField } from "@calcom/ui/form/fields"; import { inferSSRProps } from "@lib/types/inferSSRProps"; -import { getSerializableForm } from "../../utils"; +import { EmbedButton, EmbedDialog } from "@components/Embed"; -export default function RoutingForms({ - forms, - appUrl, -}: inferSSRProps & { appUrl: string }) { +import { getSerializableForm } from "../../lib/getSerializableForm"; + +const newFormModalQuerySchema = z.object({ + action: z.string(), + target: z.string().optional(), +}); + +function NewFormDialog({ appUrl }: { appUrl: string }) { + const { t } = useLocale(); + const utils = trpc.useContext(); const router = useRouter(); - const deleteMutation = trpc.useMutation("viewer.app_routing_forms.deleteForm", { - onSuccess: () => { - showToast("Form deleted", "success"); - router.replace(router.asPath); - }, - onSettled: () => { - utils.invalidateQueries(["viewer.app_routing_forms.forms"]); - }, - onError: () => { - showToast("Something went wrong", "error"); - }, - }); - const utils = trpc.useContext(); - const { t } = useLocale(); + const hookForm = useForm<{ + name: string; + description: string; + }>(); + const { action, target } = router.query as z.infer; const mutation = trpc.useMutation("viewer.app_routing_forms.form", { onSuccess: (_data, variables) => { utils.invalidateQueries("viewer.app_routing_forms.forms"); @@ -62,20 +56,105 @@ export default function RoutingForms({ showToast(`Something went wrong`, "error"); }, }); - const formId = uuidv4(); + const { register } = hookForm; + return ( + + +
+ +
+

Create your form to route a booker

+
+
+
{ + const formId = uuidv4(); + + mutation.mutate({ + id: formId, + ...values, + addFallback: true, + duplicateFrom: action === "duplicate" ? target : null, + }); + }}> +
+ +
+

Description

+
+