feat: check if alby app is setup, if not link to setup page

feat/alby
Roland Bewick 2023-09-22 22:03:46 +07:00
parent 4cbbe3aaad
commit 2bf6b44c06
3 changed files with 23 additions and 5 deletions

View File

@ -4,7 +4,8 @@ import Link from "next/link";
import { useAppContextWithSchema } from "@calcom/app-store/EventTypeAppContext";
import { classNames } from "@calcom/lib";
import type { RouterOutputs } from "@calcom/trpc/react";
import { Switch, Badge, Avatar } from "@calcom/ui";
import { Switch, Badge, Avatar, Button } from "@calcom/ui";
import { Settings } from "@calcom/ui/components/icon";
import type { CredentialOwner } from "../types";
import OmniInstallAppButton from "./OmniInstallAppButton";
@ -111,8 +112,23 @@ export default function AppCard({
</div>
<div ref={animationRef}>
{app?.isInstalled && switchChecked && <hr className="border-subtle" />}
{app?.isInstalled && switchChecked ? (
<div className="p-4 pt-5 text-sm [&_input]:mb-0 [&_input]:leading-4">{children}</div>
app.isSetup ? (
<div className="relative p-4 pt-5 text-sm [&_input]:mb-0 [&_input]:leading-4">
<Link href={`/apps/${app.slug}/setup`} className="absolute right-4 top-4">
<Settings className="text-default h-4 w-4" aria-hidden="true" />
</Link>
{children}
</div>
) : (
<div className="flex h-64 w-full flex-col items-center justify-center gap-4 ">
<p>This app has not been setup yet</p>
<Link href={`/apps/${app.slug}/setup`}>
<Button startIcon={Settings}>Setup</Button>
</Link>
</div>
)
) : null}
</div>
</div>

View File

@ -1,5 +1,3 @@
import { Price } from "bookings/components/event-meta/Price";
import { getPayIcon } from "bookings/components/event-meta/getPayIcon";
import classNames from "classnames";
import dynamic from "next/dynamic";
import Head from "next/head";
@ -9,6 +7,8 @@ import { useEffect, useState } from "react";
import { getSuccessPageLocationMessage } from "@calcom/app-store/locations";
import dayjs from "@calcom/dayjs";
import { sdkActionManager, useIsEmbed } from "@calcom/embed-core/embed-iframe";
import { Price } from "@calcom/features/bookings/components/event-meta/Price";
import { getPayIcon } from "@calcom/features/bookings/components/event-meta/getPayIcon";
import { APP_NAME, WEBSITE_URL } from "@calcom/lib/constants";
import getPaymentAppData from "@calcom/lib/getPaymentAppData";
import { useLocale } from "@calcom/lib/hooks/useLocale";

View File

@ -133,7 +133,7 @@ export const integrationsHandler = async ({ ctx, input }: IntegrationsOptions) =
});
//TODO: Refactor this to pick up only needed fields and prevent more leaking
let apps = enabledApps.map(
({ credentials: _, credential: _1, key: _2 /* don't leak to frontend */, ...app }) => {
({ credentials: _, credential, key: _2 /* don't leak to frontend */, ...app }) => {
const userCredentialIds = credentials.filter((c) => c.type === app.type && !c.teamId).map((c) => c.id);
const invalidCredentialIds = credentials
.filter((c) => c.type === app.type && c.invalid)
@ -169,6 +169,8 @@ export const integrationsHandler = async ({ ctx, input }: IntegrationsOptions) =
invalidCredentialIds,
teams,
isInstalled: !!userCredentialIds.length || !!teams.length || app.isGlobal,
// FIXME: remove hardcoding and add per-app validation
isSetup: !!credential?.key?.account_id || app.slug !== "alby",
};
}
);