Skip to content

Scheduling infrastructure for absolutely everyone.

chore: App router migration - general settings (#16312)

Joe Au-Yeung84a2e55125c3
diff --git a/apps/web/app/_utils.tsx b/apps/web/app/_utils.tsx
index a4bcdf1d10b..21ddec09943 100644
--- a/apps/web/app/_utils.tsx
+++ b/apps/web/app/_utils.tsx
@@ -22,7 +22,7 @@ const create = async (locale: string, ns: string) => {
return _i18n;
};
-const getFixedT = async (locale: string, ns: string) => {
+export const getFixedT = async (locale: string, ns = "common") => {
const i18n = await create(locale, ns);
return i18n.getFixedT(locale, ns);
diff --git a/apps/web/app/future/reschedule/[uid]/embed/page.tsx b/apps/web/app/future/reschedule/[uid]/embed/page.tsx
index a81eed65233..4cc22aabf29 100644
--- a/apps/web/app/future/reschedule/[uid]/embed/page.tsx
+++ b/apps/web/app/future/reschedule/[uid]/embed/page.tsx
@@ -1,17 +1,11 @@
import { getServerSideProps } from "@pages/reschedule/[uid]";
import { withAppDirSsr } from "app/WithAppDirSsr";
-import type { SearchParams } from "app/_types";
-import type { Params } from "next/dist/shared/lib/router/utils/route-matcher";
+import type { PageProps } from "app/_types";
import { cookies, headers } from "next/headers";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
import withEmbedSsr from "@lib/withEmbedSsr";
-type PageProps = Readonly<{
- params: Params;
- searchParams: SearchParams;
-}>;
-
const Page = async ({ params, searchParams }: PageProps) => {
const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);
await withAppDirSsr(withEmbedSsr(getServerSideProps))(legacyCtx);
diff --git a/apps/web/app/future/reschedule/[uid]/page.tsx b/apps/web/app/future/reschedule/[uid]/page.tsx
index af6ffb2505b..921369891f3 100644
--- a/apps/web/app/future/reschedule/[uid]/page.tsx
+++ b/apps/web/app/future/reschedule/[uid]/page.tsx
@@ -1,8 +1,7 @@
import { getServerSideProps } from "@pages/reschedule/[uid]";
import { withAppDirSsr } from "app/WithAppDirSsr";
-import type { SearchParams } from "app/_types";
+import type { PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
-import type { Params } from "next/dist/shared/lib/router/utils/route-matcher";
import { headers, cookies } from "next/headers";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
@@ -13,11 +12,6 @@ export const generateMetadata = async () =>
() => ""
);
-type PageProps = Readonly<{
- params: Params;
- searchParams: SearchParams;
-}>;
-
const getData = withAppDirSsr(getServerSideProps);
const Page = async ({ params, searchParams }: PageProps) => {
diff --git a/apps/web/app/future/routing-forms/page.tsx b/apps/web/app/future/routing-forms/page.tsx
index 52375eb6777..f904f3eaf4b 100644
--- a/apps/web/app/future/routing-forms/page.tsx
+++ b/apps/web/app/future/routing-forms/page.tsx
@@ -1,6 +1,5 @@
-import { type SearchParams } from "app/_types";
+import type { PageProps } from "app/_types";
import { type GetServerSidePropsContext } from "next";
-import type { Params } from "next/dist/shared/lib/router/utils/route-matcher";
import { cookies, headers } from "next/headers";
import { redirect } from "next/navigation";
import z from "zod";
@@ -21,11 +20,6 @@ const getPageProps = async (context: GetServerSidePropsContext) => {
return redirect(`/apps/routing-forms/${pages.length ? pages.join("/") : ""}`);
};
-type PageProps = Readonly<{
- params: Params;
- searchParams: SearchParams;
-}>;
-
const Page = async ({ params, searchParams }: PageProps) => {
const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);
await getPageProps(legacyCtx);
diff --git a/apps/web/app/future/settings/(admin)/admin/apps/[category]/page.tsx b/apps/web/app/future/settings/(admin)/admin/apps/[category]/page.tsx
new file mode 100644
index 00000000000..90c04a5c3a0
--- /dev/null
+++ b/apps/web/app/future/settings/(admin)/admin/apps/[category]/page.tsx
@@ -0,0 +1,34 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import AdminAppsList from "@calcom/features/apps/AdminAppsList";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("apps"),
+ (t) => t("admin_apps_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader title={t("apps")} description={t("admin_apps_description")}>
+ <div className="flex">
+ <AdminAppsList
+ baseURL="/settings/admin/apps"
+ classNames={{
+ appCategoryNavigationRoot: "overflow-x-scroll",
+ }}
+ />
+ </div>
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/admin/apps/[category]/page.tsx b/apps/web/app/future/settings/(admin)/admin/apps/page.tsx
similarity index 68%
rename from apps/web/app/future/settings/admin/apps/[category]/page.tsx
rename to apps/web/app/future/settings/(admin)/admin/apps/page.tsx
index 0805169a9e7..116b5da1ef7 100644
--- a/apps/web/app/future/settings/admin/apps/[category]/page.tsx
+++ b/apps/web/app/future/settings/(admin)/admin/apps/page.tsx
@@ -1,5 +1,5 @@
-import Page from "@pages/settings/admin/apps/[category]";
import { _generateMetadata } from "app/_utils";
+import { redirect } from "next/navigation";
export const generateMetadata = async () =>
await _generateMetadata(
@@ -7,4 +7,8 @@ export const generateMetadata = async () =>
(t) => t("admin_apps_description")
);
+const Page = () => {
+ redirect("/[category]");
+};
+
export default Page;
diff --git a/apps/web/app/future/settings/(admin)/admin/flags/page.tsx b/apps/web/app/future/settings/(admin)/admin/flags/page.tsx
new file mode 100644
index 00000000000..9322b5fd8ee
--- /dev/null
+++ b/apps/web/app/future/settings/(admin)/admin/flags/page.tsx
@@ -0,0 +1,20 @@
+import { _generateMetadata } from "app/_utils";
+
+import { FlagListingView } from "@calcom/features/flags/pages/flag-listing-view";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ () => "Feature Flags",
+ () => "Here you can toggle your Cal.com instance features."
+ );
+
+const Page = async () => {
+ return (
+ <SettingsHeader title="Feature Flags" description="Here you can toggle your Cal.com instance features.">
+ <FlagListingView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(admin)/admin/impersonation/page.tsx b/apps/web/app/future/settings/(admin)/admin/impersonation/page.tsx
new file mode 100644
index 00000000000..d3c29d61ad1
--- /dev/null
+++ b/apps/web/app/future/settings/(admin)/admin/impersonation/page.tsx
@@ -0,0 +1,27 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+import ImpersonationView from "~/settings/admin/impersonation-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("admin"),
+ (t) => t("impersonation")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+ return (
+ <SettingsHeader title={t("admin")} description={t("impersonation")}>
+ <ImpersonationView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(admin)/admin/lockedSMS/page.tsx b/apps/web/app/future/settings/(admin)/admin/lockedSMS/page.tsx
new file mode 100644
index 00000000000..9be28b5a4c1
--- /dev/null
+++ b/apps/web/app/future/settings/(admin)/admin/lockedSMS/page.tsx
@@ -0,0 +1,21 @@
+import { _generateMetadata } from "app/_utils";
+
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+import LockedSMSView from "~/settings/admin/locked-sms-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ () => "Locked SMS",
+ () => "Lock or unlock SMS sending for users"
+ );
+
+const Page = () => {
+ return (
+ <SettingsHeader title="Locked SMS" description="Lock or unlock SMS sending for users">
+ <LockedSMSView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(admin)/admin/oAuth/page.tsx b/apps/web/app/future/settings/(admin)/admin/oAuth/page.tsx
new file mode 100644
index 00000000000..158965294de
--- /dev/null
+++ b/apps/web/app/future/settings/(admin)/admin/oAuth/page.tsx
@@ -0,0 +1,21 @@
+import { _generateMetadata } from "app/_utils";
+
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+import LegacyPage from "~/settings/admin/oauth-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ () => "OAuth",
+ () => "Add new OAuth Clients"
+ );
+
+const Page = () => {
+ return (
+ <SettingsHeader title="OAuth" description="Add new OAuth Clients">
+ <LegacyPage />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(admin)/admin/organizations/[id]/edit/page.tsx b/apps/web/app/future/settings/(admin)/admin/organizations/[id]/edit/page.tsx
new file mode 100644
index 00000000000..1e94efb8171
--- /dev/null
+++ b/apps/web/app/future/settings/(admin)/admin/organizations/[id]/edit/page.tsx
@@ -0,0 +1,52 @@
+import { type Params } from "app/_types";
+import { _generateMetadata } from "app/_utils";
+import { notFound } from "next/navigation";
+import { z } from "zod";
+
+import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
+import { OrgForm } from "@calcom/features/ee/organizations/pages/settings/admin/AdminOrgEditPage";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+import { OrganizationRepository } from "@calcom/lib/server/repository/organization";
+
+const orgIdSchema = z.object({ id: z.coerce.number() });
+
+export const generateMetadata = async ({ params }: { params: Params }) => {
+ const input = orgIdSchema.safeParse(params);
+ if (!input.success) {
+ return await _generateMetadata(
+ () => `Editing organization`,
+ () => "Here you can edit an organization."
+ );
+ }
+
+ const org = await OrganizationRepository.adminFindById({ id: input.data.id });
+
+ return await _generateMetadata(
+ () => `Editing organization: ${org.name}`,
+ () => "Here you can edit an organization."
+ );
+};
+
+const Page = async ({ params }: { params: Params }) => {
+ const input = orgIdSchema.safeParse(params);
+
+ if (!input.success) notFound();
+
+ try {
+ const org = await OrganizationRepository.adminFindById({ id: input.data.id });
+
+ return (
+ <SettingsHeader
+ title={`Editing organization: ${org.name}`}
+ description="Here you can edit an organization.">
+ <LicenseRequired>
+ <OrgForm org={org} />
+ </LicenseRequired>
+ </SettingsHeader>
+ );
+ } catch {
+ notFound();
+ }
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(admin)/admin/organizations/page.tsx b/apps/web/app/future/settings/(admin)/admin/organizations/page.tsx
new file mode 100644
index 00000000000..672632f91a7
--- /dev/null
+++ b/apps/web/app/future/settings/(admin)/admin/organizations/page.tsx
@@ -0,0 +1,29 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
+import AdminOrgTable from "@calcom/features/ee/organizations/pages/settings/admin/AdminOrgPage";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("organizations"),
+ (t) => t("orgs_page_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+ return (
+ <SettingsHeader title={t("organizations")} description={t("orgs_page_description")}>
+ <LicenseRequired>
+ <AdminOrgTable />
+ </LicenseRequired>
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/admin/page.tsx b/apps/web/app/future/settings/(admin)/admin/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/admin/page.tsx
rename to apps/web/app/future/settings/(admin)/admin/page.tsx
diff --git a/apps/web/app/future/settings/(admin)/admin/users/[id]/edit/page.tsx b/apps/web/app/future/settings/(admin)/admin/users/[id]/edit/page.tsx
new file mode 100644
index 00000000000..6e554b19737
--- /dev/null
+++ b/apps/web/app/future/settings/(admin)/admin/users/[id]/edit/page.tsx
@@ -0,0 +1,52 @@
+import { type Params } from "app/_types";
+import { _generateMetadata } from "app/_utils";
+import { notFound } from "next/navigation";
+import { z } from "zod";
+
+import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
+import { UsersEditView } from "@calcom/features/ee/users/pages/users-edit-view";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+import { UserRepository } from "@calcom/lib/server/repository/user";
+
+const userIdSchema = z.object({ id: z.coerce.number() });
+
+export const generateMetadata = async ({ params }: { params: Params }) => {
+ const input = userIdSchema.safeParse(params);
+ if (!input.success) {
+ return await _generateMetadata(
+ () => `Editing user`,
+ () => "Here you can edit a current user."
+ );
+ }
+
+ const user = await UserRepository.adminFindById(input.data.id);
+
+ return await _generateMetadata(
+ () => `Editing user: ${user.username}`,
+ () => "Here you can edit a current user."
+ );
+};
+
+const Page = async ({ params }: { params: Params }) => {
+ const input = userIdSchema.safeParse(params);
+
+ if (!input.success) {
+ notFound();
+ }
+
+ try {
+ const user = await UserRepository.adminFindById(input.data.id);
+
+ return (
+ <SettingsHeader title="Editing user" description="Here you can edit a current user">
+ <LicenseRequired>
+ <UsersEditView user={user} />
+ </LicenseRequired>
+ </SettingsHeader>
+ );
+ } catch {
+ notFound();
+ }
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(admin)/admin/users/add/page.tsx b/apps/web/app/future/settings/(admin)/admin/users/add/page.tsx
new file mode 100644
index 00000000000..ee1aeb04c00
--- /dev/null
+++ b/apps/web/app/future/settings/(admin)/admin/users/add/page.tsx
@@ -0,0 +1,20 @@
+import { _generateMetadata } from "app/_utils";
+
+import UsersAddView from "@calcom/features/ee/users/pages/users-add-view";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ () => "Add new user",
+ () => "Here you can add a new user."
+ );
+
+const Page = () => {
+ return (
+ <SettingsHeader title="Add new user" description="Here you can add a new user">
+ <UsersAddView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(admin)/admin/users/page.tsx b/apps/web/app/future/settings/(admin)/admin/users/page.tsx
new file mode 100644
index 00000000000..26fb4f30d17
--- /dev/null
+++ b/apps/web/app/future/settings/(admin)/admin/users/page.tsx
@@ -0,0 +1,30 @@
+import { _generateMetadata } from "app/_utils";
+
+import UsersListingView from "@calcom/features/ee/users/pages/users-listing-view";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+import { Button } from "@calcom/ui";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ () => "Users",
+ () => "A list of all the users in your account including their name, title, email and role."
+ );
+
+const Page = () => {
+ return (
+ <SettingsHeader
+ title="Users"
+ description="A list of all the users in your account including their name, title, email and role."
+ CTA={
+ <div className="mt-4 space-x-5 sm:ml-16 sm:mt-0 sm:flex-none">
+ {/* TODO: Add import users functionality */}
+ {/* <Button disabled>Import users</Button> */}
+ <Button href="/settings/admin/users/add">Add user</Button>
+ </div>
+ }>
+ <UsersListingView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/admin/apps/layout.tsx b/apps/web/app/future/settings/(admin)/layout.tsx
similarity index 100%
rename from apps/web/app/future/settings/admin/apps/layout.tsx
rename to apps/web/app/future/settings/(admin)/layout.tsx
diff --git a/apps/web/app/future/settings/(settings)/billing/page.tsx b/apps/web/app/future/settings/(settings)/billing/page.tsx
new file mode 100644
index 00000000000..656487851da
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/billing/page.tsx
@@ -0,0 +1,31 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+import BillingView from "~/settings/billing/billing-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("billing"),
+ (t) => t("manage_billing_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader
+ title={t("billing")}
+ description={t("manage_billing_description")}
+ borderInShellHeader={true}>
+ <BillingView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/developer/api-keys/page.tsx b/apps/web/app/future/settings/(settings)/developer/api-keys/page.tsx
new file mode 100644
index 00000000000..31f740e36d2
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/developer/api-keys/page.tsx
@@ -0,0 +1,33 @@
+import { getFixedT, _generateMetadata } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+import { APP_NAME } from "@calcom/lib/constants";
+
+import ApiKeysView from "~/settings/developer/api-keys-view";
+import NewApiKeyButton from "~/settings/developer/components/CreateApiKeyButton";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("api_keys"),
+ (t) => t("create_first_api_key_description", { appName: APP_NAME })
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader
+ title={t("api_keys")}
+ description={t("create_first_api_key_description", { appName: APP_NAME })}
+ CTA={<NewApiKeyButton />}
+ borderInShellHeader={true}>
+ <ApiKeysView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/developer/webhooks/[id]/page.tsx b/apps/web/app/future/settings/(settings)/developer/webhooks/[id]/page.tsx
new file mode 100644
index 00000000000..709d2e0fffd
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/developer/webhooks/[id]/page.tsx
@@ -0,0 +1,36 @@
+import type { PageProps } from "app/_types";
+import { getFixedT, _generateMetadata } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+import { EditWebhookView } from "@calcom/features/webhooks/pages/webhook-edit-view";
+import { APP_NAME } from "@calcom/lib/constants";
+import { WebhookRepository } from "@calcom/lib/server/repository/webhook";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("webhooks"),
+ (t) => t("add_webhook_description", { appName: APP_NAME })
+ );
+
+const Page = async ({ params }: PageProps) => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+ const id = typeof params?.id === "string" ? params.id : undefined;
+
+ const webhook = await WebhookRepository.findByWebhookId(id);
+ console.log("This is the webhook", webhook);
+ return (
+ <SettingsHeader
+ title={t("edit_webhook")}
+ description={t("add_webhook_description", { appName: APP_NAME })}
+ borderInShellHeader={true}
+ backButton>
+ <EditWebhookView webhook={webhook} />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/developer/webhooks/new/page.tsx b/apps/web/app/future/settings/(settings)/developer/webhooks/new/page.tsx
new file mode 100644
index 00000000000..4c60a8989f4
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/developer/webhooks/new/page.tsx
@@ -0,0 +1,31 @@
+import { getFixedT, _generateMetadata } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+import { NewWebhookView } from "@calcom/features/webhooks/pages/webhook-new-view";
+import { APP_NAME } from "@calcom/lib/constants";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("webhooks"),
+ (t) => t("add_webhook_description", { appName: APP_NAME })
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader
+ title={t("add_webhook")}
+ description={t("add_webhook_description", { appName: APP_NAME })}
+ borderInShellHeader={true}
+ backButton>
+ <NewWebhookView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/developer/webhooks/page.tsx b/apps/web/app/future/settings/(settings)/developer/webhooks/page.tsx
new file mode 100644
index 00000000000..406599b63ac
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/developer/webhooks/page.tsx
@@ -0,0 +1,16 @@
+import { _generateMetadata } from "app/_utils";
+
+import { WebhooksViewAppDir } from "@calcom/features/webhooks/pages/webhooks-view";
+import { APP_NAME } from "@calcom/lib/constants";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("webhooks"),
+ (t) => t("add_webhook_description", { appName: APP_NAME })
+ );
+
+const Page = () => {
+ return <WebhooksViewAppDir />;
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/layout.tsx b/apps/web/app/future/settings/(settings)/layout.tsx
new file mode 100644
index 00000000000..3fc739975d4
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/layout.tsx
@@ -0,0 +1,5 @@
+import { WithLayout } from "app/layoutHOC";
+
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
+
+export default WithLayout({ getLayout: getLayout })<"L">;
diff --git a/apps/web/app/future/settings/(settings)/my-account/appearance/page.tsx b/apps/web/app/future/settings/(settings)/my-account/appearance/page.tsx
new file mode 100644
index 00000000000..b32f763a79f
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/my-account/appearance/page.tsx
@@ -0,0 +1,27 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+import AppearancePage from "~/settings/my-account/appearance-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("appearance"),
+ (t) => t("appearance_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader title={t("appearance")} description={t("appearance_description")}>
+ <AppearancePage />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/my-account/calendars/page.tsx b/apps/web/app/future/settings/(settings)/my-account/calendars/page.tsx
new file mode 100644
index 00000000000..4b5b25885af
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/my-account/calendars/page.tsx
@@ -0,0 +1,41 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+import { Button } from "@calcom/ui";
+
+import { CalendarListContainer } from "@components/apps/CalendarListContainer";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("calendars"),
+ (t) => t("calendars_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+ const t = await getFixedT(session?.user.locale || "en");
+
+ const AddCalendarButton = () => {
+ return (
+ <>
+ <Button color="secondary" StartIcon="plus" href="/apps/categories/calendar">
+ {t("add_calendar")}
+ </Button>
+ </>
+ );
+ };
+
+ return (
+ <SettingsHeader
+ title={t("calendars")}
+ description={t("calendars_description")}
+ CTA={<AddCalendarButton />}>
+ <CalendarListContainer />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/my-account/conferencing/page.tsx b/apps/web/app/future/settings/(settings)/my-account/conferencing/page.tsx
new file mode 100644
index 00000000000..add5f7dd586
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/my-account/conferencing/page.tsx
@@ -0,0 +1,40 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+import { Button } from "@calcom/ui";
+
+import ConferencingView from "~/settings/my-account/conferencing-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("conferencing"),
+ (t) => t("conferencing_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+ const t = await getFixedT(session?.user.locale || "en");
+
+ const AddConferencingButton = () => {
+ return (
+ <Button color="secondary" StartIcon="plus" href="/apps/categories/conferencing">
+ {t("add")}
+ </Button>
+ );
+ };
+
+ return (
+ <SettingsHeader
+ title={t("conferencing")}
+ description={t("conferencing_description")}
+ CTA={<AddConferencingButton />}
+ borderInShellHeader={true}>
+ <ConferencingView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/my-account/general/page.tsx b/apps/web/app/future/settings/(settings)/my-account/general/page.tsx
new file mode 100644
index 00000000000..773337ae074
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/my-account/general/page.tsx
@@ -0,0 +1,27 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+import GeneralQueryView from "~/settings/my-account/general-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("general"),
+ (t) => t("general_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+ return (
+ <SettingsHeader title={t("general")} description={t("general_description")} borderInShellHeader={true}>
+ <GeneralQueryView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/my-account/out-of-office/page.tsx b/apps/web/app/future/settings/(settings)/my-account/out-of-office/page.tsx
new file mode 100644
index 00000000000..993615b0a6c
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/my-account/out-of-office/page.tsx
@@ -0,0 +1,31 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+import CreateNewOutOfOfficeEntryButton from "@calcom/features/settings/outOfOffice/CreateNewOutOfOfficeEntryButton";
+import { OutOfOfficeEntriesList } from "@calcom/features/settings/outOfOffice/OutOfOfficeEntriesList";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("out_of_office"),
+ (t) => t("out_of_office_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader
+ title={t("out_of_office")}
+ description={t("out_of_office_description")}
+ CTA={<CreateNewOutOfOfficeEntryButton />}>
+ <OutOfOfficeEntriesList />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/my-account/profile/page.tsx b/apps/web/app/future/settings/(settings)/my-account/profile/page.tsx
new file mode 100644
index 00000000000..3504f51af9e
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/my-account/profile/page.tsx
@@ -0,0 +1,31 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+import { APP_NAME } from "@calcom/lib/constants";
+
+import ProfileView from "~/settings/my-account/profile-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("profile"),
+ (t) => t("profile_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader
+ title={t("profile")}
+ description={t("profile_description", { appName: APP_NAME })}
+ borderInShellHeader={true}>
+ <ProfileView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/organizations/[id]/about/page.tsx b/apps/web/app/future/settings/(settings)/organizations/[id]/about/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/organizations/[id]/about/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/[id]/about/page.tsx
diff --git a/apps/web/app/future/settings/organizations/[id]/add-teams/page.tsx b/apps/web/app/future/settings/(settings)/organizations/[id]/add-teams/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/organizations/[id]/add-teams/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/[id]/add-teams/page.tsx
diff --git a/apps/web/app/future/settings/organizations/[id]/onboard-admins/page.tsx b/apps/web/app/future/settings/(settings)/organizations/[id]/onboard-admins/page.tsx
similarity index 89%
rename from apps/web/app/future/settings/organizations/[id]/onboard-admins/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/[id]/onboard-admins/page.tsx
index 5337e258e98..3bac3fb49d9 100644
--- a/apps/web/app/future/settings/organizations/[id]/onboard-admins/page.tsx
+++ b/apps/web/app/future/settings/(settings)/organizations/[id]/onboard-admins/page.tsx
@@ -1,16 +1,12 @@
import LegacyPage, {
buildWrappedOnboardTeamMembersPage,
} from "@pages/settings/organizations/[id]/onboard-members";
-import { type Params } from "app/_types";
+import type { PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { headers } from "next/headers";
import PageWrapper from "@components/PageWrapperAppDir";
-type PageProps = Readonly<{
- params: Params;
-}>;
-
export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("invite_organization_admins"),
diff --git a/apps/web/app/future/settings/(settings)/organizations/admin-api/page.tsx b/apps/web/app/future/settings/(settings)/organizations/admin-api/page.tsx
new file mode 100644
index 00000000000..8f5b2ddea05
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/organizations/admin-api/page.tsx
@@ -0,0 +1,29 @@
+import { getFixedT, _generateMetadata } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import { AdminAPIView } from "@calcom/features/ee/organizations/pages/settings/admin-api";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => `${t("admin")} ${t("api_reference")}`,
+ (t) => t("leverage_our_api")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader
+ title={`${t("admin")} ${t("api_reference")}`}
+ description={t("leverage_our_api")}
+ borderInShellHeader={false}>
+ <AdminAPIView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/my-account/appearance/layout.tsx b/apps/web/app/future/settings/(settings)/organizations/appearance/layout.tsx
similarity index 51%
rename from apps/web/app/future/settings/my-account/appearance/layout.tsx
rename to apps/web/app/future/settings/(settings)/organizations/appearance/layout.tsx
index 230bfea4d1b..517645e71f0 100644
--- a/apps/web/app/future/settings/my-account/appearance/layout.tsx
+++ b/apps/web/app/future/settings/(settings)/organizations/appearance/layout.tsx
@@ -1,5 +1,5 @@
import { WithLayout } from "app/layoutHOC";
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/appearance/page.tsx b/apps/web/app/future/settings/(settings)/organizations/appearance/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/organizations/appearance/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/appearance/page.tsx
diff --git a/apps/web/app/future/settings/my-account/calendars/layout.tsx b/apps/web/app/future/settings/(settings)/organizations/billing/layout.tsx
similarity index 51%
rename from apps/web/app/future/settings/my-account/calendars/layout.tsx
rename to apps/web/app/future/settings/(settings)/organizations/billing/layout.tsx
index 230bfea4d1b..517645e71f0 100644
--- a/apps/web/app/future/settings/my-account/calendars/layout.tsx
+++ b/apps/web/app/future/settings/(settings)/organizations/billing/layout.tsx
@@ -1,5 +1,5 @@
import { WithLayout } from "app/layoutHOC";
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/billing/page.tsx b/apps/web/app/future/settings/(settings)/organizations/billing/page.tsx
similarity index 80%
rename from apps/web/app/future/settings/organizations/billing/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/billing/page.tsx
index 7dbae67d41e..52080e55f5b 100644
--- a/apps/web/app/future/settings/organizations/billing/page.tsx
+++ b/apps/web/app/future/settings/(settings)/organizations/billing/page.tsx
@@ -1,6 +1,7 @@
-import Page from "@pages/settings/billing/index";
import { _generateMetadata } from "app/_utils";
+import Page from "~/settings/billing/billing-view";
+
export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("billing"),
diff --git a/apps/web/app/future/settings/my-account/conferencing/layout.tsx b/apps/web/app/future/settings/(settings)/organizations/general/layout.tsx
similarity index 51%
rename from apps/web/app/future/settings/my-account/conferencing/layout.tsx
rename to apps/web/app/future/settings/(settings)/organizations/general/layout.tsx
index 230bfea4d1b..517645e71f0 100644
--- a/apps/web/app/future/settings/my-account/conferencing/layout.tsx
+++ b/apps/web/app/future/settings/(settings)/organizations/general/layout.tsx
@@ -1,5 +1,5 @@
import { WithLayout } from "app/layoutHOC";
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/general/page.tsx b/apps/web/app/future/settings/(settings)/organizations/general/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/organizations/general/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/general/page.tsx
diff --git a/apps/web/app/future/settings/my-account/general/layout.tsx b/apps/web/app/future/settings/(settings)/organizations/members/layout.tsx
similarity index 51%
rename from apps/web/app/future/settings/my-account/general/layout.tsx
rename to apps/web/app/future/settings/(settings)/organizations/members/layout.tsx
index 230bfea4d1b..517645e71f0 100644
--- a/apps/web/app/future/settings/my-account/general/layout.tsx
+++ b/apps/web/app/future/settings/(settings)/organizations/members/layout.tsx
@@ -1,5 +1,5 @@
import { WithLayout } from "app/layoutHOC";
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/members/page.tsx b/apps/web/app/future/settings/(settings)/organizations/members/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/organizations/members/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/members/page.tsx
diff --git a/apps/web/app/future/settings/organizations/new/page.tsx b/apps/web/app/future/settings/(settings)/organizations/new/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/organizations/new/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/new/page.tsx
diff --git a/apps/web/app/future/settings/(settings)/organizations/profile/layout.tsx b/apps/web/app/future/settings/(settings)/organizations/profile/layout.tsx
new file mode 100644
index 00000000000..517645e71f0
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/organizations/profile/layout.tsx
@@ -0,0 +1,5 @@
+import { WithLayout } from "app/layoutHOC";
+
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
+
+export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/profile/page.tsx b/apps/web/app/future/settings/(settings)/organizations/profile/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/organizations/profile/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/profile/page.tsx
diff --git a/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/appearance/layout.tsx b/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/appearance/layout.tsx
new file mode 100644
index 00000000000..517645e71f0
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/appearance/layout.tsx
@@ -0,0 +1,5 @@
+import { WithLayout } from "app/layoutHOC";
+
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
+
+export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/teams/other/[id]/appearance/page.tsx b/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/appearance/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/organizations/teams/other/[id]/appearance/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/appearance/page.tsx
diff --git a/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/members/layout.tsx b/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/members/layout.tsx
new file mode 100644
index 00000000000..517645e71f0
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/members/layout.tsx
@@ -0,0 +1,5 @@
+import { WithLayout } from "app/layoutHOC";
+
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
+
+export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/teams/other/[id]/members/page.tsx b/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/members/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/organizations/teams/other/[id]/members/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/members/page.tsx
diff --git a/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/profile/layout.tsx b/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/profile/layout.tsx
new file mode 100644
index 00000000000..517645e71f0
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/profile/layout.tsx
@@ -0,0 +1,5 @@
+import { WithLayout } from "app/layoutHOC";
+
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
+
+export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/teams/other/[id]/profile/page.tsx b/apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/profile/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/organizations/teams/other/[id]/profile/page.tsx
rename to apps/web/app/future/settings/(settings)/organizations/teams/other/[id]/profile/page.tsx
diff --git a/apps/web/app/future/settings/(settings)/organizations/teams/other/layout.tsx b/apps/web/app/future/settings/(settings)/organizations/teams/other/layout.tsx
new file mode 100644
index 00000000000..517645e71f0
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/organizations/teams/other/layout.tsx
@@ -0,0 +1,5 @@
+import { WithLayout } from "app/layoutHOC";
+
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
+
+export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/teams/other/page.ts b/apps/web/app/future/settings/(settings)/organizations/teams/other/page.ts
similarity index 100%
rename from apps/web/app/future/settings/organizations/teams/other/page.ts
rename to apps/web/app/future/settings/(settings)/organizations/teams/other/page.ts
diff --git a/apps/web/app/future/settings/(settings)/security/impersonation/page.tsx b/apps/web/app/future/settings/(settings)/security/impersonation/page.tsx
new file mode 100644
index 00000000000..4e209393936
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/security/impersonation/page.tsx
@@ -0,0 +1,31 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+import ProfileImpersonationViewWrapper from "~/settings/security/impersonation-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("impersonation"),
+ (t) => t("impersonation_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader
+ title={t("impersonation")}
+ description={t("impersonation_description")}
+ borderInShellHeader={true}>
+ <ProfileImpersonationViewWrapper />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/security/password/page.tsx b/apps/web/app/future/settings/(settings)/security/password/page.tsx
new file mode 100644
index 00000000000..09a6d0e68ff
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/security/password/page.tsx
@@ -0,0 +1,28 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+import PasswordViewWrapper from "~/settings/security/password-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("password"),
+ (t) => t("password_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader title={t("password")} description={t("password_description")} borderInShellHeader={true}>
+ <PasswordViewWrapper />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/security/sso/page.tsx b/apps/web/app/future/settings/(settings)/security/sso/page.tsx
new file mode 100644
index 00000000000..b5f311b3691
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/security/sso/page.tsx
@@ -0,0 +1,30 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SAMLSSO from "@calcom/features/ee/sso/page/user-sso-view";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("sso_configuration"),
+ (t) => t("sso_configuration_description")
+ );
+
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader
+ title={t("sso_configuration")}
+ description={t("sso_configuration_description")}
+ borderInShellHeader={true}>
+ <SAMLSSO />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/(settings)/security/two-factor-auth/page.tsx b/apps/web/app/future/settings/(settings)/security/two-factor-auth/page.tsx
new file mode 100644
index 00000000000..dbfed4e9abb
--- /dev/null
+++ b/apps/web/app/future/settings/(settings)/security/two-factor-auth/page.tsx
@@ -0,0 +1,30 @@
+import { _generateMetadata } from "app/_utils";
+import { getFixedT } from "app/_utils";
+import { getServerSession } from "next-auth";
+
+import { AUTH_OPTIONS } from "@calcom/feature-auth/lib/next-auth-options";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
+
+import TwoFactorAuthView from "~/settings/security/two-factor-auth-view";
+
+export const generateMetadata = async () =>
+ await _generateMetadata(
+ (t) => t("two_factor_auth"),
+ (t) => t("add_an_extra_layer_of_security")
+ );
+const Page = async () => {
+ const session = await getServerSession(AUTH_OPTIONS);
+
+ const t = await getFixedT(session?.user.locale || "en");
+
+ return (
+ <SettingsHeader
+ title={t("2fa")}
+ description={t("set_up_two_factor_authentication")}
+ borderInShellHeader={true}>
+ <TwoFactorAuthView />
+ </SettingsHeader>
+ );
+};
+
+export default Page;
diff --git a/apps/web/app/future/settings/teams/[id]/appearance/page.tsx b/apps/web/app/future/settings/(settings)/teams/[id]/appearance/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/teams/[id]/appearance/page.tsx
rename to apps/web/app/future/settings/(settings)/teams/[id]/appearance/page.tsx
diff --git a/apps/web/app/future/settings/teams/[id]/billing/page.tsx b/apps/web/app/future/settings/(settings)/teams/[id]/billing/page.tsx
similarity index 80%
rename from apps/web/app/future/settings/teams/[id]/billing/page.tsx
rename to apps/web/app/future/settings/(settings)/teams/[id]/billing/page.tsx
index 96b7f2f3b35..34e7f004a4d 100644
--- a/apps/web/app/future/settings/teams/[id]/billing/page.tsx
+++ b/apps/web/app/future/settings/(settings)/teams/[id]/billing/page.tsx
@@ -1,6 +1,7 @@
-import Page from "@pages/settings/billing/index";
import { _generateMetadata } from "app/_utils";
+import Page from "~/settings/billing/billing-view";
+
export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("billing"),
diff --git a/apps/web/app/future/settings/teams/[id]/event-type/page.tsx b/apps/web/app/future/settings/(settings)/teams/[id]/event-type/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/teams/[id]/event-type/page.tsx
rename to apps/web/app/future/settings/(settings)/teams/[id]/event-type/page.tsx
diff --git a/apps/web/app/future/settings/teams/[id]/members/page.tsx b/apps/web/app/future/settings/(settings)/teams/[id]/members/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/teams/[id]/members/page.tsx
rename to apps/web/app/future/settings/(settings)/teams/[id]/members/page.tsx
diff --git a/apps/web/app/future/settings/teams/[id]/onboard-members/page.tsx b/apps/web/app/future/settings/(settings)/teams/[id]/onboard-members/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/teams/[id]/onboard-members/page.tsx
rename to apps/web/app/future/settings/(settings)/teams/[id]/onboard-members/page.tsx
diff --git a/apps/web/app/future/settings/teams/[id]/profile/page.tsx b/apps/web/app/future/settings/(settings)/teams/[id]/profile/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/teams/[id]/profile/page.tsx
rename to apps/web/app/future/settings/(settings)/teams/[id]/profile/page.tsx
diff --git a/apps/web/app/future/settings/admin/flags/layout.tsx b/apps/web/app/future/settings/(settings)/teams/layout.tsx
similarity index 52%
rename from apps/web/app/future/settings/admin/flags/layout.tsx
rename to apps/web/app/future/settings/(settings)/teams/layout.tsx
index f415bae7649..31b58d652c8 100644
--- a/apps/web/app/future/settings/admin/flags/layout.tsx
+++ b/apps/web/app/future/settings/(settings)/teams/layout.tsx
@@ -1,5 +1,5 @@
import { WithLayout } from "app/layoutHOC";
-import { getLayout } from "@components/auth/layouts/AdminLayoutAppDir";
+import { getLayout } from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
export default WithLayout({ getLayout })<"L">;
diff --git a/apps/web/app/future/settings/teams/new/page.tsx b/apps/web/app/future/settings/(settings)/teams/new/page.tsx
similarity index 100%
rename from apps/web/app/future/settings/teams/new/page.tsx
rename to apps/web/app/future/settings/(settings)/teams/new/page.tsx
diff --git a/apps/web/app/future/settings/teams/page.ts b/apps/web/app/future/settings/(settings)/teams/page.ts
similarity index 100%
rename from apps/web/app/future/settings/teams/page.ts
rename to apps/web/app/future/settings/(settings)/teams/page.ts
diff --git a/apps/web/app/future/settings/admin/apps/page.tsx b/apps/web/app/future/settings/admin/apps/page.tsx
deleted file mode 100644
index c53f6eb9f90..00000000000
--- a/apps/web/app/future/settings/admin/apps/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/admin/apps/index";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("apps"),
- (t) => t("admin_apps_description")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/admin/flags/page.tsx b/apps/web/app/future/settings/admin/flags/page.tsx
deleted file mode 100644
index adf10ecbc3c..00000000000
--- a/apps/web/app/future/settings/admin/flags/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/admin/flags";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- () => "Feature Flags",
- () => "Here you can toggle your Cal.com instance features."
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/admin/impersonation/layout.tsx b/apps/web/app/future/settings/admin/impersonation/layout.tsx
deleted file mode 100644
index f415bae7649..00000000000
--- a/apps/web/app/future/settings/admin/impersonation/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@components/auth/layouts/AdminLayoutAppDir";
-
-export default WithLayout({ getLayout })<"L">;
diff --git a/apps/web/app/future/settings/admin/impersonation/page.tsx b/apps/web/app/future/settings/admin/impersonation/page.tsx
deleted file mode 100644
index f18a6df8584..00000000000
--- a/apps/web/app/future/settings/admin/impersonation/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/admin/impersonation";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("admin"),
- (t) => t("impersonation")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/admin/oAuth/oAuthView/layout.tsx b/apps/web/app/future/settings/admin/oAuth/oAuthView/layout.tsx
deleted file mode 100644
index dc2fb3468fd..00000000000
--- a/apps/web/app/future/settings/admin/oAuth/oAuthView/layout.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-export default WithLayout({ getLayout: null })<"L">;
diff --git a/apps/web/app/future/settings/admin/oAuth/oAuthView/page.tsx b/apps/web/app/future/settings/admin/oAuth/oAuthView/page.tsx
deleted file mode 100644
index 165622e62a7..00000000000
--- a/apps/web/app/future/settings/admin/oAuth/oAuthView/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/admin/oAuth/oAuthView";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- () => "OAuth",
- () => "Add new OAuth Clients"
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/admin/oAuth/page.tsx b/apps/web/app/future/settings/admin/oAuth/page.tsx
deleted file mode 100644
index 58a8a41dd6b..00000000000
--- a/apps/web/app/future/settings/admin/oAuth/page.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import LegacyPage from "@pages/settings/admin/oAuth/index";
-import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@components/auth/layouts/AdminLayoutAppDir";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- () => "OAuth",
- () => "Add new OAuth Clients"
- );
-
-export default WithLayout({ getLayout, Page: LegacyPage })<"P">;
diff --git a/apps/web/app/future/settings/admin/organizations/layout.tsx b/apps/web/app/future/settings/admin/organizations/layout.tsx
deleted file mode 100644
index 1359b266012..00000000000
--- a/apps/web/app/future/settings/admin/organizations/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout })<"L">;
diff --git a/apps/web/app/future/settings/admin/organizations/page.tsx b/apps/web/app/future/settings/admin/organizations/page.tsx
deleted file mode 100644
index 7ec2b7fa6b6..00000000000
--- a/apps/web/app/future/settings/admin/organizations/page.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { _generateMetadata } from "app/_utils";
-
-import Page from "@calcom/features/ee/organizations/pages/settings/admin/AdminOrgPage";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("organizations"),
- (t) => t("orgs_page_description")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/admin/users/[id]/edit/page.tsx b/apps/web/app/future/settings/admin/users/[id]/edit/page.tsx
deleted file mode 100644
index b9291227c7b..00000000000
--- a/apps/web/app/future/settings/admin/users/[id]/edit/page.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import { type Params } from "app/_types";
-import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
-import { z } from "zod";
-
-import Page from "@calcom/features/ee/users/pages/users-edit-view";
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-const userIdSchema = z.object({ id: z.coerce.number() });
-
-export const generateMetadata = async ({ params }: { params: Params }) => {
- const input = userIdSchema.safeParse(params);
- if (!input.success) {
- return await _generateMetadata(
- () => "",
- () => "Here you can edit a current user."
- );
- }
-
- const userId = input.data.id;
- const { trpc } = await import("@calcom/trpc");
- const [data] = trpc.viewer.users.get.useSuspenseQuery({ userId });
- const { user } = data;
- const title = `Editing user: ${user.username}`;
-
- return await _generateMetadata(
- () => title,
- () => "Here you can edit a current user."
- );
-};
-
-export default WithLayout({ getLayout, Page })<"P">;
diff --git a/apps/web/app/future/settings/admin/users/add/page.tsx b/apps/web/app/future/settings/admin/users/add/page.tsx
deleted file mode 100644
index b9ee07ef278..00000000000
--- a/apps/web/app/future/settings/admin/users/add/page.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
-
-import Page from "@calcom/features/ee/users/pages/users-add-view";
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- () => "Add new user",
- () => "Here you can add a new user."
- );
-
-export default WithLayout({ getLayout, Page })<"P">;
diff --git a/apps/web/app/future/settings/admin/users/page.tsx b/apps/web/app/future/settings/admin/users/page.tsx
deleted file mode 100644
index b78abbdd476..00000000000
--- a/apps/web/app/future/settings/admin/users/page.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
-
-import Page from "@calcom/features/ee/users/pages/users-listing-view";
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- () => "Users",
- () => "A list of all the users in your account including their name, title, email and role."
- );
-
-export default WithLayout({ getLayout, Page })<"P">;
diff --git a/apps/web/app/future/settings/my-account/appearance/page.tsx b/apps/web/app/future/settings/my-account/appearance/page.tsx
deleted file mode 100644
index 73def1169e0..00000000000
--- a/apps/web/app/future/settings/my-account/appearance/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/my-account/appearance";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("appearance"),
- (t) => t("appearance_description")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/my-account/calendars/page.tsx b/apps/web/app/future/settings/my-account/calendars/page.tsx
deleted file mode 100644
index b44eeadcbe0..00000000000
--- a/apps/web/app/future/settings/my-account/calendars/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/my-account/calendars";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("calendars"),
- (t) => t("calendars_description")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/my-account/conferencing/page.tsx b/apps/web/app/future/settings/my-account/conferencing/page.tsx
deleted file mode 100644
index ce3edb408df..00000000000
--- a/apps/web/app/future/settings/my-account/conferencing/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/my-account/conferencing";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("conferencing"),
- (t) => t("conferencing_description")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/my-account/general/page.tsx b/apps/web/app/future/settings/my-account/general/page.tsx
deleted file mode 100644
index a768e8f608c..00000000000
--- a/apps/web/app/future/settings/my-account/general/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/my-account/general";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("general"),
- (t) => t("general_description")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/my-account/profile/layout.tsx b/apps/web/app/future/settings/my-account/profile/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/my-account/profile/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/my-account/profile/page.tsx b/apps/web/app/future/settings/my-account/profile/page.tsx
deleted file mode 100644
index 2d850a0df65..00000000000
--- a/apps/web/app/future/settings/my-account/profile/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/my-account/profile";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("profile"),
- (t) => t("profile_description")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/organizations/appearance/layout.tsx b/apps/web/app/future/settings/organizations/appearance/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/organizations/appearance/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/billing/layout.tsx b/apps/web/app/future/settings/organizations/billing/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/organizations/billing/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/general/layout.tsx b/apps/web/app/future/settings/organizations/general/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/organizations/general/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/members/layout.tsx b/apps/web/app/future/settings/organizations/members/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/organizations/members/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/profile/layout.tsx b/apps/web/app/future/settings/organizations/profile/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/organizations/profile/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/teams/other/[id]/appearance/layout.tsx b/apps/web/app/future/settings/organizations/teams/other/[id]/appearance/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/organizations/teams/other/[id]/appearance/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/teams/other/[id]/members/layout.tsx b/apps/web/app/future/settings/organizations/teams/other/[id]/members/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/organizations/teams/other/[id]/members/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/teams/other/[id]/profile/layout.tsx b/apps/web/app/future/settings/organizations/teams/other/[id]/profile/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/organizations/teams/other/[id]/profile/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/organizations/teams/other/layout.tsx b/apps/web/app/future/settings/organizations/teams/other/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/organizations/teams/other/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/security/impersonation/layout.tsx b/apps/web/app/future/settings/security/impersonation/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/security/impersonation/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/security/impersonation/page.tsx b/apps/web/app/future/settings/security/impersonation/page.tsx
deleted file mode 100644
index 2fa8e4fec27..00000000000
--- a/apps/web/app/future/settings/security/impersonation/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/security/impersonation";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("impersonation"),
- (t) => t("impersonation_description")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/security/password/layout.tsx b/apps/web/app/future/settings/security/password/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/security/password/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/security/password/page.tsx b/apps/web/app/future/settings/security/password/page.tsx
deleted file mode 100644
index acf5fe37b29..00000000000
--- a/apps/web/app/future/settings/security/password/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/security/password";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("password"),
- (t) => t("password_description")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/security/sso/layout.tsx b/apps/web/app/future/settings/security/sso/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/security/sso/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/security/sso/page.tsx b/apps/web/app/future/settings/security/sso/page.tsx
deleted file mode 100644
index 996ac7c913b..00000000000
--- a/apps/web/app/future/settings/security/sso/page.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { _generateMetadata } from "app/_utils";
-
-import Page from "@calcom/features/ee/sso/page/user-sso-view";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("sso_configuration"),
- (t) => t("sso_configuration_description")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/security/two-factor-auth/layout.tsx b/apps/web/app/future/settings/security/two-factor-auth/layout.tsx
deleted file mode 100644
index 230bfea4d1b..00000000000
--- a/apps/web/app/future/settings/security/two-factor-auth/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout });
diff --git a/apps/web/app/future/settings/security/two-factor-auth/page.tsx b/apps/web/app/future/settings/security/two-factor-auth/page.tsx
deleted file mode 100644
index 55e16afd17b..00000000000
--- a/apps/web/app/future/settings/security/two-factor-auth/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import Page from "@pages/settings/security/two-factor-auth";
-import { _generateMetadata } from "app/_utils";
-
-export const generateMetadata = async () =>
- await _generateMetadata(
- (t) => t("two_factor_auth"),
- (t) => t("add_an_extra_layer_of_security")
- );
-
-export default Page;
diff --git a/apps/web/app/future/settings/teams/layout.tsx b/apps/web/app/future/settings/teams/layout.tsx
deleted file mode 100644
index 1359b266012..00000000000
--- a/apps/web/app/future/settings/teams/layout.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import { WithLayout } from "app/layoutHOC";
-
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";
-
-export default WithLayout({ getLayout })<"L">;
diff --git a/apps/web/components/apps/CalendarListContainer.tsx b/apps/web/components/apps/CalendarListContainer.tsx
index 953d63f9ee1..2e956fcc166 100644
--- a/apps/web/components/apps/CalendarListContainer.tsx
+++ b/apps/web/components/apps/CalendarListContainer.tsx
@@ -1,4 +1,6 @@
-import { Fragment, useEffect } from "react";
+"use client";
+
+import { useEffect } from "react";
import { InstallAppButton } from "@calcom/app-store/components";
import {
diff --git a/apps/web/components/auth/layouts/AdminLayout.tsx b/apps/web/components/auth/layouts/AdminLayout.tsx
index 5c51ef47ce4..6c32d31bc3a 100644
--- a/apps/web/components/auth/layouts/AdminLayout.tsx
+++ b/apps/web/components/auth/layouts/AdminLayout.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import { useSession } from "next-auth/react";
import { usePathname, useRouter } from "next/navigation";
import type { ComponentProps } from "react";
diff --git a/apps/web/components/auth/layouts/AdminLayoutAppDir.tsx b/apps/web/components/auth/layouts/AdminLayoutAppDir.tsx
index b3d76190c4b..e07c877b684 100644
--- a/apps/web/components/auth/layouts/AdminLayoutAppDir.tsx
+++ b/apps/web/components/auth/layouts/AdminLayoutAppDir.tsx
@@ -5,7 +5,7 @@ import { usePathname, useRouter } from "next/navigation";
import type { ComponentProps } from "react";
import React, { useEffect } from "react";
-import SettingsLayout from "@calcom/features/settings/layouts/SettingsLayout";
+import SettingsLayout from "@calcom/features/settings/appDir/SettingsLayoutAppDir";
import type Shell from "@calcom/features/shell/Shell";
import { UserPermissionRole } from "@calcom/prisma/enums";
import { ErrorBoundary } from "@calcom/ui";
diff --git a/apps/web/components/settings/CustomEmailTextField.tsx b/apps/web/components/settings/CustomEmailTextField.tsx
index f489d3035a8..22417a4f69e 100644
--- a/apps/web/components/settings/CustomEmailTextField.tsx
+++ b/apps/web/components/settings/CustomEmailTextField.tsx
@@ -1,4 +1,3 @@
-import type { FormValues } from "@pages/settings/my-account/profile";
import { useState } from "react";
import type { UseFormReturn } from "react-hook-form";
@@ -15,6 +14,8 @@ import {
InputError,
} from "@calcom/ui";
+import type { FormValues } from "~/settings/my-account/profile-view";
+
type CustomEmailTextFieldProps = {
formMethods: UseFormReturn<FormValues>;
formMethodFieldName: keyof FormValues;
diff --git a/apps/web/components/settings/TravelScheduleModal.tsx b/apps/web/components/settings/TravelScheduleModal.tsx
index 2c72d73cfee..ecea7146898 100644
--- a/apps/web/components/settings/TravelScheduleModal.tsx
+++ b/apps/web/components/settings/TravelScheduleModal.tsx
@@ -1,4 +1,3 @@
-import type { FormValues } from "@pages/settings/my-account/general";
import { useState } from "react";
import type { UseFormSetValue } from "react-hook-form";
@@ -18,6 +17,8 @@ import {
DatePicker,
} from "@calcom/ui";
+import type { FormValues } from "~/settings/my-account/general-view";
+
interface TravelScheduleModalProps {
open: boolean;
onOpenChange: () => void;
diff --git a/apps/web/lib/settings/admin/orgMigrations/moveTeamToOrg/getServerSideProps.tsx b/apps/web/lib/settings/admin/orgMigrations/moveTeamToOrg/getServerSideProps.tsx
new file mode 100644
index 00000000000..cb4ac548b55
--- /dev/null
+++ b/apps/web/lib/settings/admin/orgMigrations/moveTeamToOrg/getServerSideProps.tsx
@@ -0,0 +1,36 @@
+import type { GetServerSidePropsContext } from "next";
+import { getSession } from "next-auth/react";
+import { serverSideTranslations } from "next-i18next/serverSideTranslations";
+
+import { UserPermissionRole } from "@calcom/prisma/enums";
+
+export async function getServerSideProps(ctx: GetServerSidePropsContext) {
+ const session = await getSession(ctx);
+ if (!session || !session.user) {
+ return {
+ redirect: {
+ destination: "/login",
+ permanent: false,
+ },
+ };
+ }
+
+ const isAdmin = session.user.role === UserPermissionRole.ADMIN;
+ if (!isAdmin) {
+ return {
+ redirect: {
+ destination: "/",
+ permanent: false,
+ },
+ };
+ }
+ return {
+ props: {
+ error: null,
+ migrated: null,
+ userId: session.user.id,
+ ...(await serverSideTranslations(ctx.locale || "en", ["common"])),
+ username: session.user.username,
+ },
+ };
+}
diff --git a/apps/web/lib/settings/admin/orgMigrations/moveUserToOrg/getServerSideProps.tsx b/apps/web/lib/settings/admin/orgMigrations/moveUserToOrg/getServerSideProps.tsx
new file mode 100644
index 00000000000..be728f4d8cc
--- /dev/null
+++ b/apps/web/lib/settings/admin/orgMigrations/moveUserToOrg/getServerSideProps.tsx
@@ -0,0 +1,32 @@
+import type { GetServerSidePropsContext } from "next";
+import { getSession } from "next-auth/react";
+import { serverSideTranslations } from "next-i18next/serverSideTranslations";
+
+import { UserPermissionRole } from "@calcom/prisma/enums";
+
+export async function getServerSideProps(ctx: GetServerSidePropsContext) {
+ const session = await getSession(ctx);
+ if (!session || !session.user) {
+ return {
+ redirect: {
+ destination: "/login",
+ permanent: false,
+ },
+ };
+ }
+
+ const isAdmin = session.user.role === UserPermissionRole.ADMIN;
+ if (!isAdmin) {
+ return {
+ redirect: {
+ destination: "/",
+ permanent: false,
+ },
+ };
+ }
+ return {
+ props: {
+ ...(await serverSideTranslations(ctx.locale || "en", ["common"])),
+ },
+ };
+}
diff --git a/apps/web/lib/settings/admin/orgMigrations/removeTeamFromOrg/getServerSideProps.tsx b/apps/web/lib/settings/admin/orgMigrations/removeTeamFromOrg/getServerSideProps.tsx
new file mode 100644
index 00000000000..be728f4d8cc
--- /dev/null
+++ b/apps/web/lib/settings/admin/orgMigrations/removeTeamFromOrg/getServerSideProps.tsx
@@ -0,0 +1,32 @@
+import type { GetServerSidePropsContext } from "next";
+import { getSession } from "next-auth/react";
+import { serverSideTranslations } from "next-i18next/serverSideTranslations";
+
+import { UserPermissionRole } from "@calcom/prisma/enums";
+
+export async function getServerSideProps(ctx: GetServerSidePropsContext) {
+ const session = await getSession(ctx);
+ if (!session || !session.user) {
+ return {
+ redirect: {
+ destination: "/login",
+ permanent: false,
+ },
+ };
+ }
+
+ const isAdmin = session.user.role === UserPermissionRole.ADMIN;
+ if (!isAdmin) {
+ return {
+ redirect: {
+ destination: "/",
+ permanent: false,
+ },
+ };
+ }
+ return {
+ props: {
+ ...(await serverSideTranslations(ctx.locale || "en", ["common"])),
+ },
+ };
+}
diff --git a/apps/web/lib/settings/admin/orgMigrations/removeUserFromOrg/getServerSideProps.tsx b/apps/web/lib/settings/admin/orgMigrations/removeUserFromOrg/getServerSideProps.tsx
new file mode 100644
index 00000000000..be728f4d8cc
--- /dev/null
+++ b/apps/web/lib/settings/admin/orgMigrations/removeUserFromOrg/getServerSideProps.tsx
@@ -0,0 +1,32 @@
+import type { GetServerSidePropsContext } from "next";
+import { getSession } from "next-auth/react";
+import { serverSideTranslations } from "next-i18next/serverSideTranslations";
+
+import { UserPermissionRole } from "@calcom/prisma/enums";
+
+export async function getServerSideProps(ctx: GetServerSidePropsContext) {
+ const session = await getSession(ctx);
+ if (!session || !session.user) {
+ return {
+ redirect: {
+ destination: "/login",
+ permanent: false,
+ },
+ };
+ }
+
+ const isAdmin = session.user.role === UserPermissionRole.ADMIN;
+ if (!isAdmin) {
+ return {
+ redirect: {
+ destination: "/",
+ permanent: false,
+ },
+ };
+ }
+ return {
+ props: {
+ ...(await serverSideTranslations(ctx.locale || "en", ["common"])),
+ },
+ };
+}
diff --git a/apps/web/pages/settings/admin/lockedSMS/UsersTable.tsx b/apps/web/modules/settings/admin/components/UsersTable.tsx
similarity index 100%
rename from apps/web/pages/settings/admin/lockedSMS/UsersTable.tsx
rename to apps/web/modules/settings/admin/components/UsersTable.tsx
diff --git a/apps/web/modules/settings/admin/impersonation-view.tsx b/apps/web/modules/settings/admin/impersonation-view.tsx
new file mode 100644
index 00000000000..9331377a7db
--- /dev/null
+++ b/apps/web/modules/settings/admin/impersonation-view.tsx
@@ -0,0 +1,57 @@
+"use client";
+
+import { signIn } from "next-auth/react";
+import { useSearchParams } from "next/navigation";
+import { useRef, useEffect } from "react";
+
+import { WEBAPP_URL } from "@calcom/lib/constants";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { Button, TextField } from "@calcom/ui";
+
+const ImpersonationView = () => {
+ const { t } = useLocale();
+ const usernameRef = useRef<HTMLInputElement>(null);
+ const searchParams = useSearchParams();
+
+ const username = searchParams?.get("username")?.toLowerCase();
+
+ useEffect(() => {
+ if (username) {
+ const enteredUsername = username.toLowerCase();
+ signIn("impersonation-auth", {
+ username: enteredUsername,
+ callbackUrl: `${WEBAPP_URL}/event-types`,
+ });
+ }
+ }, [username]);
+
+ return (
+ <form
+ className="mb-6 w-full"
+ onSubmit={(e) => {
+ e.preventDefault();
+ const enteredUsername = usernameRef.current?.value.toLowerCase();
+ signIn("impersonation-auth", {
+ username: enteredUsername,
+ callbackUrl: `${WEBAPP_URL}/event-types`,
+ });
+ }}>
+ <div className="flex items-center space-x-2 rtl:space-x-reverse">
+ <TextField
+ containerClassName="w-full"
+ name={t("user_impersonation_heading")}
+ addOnLeading={<>{process.env.NEXT_PUBLIC_WEBSITE_URL}/</>}
+ ref={usernameRef}
+ hint={t("impersonate_user_tip")}
+ defaultValue={undefined}
+ data-testid="admin-impersonation-input"
+ />
+ <Button type="submit" data-testid="impersonation-submit">
+ {t("impersonate")}
+ </Button>
+ </div>
+ </form>
+ );
+};
+
+export default ImpersonationView;
diff --git a/apps/web/pages/settings/admin/lockedSMS/lockedSMSView.tsx b/apps/web/modules/settings/admin/locked-sms-view.tsx
similarity index 91%
rename from apps/web/pages/settings/admin/lockedSMS/lockedSMSView.tsx
rename to apps/web/modules/settings/admin/locked-sms-view.tsx
index 079586abd63..eb6364942b1 100644
--- a/apps/web/pages/settings/admin/lockedSMS/lockedSMSView.tsx
+++ b/apps/web/modules/settings/admin/locked-sms-view.tsx
@@ -1,10 +1,11 @@
"use client";
-import UsersTable from "@pages/settings/admin/lockedSMS/UsersTable";
import { useState } from "react";
import { trpc } from "@calcom/trpc";
-import { Button, Meta, TextField, showToast } from "@calcom/ui";
+import { Button, TextField, showToast } from "@calcom/ui";
+
+import UsersTable from "./components/UsersTable";
export default function LockedSMSView() {
const [username, setUsername] = useState("");
@@ -35,7 +36,6 @@ export default function LockedSMSView() {
return (
<div>
- <Meta title="lockedSMS" description="Lock or unlock SMS sending for users" />
<div className="mb-4 flex w-full items-center justify-between space-x-2 rtl:space-x-reverse">
<div className="flex">
<TextField
diff --git a/apps/web/pages/settings/admin/oAuth/oAuthView.tsx b/apps/web/modules/settings/admin/oauth-view.tsx
similarity index 96%
rename from apps/web/pages/settings/admin/oAuth/oAuthView.tsx
rename to apps/web/modules/settings/admin/oauth-view.tsx
index fb3338860ed..711897ecd63 100644
--- a/apps/web/pages/settings/admin/oAuth/oAuthView.tsx
+++ b/apps/web/modules/settings/admin/oauth-view.tsx
@@ -5,7 +5,7 @@ import { useForm } from "react-hook-form";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc";
-import { Meta, Form, Button, Icon, TextField, showToast, Tooltip, ImageUploader, Avatar } from "@calcom/ui";
+import { Form, Button, Icon, TextField, showToast, Tooltip, ImageUploader, Avatar } from "@calcom/ui";
type FormValues = {
name: string;
@@ -33,7 +33,6 @@ export default function OAuthView() {
return (
<div>
- <Meta title="OAuth" description="Add new OAuth Clients" />
{!clientId ? (
<Form
form={oAuthForm}
diff --git a/apps/web/modules/settings/billing/billing-view.tsx b/apps/web/modules/settings/billing/billing-view.tsx
new file mode 100644
index 00000000000..5a32adecf82
--- /dev/null
+++ b/apps/web/modules/settings/billing/billing-view.tsx
@@ -0,0 +1,64 @@
+"use client";
+
+import { usePathname } from "next/navigation";
+
+import { useIntercom } from "@calcom/features/ee/support/lib/intercom/useIntercom";
+import { classNames } from "@calcom/lib";
+import { WEBAPP_URL } from "@calcom/lib/constants";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { Button } from "@calcom/ui";
+
+interface CtaRowProps {
+ title: string;
+ description: string;
+ children: React.ReactNode;
+ className?: string;
+}
+
+const CtaRow = ({ title, description, className, children }: CtaRowProps) => {
+ return (
+ <>
+ <section className={classNames("text-default flex flex-col sm:flex-row", className)}>
+ <div>
+ <h2 className="text-base font-semibold">{title}</h2>
+ <p>{description}</p>
+ </div>
+ <div className="flex-shrink-0 pt-3 sm:ml-auto sm:pl-3 sm:pt-0">{children}</div>
+ </section>
+ </>
+ );
+};
+
+const BillingView = () => {
+ const pathname = usePathname();
+ const { t } = useLocale();
+ const { open } = useIntercom();
+ const returnTo = pathname;
+ const billingHref = `/api/integrations/stripepayment/portal?returnTo=${WEBAPP_URL}${returnTo}`;
+
+ const onContactSupportClick = async () => {
+ await open();
+ };
+
+ return (
+ <>
+ <div className="border-subtle space-y-6 rounded-b-lg border border-t-0 px-6 py-8 text-sm sm:space-y-8">
+ <CtaRow title={t("view_and_manage_billing_details")} description={t("view_and_edit_billing_details")}>
+ <Button color="primary" href={billingHref} target="_blank" EndIcon="external-link">
+ {t("billing_portal")}
+ </Button>
+ </CtaRow>
+
+ <hr className="border-subtle" />
+
+ <CtaRow title={t("need_anything_else")} description={t("further_billing_help")}>
+ <Button color="secondary" onClick={onContactSupportClick}>
+ {t("contact_support")}
+ </Button>
+ </CtaRow>
+ </div>
+ </>
+ );
+};
+
+export default BillingView;
diff --git a/apps/web/modules/settings/developer/api-keys-view.tsx b/apps/web/modules/settings/developer/api-keys-view.tsx
new file mode 100644
index 00000000000..34bba40b236
--- /dev/null
+++ b/apps/web/modules/settings/developer/api-keys-view.tsx
@@ -0,0 +1,108 @@
+"use client";
+
+import { useState } from "react";
+
+import type { TApiKeys } from "@calcom/ee/api-keys/components/ApiKeyListItem";
+import LicenseRequired from "@calcom/ee/common/components/LicenseRequired";
+import ApiKeyDialogForm from "@calcom/features/ee/api-keys/components/ApiKeyDialogForm";
+import ApiKeyListItem from "@calcom/features/ee/api-keys/components/ApiKeyListItem";
+import { APP_NAME } from "@calcom/lib/constants";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { trpc } from "@calcom/trpc/react";
+import {
+ Button,
+ Dialog,
+ DialogContent,
+ EmptyScreen,
+ Meta,
+ SkeletonContainer,
+ SkeletonText,
+} from "@calcom/ui";
+
+const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
+ return (
+ <SkeletonContainer>
+ <Meta title={title} description={description} borderInShellHeader={true} />
+ <div className="divide-subtle border-subtle space-y-6 rounded-b-lg border border-t-0 px-6 py-4">
+ <SkeletonText className="h-8 w-full" />
+ <SkeletonText className="h-8 w-full" />
+ </div>
+ </SkeletonContainer>
+ );
+};
+
+const ApiKeysView = () => {
+ const { t } = useLocale();
+
+ const { data, isPending } = trpc.viewer.apiKeys.list.useQuery();
+
+ const [apiKeyModal, setApiKeyModal] = useState(false);
+ const [apiKeyToEdit, setApiKeyToEdit] = useState<(TApiKeys & { neverExpires?: boolean }) | undefined>(
+ undefined
+ );
+
+ const NewApiKeyButton = () => {
+ return (
+ <Button
+ color="secondary"
+ StartIcon="plus"
+ onClick={() => {
+ setApiKeyToEdit(undefined);
+ setApiKeyModal(true);
+ }}>
+ {t("add")}
+ </Button>
+ );
+ };
+
+ if (isPending || !data) {
+ return (
+ <SkeletonLoader
+ title={t("api_keys")}
+ description={t("create_first_api_key_description", { appName: APP_NAME })}
+ />
+ );
+ }
+
+ return (
+ <>
+ <LicenseRequired>
+ <div>
+ {data?.length ? (
+ <>
+ <div className="border-subtle rounded-b-lg border border-t-0">
+ {data.map((apiKey, index) => (
+ <ApiKeyListItem
+ key={apiKey.id}
+ apiKey={apiKey}
+ lastItem={data.length === index + 1}
+ onEditClick={() => {
+ setApiKeyToEdit(apiKey);
+ setApiKeyModal(true);
+ }}
+ />
+ ))}
+ </div>
+ </>
+ ) : (
+ <EmptyScreen
+ Icon="link"
+ headline={t("create_first_api_key")}
+ description={t("create_first_api_key_description", { appName: APP_NAME })}
+ className="rounded-b-lg rounded-t-none border-t-0"
+ buttonRaw={<NewApiKeyButton />}
+ />
+ )}
+ </div>
+ </LicenseRequired>
+
+ <Dialog open={apiKeyModal} onOpenChange={setApiKeyModal}>
+ <DialogContent type="creation">
+ <ApiKeyDialogForm handleClose={() => setApiKeyModal(false)} defaultValues={apiKeyToEdit} />
+ </DialogContent>
+ </Dialog>
+ </>
+ );
+};
+
+export default ApiKeysView;
diff --git a/apps/web/modules/settings/developer/components/CreateApiKeyButton.tsx b/apps/web/modules/settings/developer/components/CreateApiKeyButton.tsx
new file mode 100644
index 00000000000..18a0171d074
--- /dev/null
+++ b/apps/web/modules/settings/developer/components/CreateApiKeyButton.tsx
@@ -0,0 +1,38 @@
+"use client";
+
+import { useState } from "react";
+
+import type { TApiKeys } from "@calcom/ee/api-keys/components/ApiKeyListItem";
+import ApiKeyDialogForm from "@calcom/features/ee/api-keys/components/ApiKeyDialogForm";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { Button, Dialog, DialogContent } from "@calcom/ui";
+
+const NewApiKeyButton = () => {
+ const { t } = useLocale();
+ const [apiKeyModal, setApiKeyModal] = useState(false);
+ const [apiKeyToEdit, setApiKeyToEdit] = useState<(TApiKeys & { neverExpires?: boolean }) | undefined>(
+ undefined
+ );
+
+ return (
+ <>
+ <Button
+ color="secondary"
+ StartIcon="plus"
+ onClick={() => {
+ setApiKeyToEdit(undefined);
+ setApiKeyModal(true);
+ }}>
+ {t("add")}
+ </Button>
+
+ <Dialog open={apiKeyModal} onOpenChange={setApiKeyModal}>
+ <DialogContent type="creation">
+ <ApiKeyDialogForm handleClose={() => setApiKeyModal(false)} defaultValues={apiKeyToEdit} />
+ </DialogContent>
+ </Dialog>
+ </>
+ );
+};
+
+export default NewApiKeyButton;
diff --git a/apps/web/modules/settings/my-account/appearance-view.tsx b/apps/web/modules/settings/my-account/appearance-view.tsx
new file mode 100644
index 00000000000..fc904d000bb
--- /dev/null
+++ b/apps/web/modules/settings/my-account/appearance-view.tsx
@@ -0,0 +1,440 @@
+"use client";
+
+import { useSession } from "next-auth/react";
+import { useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+import type { z } from "zod";
+
+import { BookerLayoutSelector } from "@calcom/features/settings/BookerLayoutSelector";
+import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
+import ThemeLabel from "@calcom/features/settings/ThemeLabel";
+import { APP_NAME } from "@calcom/lib/constants";
+import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR } from "@calcom/lib/constants";
+import { checkWCAGContrastColor } from "@calcom/lib/getBrandColours";
+import useGetBrandingColours from "@calcom/lib/getBrandColours";
+import { useHasPaidPlan } from "@calcom/lib/hooks/useHasPaidPlan";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import useTheme from "@calcom/lib/hooks/useTheme";
+import { validateBookerLayouts } from "@calcom/lib/validateBookerLayouts";
+import type { userMetadata } from "@calcom/prisma/zod-utils";
+import { trpc } from "@calcom/trpc/react";
+import type { RouterOutputs } from "@calcom/trpc/react";
+import {
+ Alert,
+ Button,
+ ColorPicker,
+ Form,
+ showToast,
+ SkeletonButton,
+ SkeletonContainer,
+ SkeletonText,
+ SettingsToggle,
+ UpgradeTeamsBadge,
+ useCalcomTheme,
+} from "@calcom/ui";
+
+const SkeletonLoader = () => {
+ return (
+ <SkeletonContainer>
+ <div className="border-subtle mt-6 flex items-center rounded-t-xl border p-6 text-sm">
+ <SkeletonText className="h-8 w-1/3" />
+ </div>
+ <div className="border-subtle space-y-6 border-x px-4 py-6 sm:px-6">
+ <div className="[&>*]:bg-emphasis flex w-full items-center justify-center gap-x-2 [&>*]:animate-pulse">
+ <div className="h-32 flex-1 rounded-md p-5" />
+ <div className="h-32 flex-1 rounded-md p-5" />
+ <div className="h-32 flex-1 rounded-md p-5" />
+ </div>
+ <div className="flex justify-between">
+ <SkeletonText className="h-8 w-1/3" />
+ <SkeletonText className="h-8 w-1/3" />
+ </div>
+
+ <SkeletonText className="h-8 w-full" />
+ </div>
+ <div className="rounded-b-lg">
+ <SectionBottomActions align="end">
+ <SkeletonButton className="mr-6 h-8 w-20 rounded-md p-5" />
+ </SectionBottomActions>
+ </div>
+ </SkeletonContainer>
+ );
+};
+
+const useBrandColors = (
+ currentTheme: string | null,
+ {
+ brandColor,
+ darkBrandColor,
+ }: {
+ brandColor?: string | null;
+ darkBrandColor?: string | null;
+ }
+): void => {
+ const brandTheme = useGetBrandingColours({
+ lightVal: brandColor,
+ darkVal: darkBrandColor,
+ });
+ const selectedTheme = currentTheme ? brandTheme[currentTheme as "light" | "dark"] : {};
+ useCalcomTheme({
+ root: selectedTheme,
+ });
+};
+
+const AppearanceView = ({
+ user,
+ hasPaidPlan,
+}: {
+ user: RouterOutputs["viewer"]["me"];
+ hasPaidPlan: boolean;
+}) => {
+ const { t } = useLocale();
+ const utils = trpc.useUtils();
+ const session = useSession();
+ const isApartOfOrganization = session.data?.user.org?.id;
+ const [darkModeError, setDarkModeError] = useState(false);
+ const [lightModeError, setLightModeError] = useState(false);
+ const [isCustomBrandColorChecked, setIsCustomBranColorChecked] = useState(
+ user?.brandColor !== DEFAULT_LIGHT_BRAND_COLOR || user?.darkBrandColor !== DEFAULT_DARK_BRAND_COLOR
+ );
+ const [hideBrandingValue, setHideBrandingValue] = useState(user?.hideBranding ?? false);
+ useTheme(user?.appTheme);
+ useBrandColors(user?.appTheme ?? null, {
+ brandColor: user?.brandColor,
+ darkBrandColor: user?.darkBrandColor,
+ });
+
+ const userAppThemeFormMethods = useForm({
+ defaultValues: {
+ appTheme: user.appTheme,
+ },
+ });
+
+ const {
+ formState: { isSubmitting: isUserAppThemeSubmitting, isDirty: isUserAppThemeDirty },
+ reset: resetUserAppThemeReset,
+ } = userAppThemeFormMethods;
+
+ const userThemeFormMethods = useForm({
+ defaultValues: {
+ theme: user.theme,
+ },
+ });
+
+ const {
+ formState: { isSubmitting: isUserThemeSubmitting, isDirty: isUserThemeDirty },
+ reset: resetUserThemeReset,
+ } = userThemeFormMethods;
+
+ const bookerLayoutFormMethods = useForm({
+ defaultValues: {
+ metadata: user.metadata as z.infer<typeof userMetadata>,
+ },
+ });
+
+ const {
+ formState: { isSubmitting: isBookerLayoutFormSubmitting, isDirty: isBookerLayoutFormDirty },
+ reset: resetBookerLayoutThemeReset,
+ } = bookerLayoutFormMethods;
+
+ const DEFAULT_BRAND_COLOURS = {
+ light: user.brandColor ?? DEFAULT_LIGHT_BRAND_COLOR,
+ dark: user.darkBrandColor ?? DEFAULT_DARK_BRAND_COLOR,
+ };
+
+ const brandColorsFormMethods = useForm({
+ defaultValues: {
+ brandColor: DEFAULT_BRAND_COLOURS.light,
+ darkBrandColor: DEFAULT_BRAND_COLOURS.dark,
+ },
+ });
+
+ const {
+ formState: { isSubmitting: isBrandColorsFormSubmitting, isDirty: isBrandColorsFormDirty },
+ reset: resetBrandColorsThemeReset,
+ } = brandColorsFormMethods;
+
+ const selectedTheme = userThemeFormMethods.watch("theme");
+ const selectedThemeIsDark =
+ selectedTheme === "dark" ||
+ (selectedTheme === "" &&
+ typeof document !== "undefined" &&
+ document.documentElement.classList.contains("dark"));
+
+ const mutation = trpc.viewer.updateProfile.useMutation({
+ onSuccess: async (data) => {
+ await utils.viewer.me.invalidate();
+ showToast(t("settings_updated_successfully"), "success");
+ resetBrandColorsThemeReset({ brandColor: data.brandColor, darkBrandColor: data.darkBrandColor });
+ resetBookerLayoutThemeReset({ metadata: data.metadata });
+ resetUserThemeReset({ theme: data.theme });
+ resetUserAppThemeReset({ appTheme: data.appTheme });
+ },
+ onError: (error) => {
+ if (error.message) {
+ showToast(error.message, "error");
+ } else {
+ showToast(t("error_updating_settings"), "error");
+ }
+ },
+ onSettled: async () => {
+ await utils.viewer.me.invalidate();
+ },
+ });
+
+ return (
+ <div>
+ <div className="border-subtle mt-6 flex items-center rounded-t-lg border p-6 text-sm">
+ <div>
+ <p className="text-default text-base font-semibold">{t("app_theme")}</p>
+ <p className="text-default">{t("app_theme_applies_note")}</p>
+ </div>
+ </div>
+ <Form
+ form={userAppThemeFormMethods}
+ handleSubmit={(values) => {
+ mutation.mutate({
+ appTheme: values.appTheme === "" ? null : values.appTheme,
+ });
+ }}>
+ <div className="border-subtle flex flex-col justify-between border-x px-6 py-8 sm:flex-row">
+ <ThemeLabel
+ variant="system"
+ value={undefined}
+ label={t("theme_system")}
+ defaultChecked={user.appTheme === null}
+ register={userAppThemeFormMethods.register}
+ fieldName="appTheme"
+ />
+ <ThemeLabel
+ variant="light"
+ value="light"
+ label={t("light")}
+ defaultChecked={user.appTheme === "light"}
+ register={userAppThemeFormMethods.register}
+ fieldName="appTheme"
+ />
+ <ThemeLabel
+ variant="dark"
+ value="dark"
+ label={t("dark")}
+ defaultChecked={user.appTheme === "dark"}
+ register={userAppThemeFormMethods.register}
+ fieldName="appTheme"
+ />
+ </div>
+ <SectionBottomActions className="mb-6" align="end">
+ <Button
+ disabled={isUserAppThemeSubmitting || !isUserAppThemeDirty}
+ type="submit"
+ data-testid="update-app-theme-btn"
+ color="primary">
+ {t("update")}
+ </Button>
+ </SectionBottomActions>
+ </Form>
+
+ {isApartOfOrganization ? null : (
+ <>
+ <div className="border-subtle mt-6 flex items-center rounded-t-lg border p-6 text-sm">
+ <div>
+ <p className="text-default text-base font-semibold">{t("theme")}</p>
+ <p className="text-default">{t("theme_applies_note")}</p>
+ </div>
+ </div>
+ <Form
+ form={userThemeFormMethods}
+ handleSubmit={(values) => {
+ mutation.mutate({
+ // Radio values don't support null as values, therefore we convert an empty string
+ // back to null here.
+ theme: values.theme === "" ? null : values.theme,
+ });
+ }}>
+ <div className="border-subtle flex flex-col justify-between border-x px-6 py-8 sm:flex-row">
+ <ThemeLabel
+ variant="system"
+ value={undefined}
+ label={t("theme_system")}
+ defaultChecked={user.theme === null}
+ register={userThemeFormMethods.register}
+ />
+ <ThemeLabel
+ variant="light"
+ value="light"
+ label={t("light")}
+ defaultChecked={user.theme === "light"}
+ register={userThemeFormMethods.register}
+ />
+ <ThemeLabel
+ variant="dark"
+ value="dark"
+ label={t("dark")}
+ defaultChecked={user.theme === "dark"}
+ register={userThemeFormMethods.register}
+ />
+ </div>
+ <SectionBottomActions className="mb-6" align="end">
+ <Button
+ loading={mutation.isPending}
+ disabled={isUserThemeSubmitting || !isUserThemeDirty}
+ type="submit"
+ data-testid="update-theme-btn"
+ color="primary">
+ {t("update")}
+ </Button>
+ </SectionBottomActions>
+ </Form>
+
+ <Form
+ form={bookerLayoutFormMethods}
+ handleSubmit={(values) => {
+ const layoutError = validateBookerLayouts(values?.metadata?.defaultBookerLayouts || null);
+ if (layoutError) {
+ showToast(t(layoutError), "error");
+ return;
+ } else {
+ mutation.mutate(values);
+ }
+ }}>
+ <BookerLayoutSelector
+ isDark={selectedThemeIsDark}
+ name="metadata.defaultBookerLayouts"
+ title={t("bookerlayout_user_settings_title")}
+ description={t("bookerlayout_user_settings_description")}
+ isDisabled={isBookerLayoutFormSubmitting || !isBookerLayoutFormDirty}
+ isLoading={mutation.isPending}
+ />
+ </Form>
+
+ <Form
+ form={brandColorsFormMethods}
+ handleSubmit={(values) => {
+ mutation.mutate(values);
+ }}>
+ <div className="mt-6">
+ <SettingsToggle
+ toggleSwitchAtTheEnd={true}
+ title={t("custom_brand_colors")}
+ description={t("customize_your_brand_colors")}
+ checked={isCustomBrandColorChecked}
+ onCheckedChange={(checked) => {
+ setIsCustomBranColorChecked(checked);
+ if (!checked) {
+ mutation.mutate({
+ brandColor: DEFAULT_LIGHT_BRAND_COLOR,
+ darkBrandColor: DEFAULT_DARK_BRAND_COLOR,
+ });
+ }
+ }}
+ childrenClassName="lg:ml-0">
+ <div className="border-subtle flex flex-col gap-6 border-x p-6">
+ <Controller
+ name="brandColor"
+ control={brandColorsFormMethods.control}
+ defaultValue={DEFAULT_BRAND_COLOURS.light}
+ render={() => (
+ <div>
+ <p className="text-default mb-2 block text-sm font-medium">
+ {t("light_brand_color")}
+ </p>
+ <ColorPicker
+ defaultValue={DEFAULT_BRAND_COLOURS.light}
+ resetDefaultValue={DEFAULT_LIGHT_BRAND_COLOR}
+ onChange={(value) => {
+ if (checkWCAGContrastColor("#ffffff", value)) {
+ setLightModeError(false);
+ } else {
+ setLightModeError(true);
+ }
+ brandColorsFormMethods.setValue("brandColor", value, { shouldDirty: true });
+ }}
+ />
+ {lightModeError ? (
+ <div className="mt-4">
+ <Alert severity="warning" message={t("light_theme_contrast_error")} />
+ </div>
+ ) : null}
+ </div>
+ )}
+ />
+
+ <Controller
+ name="darkBrandColor"
+ control={brandColorsFormMethods.control}
+ defaultValue={DEFAULT_BRAND_COLOURS.dark}
+ render={() => (
+ <div className="mt-6 sm:mt-0">
+ <p className="text-default mb-2 block text-sm font-medium">{t("dark_brand_color")}</p>
+ <ColorPicker
+ defaultValue={DEFAULT_BRAND_COLOURS.dark}
+ resetDefaultValue={DEFAULT_DARK_BRAND_COLOR}
+ onChange={(value) => {
+ if (checkWCAGContrastColor("#101010", value)) {
+ setDarkModeError(false);
+ } else {
+ setDarkModeError(true);
+ }
+ brandColorsFormMethods.setValue("darkBrandColor", value, { shouldDirty: true });
+ }}
+ />
+ {darkModeError ? (
+ <div className="mt-4">
+ <Alert severity="warning" message={t("dark_theme_contrast_error")} />
+ </div>
+ ) : null}
+ </div>
+ )}
+ />
+ </div>
+ <SectionBottomActions align="end">
+ <Button
+ loading={mutation.isPending}
+ disabled={isBrandColorsFormSubmitting || !isBrandColorsFormDirty}
+ color="primary"
+ type="submit">
+ {t("update")}
+ </Button>
+ </SectionBottomActions>
+ </SettingsToggle>
+ </div>
+ </Form>
+
+ {/* TODO future PR to preview brandColors */}
+ {/* <Button
+ color="secondary"
+ EndIcon="external-link"
+ className="mt-6"
+ onClick={() => window.open(`${WEBAPP_URL}/${user.username}/${user.eventTypes[0].title}`, "_blank")}>
+ Preview
+ </Button> */}
+
+ <SettingsToggle
+ toggleSwitchAtTheEnd={true}
+ title={t("disable_cal_branding", { appName: APP_NAME })}
+ disabled={!hasPaidPlan || mutation?.isPending}
+ description={t("removes_cal_branding", { appName: APP_NAME })}
+ checked={hasPaidPlan ? hideBrandingValue : false}
+ Badge={<UpgradeTeamsBadge />}
+ onCheckedChange={(checked) => {
+ setHideBrandingValue(checked);
+ mutation.mutate({ hideBranding: checked });
+ }}
+ switchContainerClassName="mt-6"
+ />
+ </>
+ )}
+ </div>
+ );
+};
+
+const AppearancePage = () => {
+ const { data: user, isPending } = trpc.viewer.me.useQuery();
+ const { isPending: isTeamPlanStatusLoading, hasPaidPlan } = useHasPaidPlan();
+
+ if (isPending || isTeamPlanStatusLoading || !user) return <SkeletonLoader />;
+
+ return <AppearanceView user={user} hasPaidPlan={hasPaidPlan} />;
+};
+
+export default AppearancePage;
diff --git a/apps/web/modules/settings/my-account/components/AddCalendarButton.tsx b/apps/web/modules/settings/my-account/components/AddCalendarButton.tsx
new file mode 100644
index 00000000000..5634683ef4a
--- /dev/null
+++ b/apps/web/modules/settings/my-account/components/AddCalendarButton.tsx
@@ -0,0 +1,18 @@
+"use client";
+
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { Button } from "@calcom/ui";
+
+const AddCalendarButton = () => {
+ const { t } = useLocale();
+
+ return (
+ <>
+ <Button color="secondary" StartIcon="plus" href="/apps/categories/calendar">
+ {t("add_calendar")}
+ </Button>
+ </>
+ );
+};
+
+export default AddCalendarButton;
diff --git a/apps/web/modules/settings/my-account/conferencing-view.tsx b/apps/web/modules/settings/my-account/conferencing-view.tsx
new file mode 100644
index 00000000000..8a765b95ef6
--- /dev/null
+++ b/apps/web/modules/settings/my-account/conferencing-view.tsx
@@ -0,0 +1,101 @@
+"use client";
+
+import { useReducer } from "react";
+
+import DisconnectIntegrationModal from "@calcom/features/apps/components/DisconnectIntegrationModal";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { trpc } from "@calcom/trpc/react";
+import { Button, EmptyScreen, SkeletonContainer, SkeletonText } from "@calcom/ui";
+
+import { QueryCell } from "@lib/QueryCell";
+
+import { AppList } from "@components/apps/AppList";
+
+const SkeletonLoader = () => {
+ return (
+ <SkeletonContainer>
+ <div className="divide-subtle border-subtle space-y-6 rounded-b-lg border border-t-0 px-6 py-4">
+ <SkeletonText className="h-8 w-full" />
+ <SkeletonText className="h-8 w-full" />
+ </div>
+ </SkeletonContainer>
+ );
+};
+
+type ModalState = {
+ isOpen: boolean;
+ credentialId: null | number;
+};
+
+const ConferencingView = () => {
+ const { t } = useLocale();
+
+ const [modal, updateModal] = useReducer(
+ (data: ModalState, partialData: Partial<ModalState>) => ({ ...data, ...partialData }),
+ {
+ isOpen: false,
+ credentialId: null,
+ }
+ );
+
+ const query = trpc.viewer.integrations.useQuery({
+ variant: "conferencing",
+ onlyInstalled: true,
+ });
+
+ const handleModelClose = () => {
+ updateModal({ isOpen: false, credentialId: null });
+ };
+
+ const handleDisconnect = (credentialId: number) => {
+ updateModal({ isOpen: true, credentialId });
+ };
+
+ return (
+ <>
+ <div className="bg-default w-full sm:mx-0 xl:mt-0">
+ <QueryCell
+ query={query}
+ customLoader={<SkeletonLoader />}
+ success={({ data }) => {
+ console.log(data);
+ if (!data.items.length) {
+ return (
+ <EmptyScreen
+ Icon="calendar"
+ headline={t("no_category_apps", {
+ category: t("conferencing").toLowerCase(),
+ })}
+ description={t("no_category_apps_description_conferencing")}
+ buttonRaw={
+ <Button
+ color="secondary"
+ data-testid="connect-conferencing-apps"
+ href="/apps/categories/conferencing">
+ {t("connect_conference_apps")}
+ </Button>
+ }
+ />
+ );
+ }
+ return (
+ <AppList
+ listClassName="rounded-lg rounded-t-none border-t-0 max-w-full"
+ handleDisconnect={handleDisconnect}
+ data={data}
+ variant="conferencing"
+ />
+ );
+ }}
+ />
+ </div>
+ <DisconnectIntegrationModal
+ handleModelClose={handleModelClose}
+ isOpen={modal.isOpen}
+ credentialId={modal.credentialId}
+ />
+ </>
+ );
+};
+
+export default ConferencingView;
diff --git a/apps/web/modules/settings/my-account/general-view.tsx b/apps/web/modules/settings/my-account/general-view.tsx
new file mode 100644
index 00000000000..da82bbecc85
--- /dev/null
+++ b/apps/web/modules/settings/my-account/general-view.tsx
@@ -0,0 +1,378 @@
+"use client";
+
+import { useSession } from "next-auth/react";
+import { useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+
+import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
+import { classNames } from "@calcom/lib";
+import { formatLocalizedDateTime } from "@calcom/lib/date-fns";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { localeOptions } from "@calcom/lib/i18n";
+import { nameOfDay } from "@calcom/lib/weekday";
+import type { RouterOutputs } from "@calcom/trpc/react";
+import { trpc } from "@calcom/trpc/react";
+import {
+ Button,
+ Form,
+ Label,
+ Select,
+ showToast,
+ SkeletonButton,
+ SkeletonContainer,
+ SkeletonText,
+ TimezoneSelect,
+ SettingsToggle,
+} from "@calcom/ui";
+
+import TravelScheduleModal from "@components/settings/TravelScheduleModal";
+
+export type FormValues = {
+ locale: {
+ value: string;
+ label: string;
+ };
+ timeZone: string;
+ timeFormat: {
+ value: number;
+ label: string | number;
+ };
+ weekStart: {
+ value: string;
+ label: string;
+ };
+ travelSchedules: {
+ id?: number;
+ startDate: Date;
+ endDate?: Date;
+ timeZone: string;
+ }[];
+};
+
+const SkeletonLoader = () => {
+ return (
+ <SkeletonContainer>
+ <div className="border-subtle space-y-6 rounded-b-xl border border-t-0 px-4 py-8 sm:px-6">
+ <SkeletonText className="h-8 w-full" />
+ <SkeletonText className="h-8 w-full" />
+ <SkeletonText className="h-8 w-full" />
+ <SkeletonText className="h-8 w-full" />
+
+ <SkeletonButton className="ml-auto h-8 w-20 rounded-md p-5" />
+ </div>
+ </SkeletonContainer>
+ );
+};
+
+interface GeneralViewProps {
+ localeProp: string;
+ user: RouterOutputs["viewer"]["me"];
+ travelSchedules: RouterOutputs["viewer"]["getTravelSchedules"];
+}
+
+const GeneralQueryView = () => {
+ const { t } = useLocale();
+
+ const { data: user, isPending } = trpc.viewer.me.useQuery();
+
+ const { data: travelSchedules, isPending: isPendingTravelSchedules } =
+ trpc.viewer.getTravelSchedules.useQuery();
+
+ if (isPending || isPendingTravelSchedules) return <SkeletonLoader />;
+ if (!user) {
+ throw new Error(t("something_went_wrong"));
+ }
+ return <GeneralView user={user} travelSchedules={travelSchedules || []} localeProp={user.locale} />;
+};
+
+const GeneralView = ({ localeProp, user, travelSchedules }: GeneralViewProps) => {
+ const utils = trpc.useContext();
+ const {
+ t,
+ i18n: { language },
+ } = useLocale();
+ const { update } = useSession();
+ const [isUpdateBtnLoading, setIsUpdateBtnLoading] = useState<boolean>(false);
+ const [isTZScheduleOpen, setIsTZScheduleOpen] = useState<boolean>(false);
+
+ const mutation = trpc.viewer.updateProfile.useMutation({
+ onSuccess: async (res) => {
+ await utils.viewer.me.invalidate();
+ reset(getValues());
+ showToast(t("settings_updated_successfully"), "success");
+ await update(res);
+
+ if (res.locale) {
+ window.calNewLocale = res.locale;
+ }
+ },
+ onError: () => {
+ showToast(t("error_updating_settings"), "error");
+ },
+ onSettled: async () => {
+ await utils.viewer.me.invalidate();
+ setIsUpdateBtnLoading(false);
+ },
+ });
+
+ const timeFormatOptions = [
+ { value: 12, label: t("12_hour") },
+ { value: 24, label: t("24_hour") },
+ ];
+
+ const weekStartOptions = [
+ { value: "Sunday", label: nameOfDay(localeProp, 0) },
+ { value: "Monday", label: nameOfDay(localeProp, 1) },
+ { value: "Tuesday", label: nameOfDay(localeProp, 2) },
+ { value: "Wednesday", label: nameOfDay(localeProp, 3) },
+ { value: "Thursday", label: nameOfDay(localeProp, 4) },
+ { value: "Friday", label: nameOfDay(localeProp, 5) },
+ { value: "Saturday", label: nameOfDay(localeProp, 6) },
+ ];
+
+ const formMethods = useForm<FormValues>({
+ defaultValues: {
+ locale: {
+ value: localeProp || "",
+ label: localeOptions.find((option) => option.value === localeProp)?.label || "",
+ },
+ timeZone: user.timeZone || "",
+ timeFormat: {
+ value: user.timeFormat || 12,
+ label: timeFormatOptions.find((option) => option.value === user.timeFormat)?.label || 12,
+ },
+ weekStart: {
+ value: user.weekStart,
+ label: nameOfDay(localeProp, user.weekStart === "Sunday" ? 0 : 1),
+ },
+ travelSchedules:
+ travelSchedules.map((schedule) => {
+ return {
+ id: schedule.id,
+ startDate: schedule.startDate,
+ endDate: schedule.endDate ?? undefined,
+ timeZone: schedule.timeZone,
+ };
+ }) || [],
+ },
+ });
+ const {
+ formState: { isDirty, isSubmitting },
+ reset,
+ getValues,
+ } = formMethods;
+ const isDisabled = isSubmitting || !isDirty;
+
+ const [isAllowDynamicBookingChecked, setIsAllowDynamicBookingChecked] = useState(
+ !!user.allowDynamicBooking
+ );
+ const [isAllowSEOIndexingChecked, setIsAllowSEOIndexingChecked] = useState(!!user.allowSEOIndexing);
+ const [isReceiveMonthlyDigestEmailChecked, setIsReceiveMonthlyDigestEmailChecked] = useState(
+ !!user.receiveMonthlyDigestEmail
+ );
+
+ const watchedTzSchedules = formMethods.watch("travelSchedules");
+
+ return (
+ <div>
+ <Form
+ form={formMethods}
+ handleSubmit={(values) => {
+ setIsUpdateBtnLoading(true);
+ mutation.mutate({
+ ...values,
+ locale: values.locale.value,
+ timeFormat: values.timeFormat.value,
+ weekStart: values.weekStart.value,
+ });
+ }}>
+ <div className="border-subtle border-x border-y-0 px-4 py-8 sm:px-6">
+ <Controller
+ name="locale"
+ render={({ field: { value, onChange } }) => (
+ <>
+ <Label className="text-emphasis">
+ <>{t("language")}</>
+ </Label>
+ <Select<{ label: string; value: string }>
+ className="capitalize"
+ options={localeOptions}
+ value={value}
+ onChange={onChange}
+ />
+ </>
+ )}
+ />
+ <Controller
+ name="timeZone"
+ control={formMethods.control}
+ render={({ field: { value } }) => (
+ <>
+ <Label className="text-emphasis mt-6">
+ <>{t("timezone")}</>
+ </Label>
+ <TimezoneSelect
+ id="timezone"
+ value={value}
+ onChange={(event) => {
+ if (event) formMethods.setValue("timeZone", event.value, { shouldDirty: true });
+ }}
+ />
+ </>
+ )}
+ />
+ {!watchedTzSchedules.length ? (
+ <Button color="minimal" className="mt-2" onClick={() => setIsTZScheduleOpen(true)}>
+ {t("schedule_timezone_change")}
+ </Button>
+ ) : (
+ <div className="bg-muted border-subtle mt-2 rounded-md border p-4">
+ <Label>{t("travel_schedule")}</Label>
+ <div className="dark:bg-darkgray-100 border-subtle mt-4 rounded-md border bg-white text-sm">
+ {watchedTzSchedules.map((schedule, index) => {
+ return (
+ <div
+ className={classNames(
+ "flex items-center p-4",
+ index !== 0 ? "border-subtle border-t" : ""
+ )}
+ key={index}>
+ <div>
+ <div className="text-emphasis font-semibold">{`${formatLocalizedDateTime(
+ schedule.startDate,
+ { day: "numeric", month: "long" },
+ language
+ )} ${
+ schedule.endDate
+ ? `- ${formatLocalizedDateTime(
+ schedule.endDate,
+ { day: "numeric", month: "long" },
+ language
+ )}`
+ : ``
+ }`}</div>
+ <div className="text-subtle">{schedule.timeZone.replace(/_/g, " ")}</div>
+ </div>
+ <Button
+ color="secondary"
+ className="ml-auto"
+ variant="icon"
+ StartIcon="trash-2"
+ onClick={() => {
+ const updatedSchedules = watchedTzSchedules.filter(
+ (s, filterIndex) => filterIndex !== index
+ );
+ formMethods.setValue("travelSchedules", updatedSchedules, { shouldDirty: true });
+ }}
+ />
+ </div>
+ );
+ })}
+ </div>
+ <Button
+ StartIcon="plus"
+ color="secondary"
+ className="mt-4"
+ onClick={() => setIsTZScheduleOpen(true)}>
+ {t("add")}
+ </Button>
+ </div>
+ )}
+
+ <Controller
+ name="timeFormat"
+ control={formMethods.control}
+ render={({ field: { value } }) => (
+ <>
+ <Label className="text-emphasis mt-6">
+ <>{t("time_format")}</>
+ </Label>
+ <Select
+ value={value}
+ options={timeFormatOptions}
+ onChange={(event) => {
+ if (event) formMethods.setValue("timeFormat", { ...event }, { shouldDirty: true });
+ }}
+ />
+ </>
+ )}
+ />
+ <div className="text-gray text-default mt-2 flex items-center text-sm">
+ {t("timeformat_profile_hint")}
+ </div>
+ <Controller
+ name="weekStart"
+ control={formMethods.control}
+ render={({ field: { value } }) => (
+ <>
+ <Label className="text-emphasis mt-6">
+ <>{t("start_of_week")}</>
+ </Label>
+ <Select
+ value={value}
+ options={weekStartOptions}
+ onChange={(event) => {
+ if (event) formMethods.setValue("weekStart", { ...event }, { shouldDirty: true });
+ }}
+ />
+ </>
+ )}
+ />
+ </div>
+
+ <SectionBottomActions align="end">
+ <Button loading={isUpdateBtnLoading} disabled={isDisabled} color="primary" type="submit">
+ <>{t("update")}</>
+ </Button>
+ </SectionBottomActions>
+ </Form>
+
+ <SettingsToggle
+ toggleSwitchAtTheEnd={true}
+ title={t("dynamic_booking")}
+ description={t("allow_dynamic_booking")}
+ disabled={mutation.isPending}
+ checked={isAllowDynamicBookingChecked}
+ onCheckedChange={(checked) => {
+ setIsAllowDynamicBookingChecked(checked);
+ mutation.mutate({ allowDynamicBooking: checked });
+ }}
+ switchContainerClassName="mt-6"
+ />
+
+ <SettingsToggle
+ toggleSwitchAtTheEnd={true}
+ title={t("seo_indexing")}
+ description={t("allow_seo_indexing")}
+ disabled={mutation.isPending}
+ checked={isAllowSEOIndexingChecked}
+ onCheckedChange={(checked) => {
+ setIsAllowSEOIndexingChecked(checked);
+ mutation.mutate({ allowSEOIndexing: checked });
+ }}
+ switchContainerClassName="mt-6"
+ />
+
+ <SettingsToggle
+ toggleSwitchAtTheEnd={true}
+ title={t("monthly_digest_email")}
+ description={t("monthly_digest_email_for_teams")}
+ disabled={mutation.isPending}
+ checked={isReceiveMonthlyDigestEmailChecked}
+ onCheckedChange={(checked) => {
+ setIsReceiveMonthlyDigestEmailChecked(checked);
+ mutation.mutate({ receiveMonthlyDigestEmail: checked });
+ }}
+ switchContainerClassName="mt-6"
+ />
+ <TravelScheduleModal
+ open={isTZScheduleOpen}
+ onOpenChange={() => setIsTZScheduleOpen(false)}
+ setValue={formMethods.setValue}
+ existingSchedules={formMethods.getValues("travelSchedules") ?? []}
+ />
+ </div>
+ );
+};
+
+export default GeneralQueryView;
diff --git a/apps/web/modules/settings/my-account/profile-view.tsx b/apps/web/modules/settings/my-account/profile-view.tsx
new file mode 100644
index 00000000000..c737c3cd26e
--- /dev/null
+++ b/apps/web/modules/settings/my-account/profile-view.tsx
@@ -0,0 +1,730 @@
+"use client";
+
+import { zodResolver } from "@hookform/resolvers/zod";
+// eslint-disable-next-line no-restricted-imports
+import { get, pick } from "lodash";
+import { signOut, useSession } from "next-auth/react";
+import type { BaseSyntheticEvent } from "react";
+import React, { useRef, useState } from "react";
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { z } from "zod";
+
+import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
+import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
+import { APP_NAME, FULL_NAME_LENGTH_MAX_LIMIT } from "@calcom/lib/constants";
+import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { md } from "@calcom/lib/markdownIt";
+import turndown from "@calcom/lib/turndownService";
+import { IdentityProvider } from "@calcom/prisma/enums";
+import type { TRPCClientErrorLike } from "@calcom/trpc/client";
+import type { RouterOutputs } from "@calcom/trpc/react";
+import { trpc } from "@calcom/trpc/react";
+import type { AppRouter } from "@calcom/trpc/server/routers/_app";
+import {
+ Alert,
+ Button,
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogFooter,
+ DialogTrigger,
+ Editor,
+ Form,
+ ImageUploader,
+ Label,
+ PasswordField,
+ showToast,
+ SkeletonAvatar,
+ SkeletonButton,
+ SkeletonContainer,
+ SkeletonText,
+ TextField,
+ UserAvatar,
+} from "@calcom/ui";
+
+import TwoFactor from "@components/auth/TwoFactor";
+import CustomEmailTextField from "@components/settings/CustomEmailTextField";
+import SecondaryEmailConfirmModal from "@components/settings/SecondaryEmailConfirmModal";
+import SecondaryEmailModal from "@components/settings/SecondaryEmailModal";
+import { UsernameAvailabilityField } from "@components/ui/UsernameAvailability";
+
+const SkeletonLoader = () => {
+ return (
+ <SkeletonContainer>
+ <div className="border-subtle space-y-6 rounded-b-lg border border-t-0 px-4 py-8">
+ <div className="flex items-center">
+ <SkeletonAvatar className="me-4 mt-0 h-16 w-16 px-4" />
+ <SkeletonButton className="h-6 w-32 rounded-md p-5" />
+ </div>
+ <SkeletonText className="h-8 w-full" />
+ <SkeletonText className="h-8 w-full" />
+ <SkeletonText className="h-8 w-full" />
+
+ <SkeletonButton className="mr-6 h-8 w-20 rounded-md p-5" />
+ </div>
+ </SkeletonContainer>
+ );
+};
+
+interface DeleteAccountValues {
+ totpCode: string;
+}
+
+type Email = {
+ id: number;
+ email: string;
+ emailVerified: string | null;
+ emailPrimary: boolean;
+};
+
+export type FormValues = {
+ username: string;
+ avatarUrl: string | null;
+ name: string;
+ email: string;
+ bio: string;
+ secondaryEmails: Email[];
+};
+
+const ProfileView = () => {
+ const { t } = useLocale();
+ const utils = trpc.useUtils();
+ const { update } = useSession();
+ const { data: user, isPending } = trpc.viewer.me.useQuery({ includePasswordAdded: true });
+
+ const updateProfileMutation = trpc.viewer.updateProfile.useMutation({
+ onSuccess: async (res) => {
+ await update(res);
+ utils.viewer.me.invalidate();
+ utils.viewer.shouldVerifyEmail.invalidate();
+
+ if (res.hasEmailBeenChanged && res.sendEmailVerification) {
+ showToast(t("change_of_email_toast", { email: tempFormValues?.email }), "success");
+ } else {
+ showToast(t("settings_updated_successfully"), "success");
+ }
+
+ setTempFormValues(null);
+ },
+ onError: (e) => {
+ switch (e.message) {
+ // TODO: Add error codes.
+ case "email_already_used":
+ {
+ showToast(t(e.message), "error");
+ }
+ return;
+ default:
+ showToast(t("error_updating_settings"), "error");
+ }
+ },
+ });
+ const unlinkConnectedAccountMutation = trpc.viewer.unlinkConnectedAccount.useMutation({
+ onSuccess: async (res) => {
+ showToast(t(res.message), "success");
+ utils.viewer.me.invalidate();
+ },
+ onError: (e) => {
+ showToast(t(e.message), "error");
+ },
+ });
+
+ const addSecondaryEmailMutation = trpc.viewer.addSecondaryEmail.useMutation({
+ onSuccess: (res) => {
+ setShowSecondaryEmailModalOpen(false);
+ setNewlyAddedSecondaryEmail(res?.data?.email);
+ utils.viewer.me.invalidate();
+ },
+ onError: (error) => {
+ setSecondaryEmailAddErrorMessage(error?.message || "");
+ },
+ });
+
+ const resendVerifyEmailMutation = trpc.viewer.auth.resendVerifyEmail.useMutation();
+
+ const [confirmPasswordOpen, setConfirmPasswordOpen] = useState(false);
+ const [tempFormValues, setTempFormValues] = useState<ExtendedFormValues | null>(null);
+ const [confirmPasswordErrorMessage, setConfirmPasswordDeleteErrorMessage] = useState("");
+ const [showCreateAccountPasswordDialog, setShowCreateAccountPasswordDialog] = useState(false);
+ const [showAccountDisconnectWarning, setShowAccountDisconnectWarning] = useState(false);
+ const [showSecondaryEmailModalOpen, setShowSecondaryEmailModalOpen] = useState(false);
+ const [secondaryEmailAddErrorMessage, setSecondaryEmailAddErrorMessage] = useState("");
+ const [newlyAddedSecondaryEmail, setNewlyAddedSecondaryEmail] = useState<undefined | string>(undefined);
+
+ const [deleteAccountOpen, setDeleteAccountOpen] = useState(false);
+ const [hasDeleteErrors, setHasDeleteErrors] = useState(false);
+ const [deleteErrorMessage, setDeleteErrorMessage] = useState("");
+ const form = useForm<DeleteAccountValues>();
+
+ const onDeleteMeSuccessMutation = async () => {
+ await utils.viewer.me.invalidate();
+ showToast(t("Your account was deleted"), "success");
+
+ setHasDeleteErrors(false); // dismiss any open errors
+ if (process.env.NEXT_PUBLIC_WEBAPP_URL === "https://app.cal.com") {
+ signOut({ callbackUrl: "/auth/logout?survey=true" });
+ } else {
+ signOut({ callbackUrl: "/auth/logout" });
+ }
+ };
+
+ const confirmPasswordMutation = trpc.viewer.auth.verifyPassword.useMutation({
+ onSuccess() {
+ if (tempFormValues) updateProfileMutation.mutate(tempFormValues);
+ setConfirmPasswordOpen(false);
+ },
+ onError() {
+ setConfirmPasswordDeleteErrorMessage(t("incorrect_password"));
+ },
+ });
+
+ const onDeleteMeErrorMutation = (error: TRPCClientErrorLike<AppRouter>) => {
+ setHasDeleteErrors(true);
+ setDeleteErrorMessage(errorMessages[error.message]);
+ };
+ const deleteMeMutation = trpc.viewer.deleteMe.useMutation({
+ onSuccess: onDeleteMeSuccessMutation,
+ onError: onDeleteMeErrorMutation,
+ async onSettled() {
+ await utils.viewer.me.invalidate();
+ },
+ });
+ const deleteMeWithoutPasswordMutation = trpc.viewer.deleteMeWithoutPassword.useMutation({
+ onSuccess: onDeleteMeSuccessMutation,
+ onError: onDeleteMeErrorMutation,
+ async onSettled() {
+ await utils.viewer.me.invalidate();
+ },
+ });
+
+ const isCALIdentityProvider = user?.identityProvider === IdentityProvider.CAL;
+
+ const onConfirmPassword = (e: Event | React.MouseEvent<HTMLElement, MouseEvent>) => {
+ e.preventDefault();
+
+ const password = passwordRef.current.value;
+ confirmPasswordMutation.mutate({ passwordInput: password });
+ };
+
+ const onConfirmButton = (e: Event | React.MouseEvent<HTMLElement, MouseEvent>) => {
+ e.preventDefault();
+ if (isCALIdentityProvider) {
+ const totpCode = form.getValues("totpCode");
+ const password = passwordRef.current.value;
+ deleteMeMutation.mutate({ password, totpCode });
+ } else {
+ deleteMeWithoutPasswordMutation.mutate();
+ }
+ };
+
+ const onConfirm = ({ totpCode }: DeleteAccountValues, e: BaseSyntheticEvent | undefined) => {
+ e?.preventDefault();
+ if (isCALIdentityProvider) {
+ const password = passwordRef.current.value;
+ deleteMeMutation.mutate({ password, totpCode });
+ } else {
+ deleteMeWithoutPasswordMutation.mutate();
+ }
+ };
+
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ const passwordRef = useRef<HTMLInputElement>(null!);
+
+ const errorMessages: { [key: string]: string } = {
+ [ErrorCode.SecondFactorRequired]: t("2fa_enabled_instructions"),
+ [ErrorCode.IncorrectPassword]: `${t("incorrect_password")} ${t("please_try_again")}`,
+ [ErrorCode.UserNotFound]: t("no_account_exists"),
+ [ErrorCode.IncorrectTwoFactorCode]: `${t("incorrect_2fa_code")} ${t("please_try_again")}`,
+ [ErrorCode.InternalServerError]: `${t("something_went_wrong")} ${t("please_try_again_and_contact_us")}`,
+ [ErrorCode.ThirdPartyIdentityProviderEnabled]: t("account_created_with_identity_provider"),
+ };
+
+ if (isPending || !user) {
+ return <SkeletonLoader />;
+ }
+
+ const userEmail = user.email || "";
+ const defaultValues = {
+ username: user.username || "",
+ avatarUrl: user.avatarUrl,
+ name: user.name || "",
+ email: userEmail,
+ bio: user.bio || "",
+ // We add the primary email as the first item in the list
+ secondaryEmails: [
+ {
+ id: 0,
+ email: userEmail,
+ emailVerified: user.emailVerified?.toString() || null,
+ emailPrimary: true,
+ },
+ ...(user.secondaryEmails || []).map((secondaryEmail) => ({
+ ...secondaryEmail,
+ emailVerified: secondaryEmail.emailVerified?.toString() || null,
+ emailPrimary: false,
+ })),
+ ],
+ };
+
+ return (
+ <>
+ <ProfileForm
+ key={JSON.stringify(defaultValues)}
+ defaultValues={defaultValues}
+ isPending={updateProfileMutation.isPending}
+ isFallbackImg={!user.avatarUrl}
+ user={user}
+ userOrganization={user.organization}
+ onSubmit={(values) => {
+ if (values.email !== user.email && isCALIdentityProvider) {
+ setTempFormValues(values);
+ setConfirmPasswordOpen(true);
+ } else {
+ updateProfileMutation.mutate(values);
+ }
+ }}
+ handleAddSecondaryEmail={() => setShowSecondaryEmailModalOpen(true)}
+ handleResendVerifyEmail={(email) => {
+ resendVerifyEmailMutation.mutate({ email });
+ showToast(t("email_sent"), "success");
+ }}
+ handleAccountDisconnect={(values) => {
+ if (isCALIdentityProvider) return;
+ if (user?.passwordAdded) {
+ setTempFormValues(values);
+ setShowAccountDisconnectWarning(true);
+ return;
+ }
+ setShowCreateAccountPasswordDialog(true);
+ }}
+ extraField={
+ <div className="mt-6">
+ <UsernameAvailabilityField
+ onSuccessMutation={async () => {
+ showToast(t("settings_updated_successfully"), "success");
+ await utils.viewer.me.invalidate();
+ }}
+ onErrorMutation={() => {
+ showToast(t("error_updating_settings"), "error");
+ }}
+ />
+ </div>
+ }
+ isCALIdentityProvider={isCALIdentityProvider}
+ />
+
+ <div className="border-subtle mt-6 rounded-lg rounded-b-none border border-b-0 p-6">
+ <Label className="mb-0 text-base font-semibold text-red-700">{t("danger_zone")}</Label>
+ <p className="text-subtle text-sm">{t("account_deletion_cannot_be_undone")}</p>
+ </div>
+ {/* Delete account Dialog */}
+ <Dialog open={deleteAccountOpen} onOpenChange={setDeleteAccountOpen}>
+ <SectionBottomActions align="end">
+ <DialogTrigger asChild>
+ <Button data-testid="delete-account" color="destructive" className="mt-1" StartIcon="trash-2">
+ {t("delete_account")}
+ </Button>
+ </DialogTrigger>
+ </SectionBottomActions>
+ <DialogContent
+ title={t("delete_account_modal_title")}
+ description={t("confirm_delete_account_modal", { appName: APP_NAME })}
+ type="creation"
+ Icon="triangle-alert">
+ <>
+ <div className="mb-10">
+ <p className="text-default mb-4">{t("delete_account_confirmation_message")}</p>
+ {isCALIdentityProvider && (
+ <PasswordField
+ data-testid="password"
+ name="password"
+ id="password"
+ autoComplete="current-password"
+ required
+ label="Password"
+ ref={passwordRef}
+ />
+ )}
+
+ {user?.twoFactorEnabled && isCALIdentityProvider && (
+ <Form handleSubmit={onConfirm} className="pb-4" form={form}>
+ <TwoFactor center={false} />
+ </Form>
+ )}
+
+ {hasDeleteErrors && <Alert severity="error" title={deleteErrorMessage} />}
+ </div>
+ <DialogFooter showDivider>
+ <DialogClose />
+ <Button
+ color="primary"
+ data-testid="delete-account-confirm"
+ onClick={(e) => onConfirmButton(e)}>
+ {t("delete_my_account")}
+ </Button>
+ </DialogFooter>
+ </>
+ </DialogContent>
+ </Dialog>
+
+ {/* If changing email, confirm password */}
+ <Dialog open={confirmPasswordOpen} onOpenChange={setConfirmPasswordOpen}>
+ <DialogContent
+ title={t("confirm_password")}
+ description={t("confirm_password_change_email")}
+ type="creation"
+ Icon="triangle-alert">
+ <div className="mb-10">
+ <div className="mb-4 grid gap-2 md:grid-cols-2">
+ <div>
+ <span className="text-emphasis mb-2 block text-sm font-medium leading-none">
+ {t("old_email_address")}
+ </span>
+ <p className="text-subtle leading-none">{user.email}</p>
+ </div>
+ <div>
+ <span className="text-emphasis mb-2 block text-sm font-medium leading-none">
+ {t("new_email_address")}
+ </span>
+ <p className="text-subtle leading-none">{tempFormValues?.email}</p>
+ </div>
+ </div>
+ <PasswordField
+ data-testid="password"
+ name="password"
+ id="password"
+ autoComplete="current-password"
+ required
+ label="Password"
+ ref={passwordRef}
+ />
+
+ {confirmPasswordErrorMessage && <Alert severity="error" title={confirmPasswordErrorMessage} />}
+ </div>
+ <DialogFooter showDivider>
+ <Button
+ data-testid="profile-update-email-submit-button"
+ color="primary"
+ loading={confirmPasswordMutation.isPending}
+ onClick={(e) => onConfirmPassword(e)}>
+ {t("confirm")}
+ </Button>
+ <DialogClose />
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+
+ <Dialog open={showCreateAccountPasswordDialog} onOpenChange={setShowCreateAccountPasswordDialog}>
+ <DialogContent
+ title={t("create_account_password")}
+ description={t("create_account_password_hint")}
+ type="creation"
+ Icon="triangle-alert">
+ <DialogFooter>
+ <DialogClose />
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+
+ <Dialog open={showAccountDisconnectWarning} onOpenChange={setShowAccountDisconnectWarning}>
+ <DialogContent
+ title={t("disconnect_account")}
+ description={t("disconnect_account_hint")}
+ type="creation"
+ Icon="triangle-alert">
+ <DialogFooter>
+ <Button
+ color="primary"
+ onClick={() => {
+ unlinkConnectedAccountMutation.mutate();
+ setShowAccountDisconnectWarning(false);
+ }}>
+ {t("confirm")}
+ </Button>
+ <DialogClose />
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+
+ {showSecondaryEmailModalOpen && (
+ <SecondaryEmailModal
+ isLoading={addSecondaryEmailMutation.isPending}
+ errorMessage={secondaryEmailAddErrorMessage}
+ handleAddEmail={(values) => {
+ setSecondaryEmailAddErrorMessage("");
+ addSecondaryEmailMutation.mutate(values);
+ }}
+ onCancel={() => {
+ setSecondaryEmailAddErrorMessage("");
+ setShowSecondaryEmailModalOpen(false);
+ }}
+ clearErrorMessage={() => {
+ addSecondaryEmailMutation.reset();
+ setSecondaryEmailAddErrorMessage("");
+ }}
+ />
+ )}
+ {!!newlyAddedSecondaryEmail && (
+ <SecondaryEmailConfirmModal
+ email={newlyAddedSecondaryEmail}
+ onCancel={() => setNewlyAddedSecondaryEmail(undefined)}
+ />
+ )}
+ </>
+ );
+};
+
+type SecondaryEmailApiPayload = {
+ id: number;
+ email: string;
+ isDeleted: boolean;
+};
+
+type ExtendedFormValues = Omit<FormValues, "secondaryEmails"> & {
+ secondaryEmails: SecondaryEmailApiPayload[];
+};
+
+const ProfileForm = ({
+ defaultValues,
+ onSubmit,
+ handleAddSecondaryEmail,
+ handleResendVerifyEmail,
+ handleAccountDisconnect,
+ extraField,
+ isPending = false,
+ isFallbackImg,
+ user,
+ userOrganization,
+ isCALIdentityProvider,
+}: {
+ defaultValues: FormValues;
+ onSubmit: (values: ExtendedFormValues) => void;
+ handleAddSecondaryEmail: () => void;
+ handleResendVerifyEmail: (email: string) => void;
+ handleAccountDisconnect: (values: ExtendedFormValues) => void;
+ extraField?: React.ReactNode;
+ isPending: boolean;
+ isFallbackImg: boolean;
+ user: RouterOutputs["viewer"]["me"];
+ userOrganization: RouterOutputs["viewer"]["me"]["organization"];
+ isCALIdentityProvider: boolean;
+}) => {
+ const { t } = useLocale();
+ const [firstRender, setFirstRender] = useState(true);
+
+ const profileFormSchema = z.object({
+ username: z.string(),
+ avatarUrl: z.string().nullable(),
+ name: z
+ .string()
+ .trim()
+ .min(1, t("you_need_to_add_a_name"))
+ .max(FULL_NAME_LENGTH_MAX_LIMIT, {
+ message: t("max_limit_allowed_hint", { limit: FULL_NAME_LENGTH_MAX_LIMIT }),
+ }),
+ email: z.string().email(),
+ bio: z.string(),
+ secondaryEmails: z.array(
+ z.object({
+ id: z.number(),
+ email: z.string().email(),
+ emailVerified: z.union([z.string(), z.null()]).optional(),
+ emailPrimary: z.boolean().optional(),
+ })
+ ),
+ });
+
+ const formMethods = useForm<FormValues>({
+ defaultValues,
+ resolver: zodResolver(profileFormSchema),
+ });
+
+ const {
+ fields: secondaryEmailFields,
+ remove: deleteSecondaryEmail,
+ replace: updateAllSecondaryEmailFields,
+ } = useFieldArray({
+ control: formMethods.control,
+ name: "secondaryEmails",
+ keyName: "itemId",
+ });
+
+ const getUpdatedFormValues = (values: FormValues) => {
+ const changedFields = formMethods.formState.dirtyFields?.secondaryEmails || [];
+ const updatedValues: FormValues = {
+ ...values,
+ };
+
+ // If the primary email is changed, we will need to update
+ const primaryEmailIndex = updatedValues.secondaryEmails.findIndex(
+ (secondaryEmail) => secondaryEmail.emailPrimary
+ );
+ if (primaryEmailIndex >= 0) {
+ // Add the new updated value as primary email
+ updatedValues.email = updatedValues.secondaryEmails[primaryEmailIndex].email;
+ }
+
+ // We will only send the emails which have already changed
+ const updatedEmails: Email[] = [];
+ changedFields.map((field, index) => {
+ // If the email changed and if its only secondary email, we add it for updation, the first
+ // item in the list is always primary email
+ if (field?.email && updatedValues.secondaryEmails[index]?.id) {
+ updatedEmails.push(updatedValues.secondaryEmails[index]);
+ }
+ });
+
+ const deletedEmails = (user?.secondaryEmails || []).filter(
+ (secondaryEmail) => !updatedValues.secondaryEmails.find((val) => val.id && val.id === secondaryEmail.id)
+ );
+ const secondaryEmails = [
+ ...updatedEmails.map((email) => ({ ...email, isDeleted: false })),
+ ...deletedEmails.map((email) => ({ ...email, isDeleted: true })),
+ ].map((secondaryEmail) => pick(secondaryEmail, ["id", "email", "isDeleted"]));
+
+ return {
+ ...updatedValues,
+ secondaryEmails,
+ };
+ };
+
+ const handleFormSubmit = (values: FormValues) => {
+ onSubmit(getUpdatedFormValues(values));
+ };
+
+ const onDisconnect = () => {
+ handleAccountDisconnect(getUpdatedFormValues(formMethods.getValues()));
+ };
+
+ const {
+ formState: { isSubmitting, isDirty },
+ } = formMethods;
+
+ const isDisabled = isSubmitting || !isDirty;
+ return (
+ <Form form={formMethods} handleSubmit={handleFormSubmit}>
+ <div className="border-subtle border-x px-4 pb-10 pt-8 sm:px-6">
+ <div className="flex items-center">
+ <Controller
+ control={formMethods.control}
+ name="avatarUrl"
+ render={({ field: { value, onChange } }) => {
+ const showRemoveAvatarButton = value !== null;
+ return (
+ <>
+ <UserAvatar data-testid="profile-upload-avatar" previewSrc={value} size="lg" user={user} />
+ <div className="ms-4">
+ <h2 className="mb-2 text-sm font-medium">{t("profile_picture")}</h2>
+ <div className="flex gap-2">
+ <ImageUploader
+ target="avatar"
+ id="avatar-upload"
+ buttonMsg={t("upload_avatar")}
+ handleAvatarChange={(newAvatar) => {
+ onChange(newAvatar);
+ }}
+ imageSrc={getUserAvatarUrl({ avatarUrl: value })}
+ triggerButtonColor={showRemoveAvatarButton ? "secondary" : "primary"}
+ />
+
+ {showRemoveAvatarButton && (
+ <Button
+ color="destructive"
+ onClick={() => {
+ onChange(null);
+ }}>
+ {t("remove")}
+ </Button>
+ )}
+ </div>
+ </div>
+ </>
+ );
+ }}
+ />
+ </div>
+ {extraField}
+ <div className="mt-6">
+ <TextField label={t("full_name")} {...formMethods.register("name")} />
+ </div>
+ <div className="mt-6">
+ <Label>{t("email")}</Label>
+ {secondaryEmailFields.map((field, index) => (
+ <CustomEmailTextField
+ key={field.itemId}
+ formMethods={formMethods}
+ formMethodFieldName={`secondaryEmails.${index}.email` as keyof FormValues}
+ errorMessage={get(formMethods.formState.errors, `secondaryEmails.${index}.email.message`)}
+ emailVerified={Boolean(field.emailVerified)}
+ emailPrimary={field.emailPrimary}
+ dataTestId={`profile-form-email-${index}`}
+ handleChangePrimary={() => {
+ const fields = secondaryEmailFields.map((secondaryField, cIndex) => ({
+ ...secondaryField,
+ emailPrimary: cIndex === index,
+ }));
+ updateAllSecondaryEmailFields(fields);
+ }}
+ handleVerifyEmail={() => handleResendVerifyEmail(field.email)}
+ handleItemDelete={() => deleteSecondaryEmail(index)}
+ />
+ ))}
+ <div className="text-default mt-2 flex items-center text-sm">{t("change_email_hint")}</div>
+ <Button
+ color="minimal"
+ StartIcon="plus"
+ className="mt-2"
+ onClick={() => handleAddSecondaryEmail()}
+ data-testid="add-secondary-email">
+ {t("add_email")}
+ </Button>
+ </div>
+ <div className="mt-6">
+ <Label>{t("about")}</Label>
+ <Editor
+ getText={() => md.render(formMethods.getValues("bio") || "")}
+ setText={(value: string) => {
+ formMethods.setValue("bio", turndown(value), { shouldDirty: true });
+ }}
+ excludedToolbarItems={["blockType"]}
+ disableLists
+ firstRender={firstRender}
+ setFirstRender={setFirstRender}
+ height="80px"
+ />
+ </div>
+ {/* // For Non-Cal indentities, we merge the values from DB and the user logging in,
+ so essentially there is no point in allowing them to disconnect, since when they log in they will get logged into the same account */}
+ {!isCALIdentityProvider && user.email !== user.identityProviderEmail && (
+ <div className="mt-6">
+ <Label>Connected accounts</Label>
+ <div className="flex items-center">
+ <span className="text-default text-sm capitalize">{user.identityProvider.toLowerCase()}</span>
+ {user.identityProviderEmail && (
+ <span className="text-default ml-2 text-sm">{user.identityProviderEmail}</span>
+ )}
+ <div className="flex flex-1 justify-end">
+ <Button color="destructive" onClick={onDisconnect}>
+ {t("disconnect")}
+ </Button>
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
+ <SectionBottomActions align="end">
+ <Button
+ loading={isPending}
+ disabled={isDisabled}
+ color="primary"
+ type="submit"
+ data-testid="profile-submit-button">
+ {t("update")}
+ </Button>
+ </SectionBottomActions>
+ </Form>
+ );
+};
+
+export default ProfileView;
diff --git a/apps/web/modules/settings/security/impersonation-view.tsx b/apps/web/modules/settings/security/impersonation-view.tsx
new file mode 100644
index 00000000000..3e3d8bd287a
--- /dev/null
+++ b/apps/web/modules/settings/security/impersonation-view.tsx
@@ -0,0 +1,77 @@
+"use client";
+
+import { useState } from "react";
+
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { trpc } from "@calcom/trpc/react";
+import type { RouterOutputs } from "@calcom/trpc/react";
+import { showToast, SettingsToggle, SkeletonContainer, SkeletonText } from "@calcom/ui";
+
+const SkeletonLoader = () => {
+ return (
+ <SkeletonContainer>
+ <div className="border-subtle space-y-6 border border-t-0 px-4 py-8 sm:px-6">
+ <SkeletonText className="h-8 w-full" />
+ </div>
+ </SkeletonContainer>
+ );
+};
+
+const ProfileImpersonationView = ({ user }: { user: RouterOutputs["viewer"]["me"] }) => {
+ const { t } = useLocale();
+ const utils = trpc.useUtils();
+ const [disableImpersonation, setDisableImpersonation] = useState<boolean | undefined>(
+ user?.disableImpersonation
+ );
+
+ const mutation = trpc.viewer.updateProfile.useMutation({
+ onSuccess: () => {
+ showToast(t("profile_updated_successfully"), "success");
+ },
+ onSettled: () => {
+ utils.viewer.me.invalidate();
+ },
+ onMutate: async ({ disableImpersonation }) => {
+ await utils.viewer.me.cancel();
+ const previousValue = utils.viewer.me.getData();
+
+ setDisableImpersonation(disableImpersonation);
+
+ return { previousValue };
+ },
+ onError: (error, variables, context) => {
+ if (context?.previousValue) {
+ utils.viewer.me.setData(undefined, context.previousValue);
+ setDisableImpersonation(context.previousValue?.disableImpersonation);
+ }
+ showToast(`${t("error")}, ${error.message}`, "error");
+ },
+ });
+
+ return (
+ <>
+ <div>
+ <SettingsToggle
+ toggleSwitchAtTheEnd={true}
+ title={t("user_impersonation_heading")}
+ description={t("user_impersonation_description")}
+ checked={!disableImpersonation}
+ onCheckedChange={(checked) => {
+ mutation.mutate({ disableImpersonation: !checked });
+ }}
+ switchContainerClassName="rounded-t-none border-t-0"
+ disabled={mutation.isPending}
+ />
+ </div>
+ </>
+ );
+};
+
+const ProfileImpersonationViewWrapper = () => {
+ const { data: user, isPending } = trpc.viewer.me.useQuery();
+ if (isPending || !user) return <SkeletonLoader />;
+
+ return <ProfileImpersonationView user={user} />;
+};
+
+export default ProfileImpersonationViewWrapper;
diff --git a/apps/web/modules/settings/security/password-view.tsx b/apps/web/modules/settings/security/password-view.tsx
new file mode 100644
index 00000000000..48106836e1c
--- /dev/null
+++ b/apps/web/modules/settings/security/password-view.tsx
@@ -0,0 +1,315 @@
+"use client";
+
+import { signOut, useSession } from "next-auth/react";
+import { useState } from "react";
+import { useForm } from "react-hook-form";
+
+import { identityProviderNameMap } from "@calcom/features/auth/lib/identityProviderNameMap";
+import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
+import { classNames } from "@calcom/lib";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { IdentityProvider } from "@calcom/prisma/enums";
+import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils";
+import type { RouterOutputs } from "@calcom/trpc/react";
+import { trpc } from "@calcom/trpc/react";
+import {
+ Alert,
+ Button,
+ Form,
+ PasswordField,
+ Select,
+ SettingsToggle,
+ showToast,
+ SkeletonButton,
+ SkeletonContainer,
+ SkeletonText,
+} from "@calcom/ui";
+
+type ChangePasswordSessionFormValues = {
+ oldPassword: string;
+ newPassword: string;
+ sessionTimeout?: number;
+ apiError: string;
+};
+
+interface PasswordViewProps {
+ user: RouterOutputs["viewer"]["me"];
+}
+
+const SkeletonLoader = () => {
+ return (
+ <SkeletonContainer>
+ <div className="border-subtle space-y-6 border-x px-4 py-8 sm:px-6">
+ <SkeletonText className="h-8 w-full" />
+ <SkeletonText className="h-8 w-full" />
+ <SkeletonText className="h-8 w-full" />
+ </div>
+ <div className="rounded-b-xl">
+ <SectionBottomActions align="end">
+ <SkeletonButton className="ml-auto h-8 w-20 rounded-md" />
+ </SectionBottomActions>
+ </div>
+ </SkeletonContainer>
+ );
+};
+
+const PasswordView = ({ user }: PasswordViewProps) => {
+ const { data } = useSession();
+ const { t } = useLocale();
+ const utils = trpc.useUtils();
+ const metadata = userMetadataSchema.safeParse(user?.metadata);
+ const initialSessionTimeout = metadata.success ? metadata.data?.sessionTimeout : undefined;
+
+ const [sessionTimeout, setSessionTimeout] = useState<number | undefined>(initialSessionTimeout);
+
+ const sessionMutation = trpc.viewer.updateProfile.useMutation({
+ onSuccess: (data) => {
+ showToast(t("session_timeout_changed"), "success");
+ formMethods.reset(formMethods.getValues());
+ setSessionTimeout(data.metadata?.sessionTimeout);
+ },
+ onSettled: () => {
+ utils.viewer.me.invalidate();
+ },
+ onMutate: async () => {
+ await utils.viewer.me.cancel();
+ const previousValue = await utils.viewer.me.getData();
+ const previousMetadata = userMetadataSchema.safeParse(previousValue?.metadata);
+
+ if (previousValue && sessionTimeout && previousMetadata.success) {
+ utils.viewer.me.setData(undefined, {
+ ...previousValue,
+ metadata: { ...previousMetadata?.data, sessionTimeout: sessionTimeout },
+ });
+ return { previousValue };
+ }
+ },
+ onError: (error, _, context) => {
+ if (context?.previousValue) {
+ utils.viewer.me.setData(undefined, context.previousValue);
+ }
+ showToast(`${t("session_timeout_change_error")}, ${error.message}`, "error");
+ },
+ });
+ const passwordMutation = trpc.viewer.auth.changePassword.useMutation({
+ onSuccess: () => {
+ showToast(t("password_has_been_changed"), "success");
+ formMethods.resetField("oldPassword");
+ formMethods.resetField("newPassword");
+
+ if (data?.user.role === "INACTIVE_ADMIN") {
+ /*
+ AdminPasswordBanner component relies on the role returned from the session.
+ Next-Auth doesn't provide a way to revalidate the session cookie,
+ so this a workaround to hide the banner after updating the password.
+ discussion: https://github.com/nextauthjs/next-auth/discussions/4229
+ */
+ signOut({ callbackUrl: "/auth/login" });
+ }
+ },
+ onError: (error) => {
+ showToast(`${t("error_updating_password")}, ${t(error.message)}`, "error");
+
+ formMethods.setError("apiError", {
+ message: t(error.message),
+ type: "custom",
+ });
+ },
+ });
+
+ const createAccountPasswordMutation = trpc.viewer.auth.createAccountPassword.useMutation({
+ onSuccess: () => {
+ showToast(t("password_reset_email", { email: user.email }), "success");
+ },
+ onError: (error) => {
+ showToast(`${t("error_creating_account_password")}, ${t(error.message)}`, "error");
+ },
+ });
+
+ const formMethods = useForm<ChangePasswordSessionFormValues>({
+ defaultValues: {
+ oldPassword: "",
+ newPassword: "",
+ },
+ });
+
+ const handleSubmit = (values: ChangePasswordSessionFormValues) => {
+ const { oldPassword, newPassword } = values;
+
+ if (!oldPassword.length) {
+ formMethods.setError(
+ "oldPassword",
+ { type: "required", message: t("error_required_field") },
+ { shouldFocus: true }
+ );
+ }
+
+ if (!newPassword.length) {
+ formMethods.setError(
+ "newPassword",
+ { type: "required", message: t("error_required_field") },
+ { shouldFocus: true }
+ );
+ }
+
+ if (oldPassword && newPassword) {
+ passwordMutation.mutate({ oldPassword, newPassword });
+ }
+ };
+
+ const timeoutOptions = [5, 10, 15].map((mins) => ({
+ label: t("multiple_duration_mins", { count: mins }),
+ value: mins,
+ }));
+
+ const isDisabled = formMethods.formState.isSubmitting || !formMethods.formState.isDirty;
+
+ const passwordMinLength = data?.user.role === "USER" ? 7 : 15;
+ const isUser = data?.user.role === "USER";
+
+ return (
+ <>
+ {user && user.identityProvider !== IdentityProvider.CAL && !user.passwordAdded ? (
+ <div className="border-subtle rounded-b-xl border border-t-0">
+ <div className="px-4 py-6 sm:px-6">
+ <h2 className="font-cal text-emphasis text-lg font-medium leading-6">
+ {t("account_managed_by_identity_provider", {
+ provider: identityProviderNameMap[user.identityProvider],
+ })}
+ </h2>
+
+ <p className="text-subtle mt-1 text-sm">
+ {t("account_managed_by_identity_provider_description", {
+ provider: identityProviderNameMap[user.identityProvider],
+ })}
+ </p>
+ <Button
+ className="mt-3"
+ onClick={() => createAccountPasswordMutation.mutate()}
+ loading={createAccountPasswordMutation.isPending}>
+ {t("create_account_password")}
+ </Button>
+ </div>
+ </div>
+ ) : (
+ <Form form={formMethods} handleSubmit={handleSubmit}>
+ <div className="border-subtle border-x px-4 py-6 sm:px-6">
+ {formMethods.formState.errors.apiError && (
+ <div className="pb-6">
+ <Alert severity="error" message={formMethods.formState.errors.apiError?.message} />
+ </div>
+ )}
+ <div className="w-full sm:grid sm:grid-cols-2 sm:gap-x-6">
+ <div>
+ <PasswordField {...formMethods.register("oldPassword")} label={t("old_password")} />
+ </div>
+ <div>
+ <PasswordField
+ {...formMethods.register("newPassword", {
+ minLength: {
+ message: t(isUser ? "password_hint_min" : "password_hint_admin_min"),
+ value: passwordMinLength,
+ },
+ pattern: {
+ message: "Should contain a number, uppercase and lowercase letters",
+ value: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).*$/gm,
+ },
+ })}
+ label={t("new_password")}
+ />
+ </div>
+ </div>
+ <p className="text-default mt-4 w-full text-sm">
+ {t("invalid_password_hint", { passwordLength: passwordMinLength })}
+ </p>
+ </div>
+ <SectionBottomActions align="end">
+ <Button
+ color="primary"
+ type="submit"
+ loading={passwordMutation.isPending}
+ onClick={() => formMethods.clearErrors("apiError")}
+ disabled={isDisabled || passwordMutation.isPending || sessionMutation.isPending}>
+ {t("update")}
+ </Button>
+ </SectionBottomActions>
+ <div className="mt-6">
+ <SettingsToggle
+ toggleSwitchAtTheEnd={true}
+ title={t("session_timeout")}
+ description={t("session_timeout_description")}
+ checked={sessionTimeout !== undefined}
+ data-testid="session-check"
+ onCheckedChange={(e) => {
+ if (!e) {
+ setSessionTimeout(undefined);
+
+ if (metadata.success) {
+ sessionMutation.mutate({
+ metadata: { ...metadata.data, sessionTimeout: undefined },
+ });
+ }
+ } else {
+ setSessionTimeout(10);
+ }
+ }}
+ childrenClassName="lg:ml-0"
+ switchContainerClassName={classNames(
+ "py-6 px-4 sm:px-6 border-subtle rounded-xl border",
+ !!sessionTimeout && "rounded-b-none"
+ )}>
+ <>
+ <div className="border-subtle border-x p-6 pb-8">
+ <div className="flex flex-col">
+ <p className="text-default mb-2 font-medium">{t("session_timeout_after")}</p>
+ <Select
+ options={timeoutOptions}
+ defaultValue={
+ sessionTimeout
+ ? timeoutOptions.find((tmo) => tmo.value === sessionTimeout)
+ : timeoutOptions[1]
+ }
+ isSearchable={false}
+ className="block h-[36px] !w-auto min-w-0 flex-none rounded-md text-sm"
+ onChange={(event) => {
+ setSessionTimeout(event?.value);
+ }}
+ />
+ </div>
+ </div>
+ <SectionBottomActions align="end">
+ <Button
+ color="primary"
+ loading={sessionMutation.isPending}
+ onClick={() => {
+ sessionMutation.mutate({
+ metadata: { ...metadata, sessionTimeout },
+ });
+ formMethods.clearErrors("apiError");
+ }}
+ disabled={
+ initialSessionTimeout === sessionTimeout ||
+ passwordMutation.isPending ||
+ sessionMutation.isPending
+ }>
+ {t("update")}
+ </Button>
+ </SectionBottomActions>
+ </>
+ </SettingsToggle>
+ </div>
+ </Form>
+ )}
+ </>
+ );
+};
+
+const PasswordViewWrapper = () => {
+ const { data: user, isPending } = trpc.viewer.me.useQuery({ includePasswordAdded: true });
+ const { t } = useLocale();
+ if (isPending || !user) return <SkeletonLoader />;
+
+ return <PasswordView user={user} />;
+};
+
+export default PasswordViewWrapper;
diff --git a/apps/web/modules/settings/security/two-factor-auth-view.tsx b/apps/web/modules/settings/security/two-factor-auth-view.tsx
new file mode 100644
index 00000000000..59a10394a00
--- /dev/null
+++ b/apps/web/modules/settings/security/two-factor-auth-view.tsx
@@ -0,0 +1,86 @@
+"use client";
+
+import { useState } from "react";
+
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { trpc } from "@calcom/trpc/react";
+import { Badge, SkeletonButton, SkeletonContainer, SkeletonText, Alert, SettingsToggle } from "@calcom/ui";
+
+import DisableTwoFactorModal from "@components/settings/DisableTwoFactorModal";
+import EnableTwoFactorModal from "@components/settings/EnableTwoFactorModal";
+
+const SkeletonLoader = () => {
+ return (
+ <SkeletonContainer>
+ <div className="mb-8 mt-6 space-y-6">
+ <div className="flex items-center">
+ <SkeletonButton className="mr-6 h-8 w-20 rounded-md p-5" />
+ <SkeletonText className="h-8 w-full" />
+ </div>
+ </div>
+ </SkeletonContainer>
+ );
+};
+
+const TwoFactorAuthView = () => {
+ const utils = trpc.useUtils();
+
+ const { t } = useLocale();
+ const { data: user, isPending } = trpc.viewer.me.useQuery({ includePasswordAdded: true });
+
+ const [enableModalOpen, setEnableModalOpen] = useState<boolean>(false);
+ const [disableModalOpen, setDisableModalOpen] = useState<boolean>(false);
+
+ if (isPending) return <SkeletonLoader />;
+
+ const isCalProvider = user?.identityProvider === "CAL";
+ const canSetupTwoFactor = !isCalProvider && !user?.twoFactorEnabled && !user?.passwordAdded;
+ return (
+ <>
+ {canSetupTwoFactor && <Alert severity="neutral" message={t("2fa_disabled")} />}
+ <SettingsToggle
+ toggleSwitchAtTheEnd={true}
+ data-testid="two-factor-switch"
+ title={t("two_factor_auth")}
+ description={t("add_an_extra_layer_of_security")}
+ checked={user?.twoFactorEnabled ?? false}
+ onCheckedChange={() =>
+ user?.twoFactorEnabled ? setDisableModalOpen(true) : setEnableModalOpen(true)
+ }
+ Badge={
+ <Badge className="mx-2 text-xs" variant={user?.twoFactorEnabled ? "success" : "gray"}>
+ {user?.twoFactorEnabled ? t("enabled") : t("disabled")}
+ </Badge>
+ }
+ switchContainerClassName="rounded-t-none border-t-0"
+ />
+
+ <EnableTwoFactorModal
+ open={enableModalOpen}
+ onOpenChange={() => setEnableModalOpen(!enableModalOpen)}
+ onEnable={() => {
+ setEnableModalOpen(false);
+ utils.viewer.me.invalidate();
+ }}
+ onCancel={() => {
+ setEnableModalOpen(false);
+ }}
+ />
+
+ <DisableTwoFactorModal
+ open={disableModalOpen}
+ disablePassword={!isCalProvider}
+ onOpenChange={() => setDisableModalOpen(!disableModalOpen)}
+ onDisable={() => {
+ setDisableModalOpen(false);
+ utils.viewer.me.invalidate();
+ }}
+ onCancel={() => {
+ setDisableModalOpen(false);
+ }}
+ />
+ </>
+ );
+};
+
+export default TwoFactorAuthView;
diff --git a/apps/web/pages/settings/admin/flags.tsx b/apps/web/pages/settings/admin/flags.tsx
index 61151984615..e898c79af26 100644
--- a/apps/web/pages/settings/admin/flags.tsx
+++ b/apps/web/pages/settings/admin/flags.tsx
@@ -1,11 +1,17 @@
"use client";
import { FlagListingView } from "@calcom/features/flags/pages/flag-listing-view";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
import { getLayout } from "@components/auth/layouts/AdminLayout";
-const FlagsPage = () => <FlagListingView />;
+const FlagsPage = () => (
+ <div>
+ <Meta title="Feature Flags" description="Here you can toggle your Cal.com instance features." />
+ <FlagListingView />
+ </div>
+);
FlagsPage.getLayout = getLayout;
FlagsPage.PageWrapper = PageWrapper;
diff --git a/apps/web/pages/settings/admin/impersonation.tsx b/apps/web/pages/settings/admin/impersonation.tsx
index e1f20ca8a77..d46f7581cd3 100644
--- a/apps/web/pages/settings/admin/impersonation.tsx
+++ b/apps/web/pages/settings/admin/impersonation.tsx
@@ -1,5 +1,3 @@
-"use client";
-
import { signIn } from "next-auth/react";
import { useSearchParams } from "next/navigation";
import { useRef, useEffect } from "react";
diff --git a/apps/web/pages/settings/admin/lockedSMS/index.tsx b/apps/web/pages/settings/admin/lockedSMS/index.tsx
index bb9f9b6f6c1..d10422dc322 100644
--- a/apps/web/pages/settings/admin/lockedSMS/index.tsx
+++ b/apps/web/pages/settings/admin/lockedSMS/index.tsx
@@ -1,11 +1,16 @@
-"use client";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
import { getLayout } from "@components/auth/layouts/AdminLayout";
-import LockedSMSView from "./lockedSMSView";
+import LockedSMSView from "~/settings/admin/locked-sms-view";
-const LockedSMSPage = () => <LockedSMSView />;
+const LockedSMSPage = () => (
+ <>
+ <Meta title="Locked SMS" description="Lock or unlock SMS sending for users" />
+ <LockedSMSView />
+ </>
+);
LockedSMSPage.getLayout = getLayout;
LockedSMSPage.PageWrapper = PageWrapper;
diff --git a/apps/web/pages/settings/admin/oAuth/index.tsx b/apps/web/pages/settings/admin/oAuth/index.tsx
index 73568da45cd..0307086f328 100644
--- a/apps/web/pages/settings/admin/oAuth/index.tsx
+++ b/apps/web/pages/settings/admin/oAuth/index.tsx
@@ -1,11 +1,16 @@
-"use client";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
import { getLayout } from "@components/auth/layouts/AdminLayout";
-import OAuthView from "./oAuthView";
+import OAuthView from "~/settings/admin/oauth-view";
-const OAuthPage = () => <OAuthView />;
+const OAuthPage = () => (
+ <>
+ <Meta title="OAuth" description="Add new OAuth Clients" />
+ <OAuthView />
+ </>
+);
OAuthPage.getLayout = getLayout;
OAuthPage.PageWrapper = PageWrapper;
diff --git a/apps/web/pages/settings/admin/orgMigrations/moveTeamToOrg.tsx b/apps/web/pages/settings/admin/orgMigrations/moveTeamToOrg.tsx
index c2e0d005510..fdcd246642c 100644
--- a/apps/web/pages/settings/admin/orgMigrations/moveTeamToOrg.tsx
+++ b/apps/web/pages/settings/admin/orgMigrations/moveTeamToOrg.tsx
@@ -1,21 +1,23 @@
+"use client";
+
import { zodResolver } from "@hookform/resolvers/zod";
-import type { GetServerSidePropsContext } from "next";
-import { getSession } from "next-auth/react";
import type { TFunction } from "next-i18next";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { z } from "zod";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { UserPermissionRole } from "@calcom/prisma/enums";
import { getStringAsNumberRequiredSchema } from "@calcom/prisma/zod-utils";
import { Button, Form, Meta, SelectField, TextField, showToast } from "@calcom/ui";
+import { getServerSideProps } from "@lib/settings/admin/orgMigrations/moveTeamToOrg/getServerSideProps";
+
import PageWrapper from "@components/PageWrapper";
import { getLayout } from "./_OrgMigrationLayout";
+export { getServerSideProps };
+
export const getFormSchema = (t: TFunction) => {
return z.object({
teamId: z.number().or(getStringAsNumberRequiredSchema(t)),
@@ -147,36 +149,5 @@ export default function MoveTeamToOrg() {
);
}
-export async function getServerSideProps(ctx: GetServerSidePropsContext) {
- const session = await getSession(ctx);
- if (!session || !session.user) {
- return {
- redirect: {
- destination: "/login",
- permanent: false,
- },
- };
- }
-
- const isAdmin = session.user.role === UserPermissionRole.ADMIN;
- if (!isAdmin) {
- return {
- redirect: {
- destination: "/",
- permanent: false,
- },
- };
- }
- return {
- props: {
- error: null,
- migrated: null,
- userId: session.user.id,
- ...(await serverSideTranslations(ctx.locale || "en", ["common"])),
- username: session.user.username,
- },
- };
-}
-
MoveTeamToOrg.PageWrapper = PageWrapper;
MoveTeamToOrg.getLayout = getLayout;
diff --git a/apps/web/pages/settings/admin/orgMigrations/moveUserToOrg.tsx b/apps/web/pages/settings/admin/orgMigrations/moveUserToOrg.tsx
index 784152caa73..495ed575864 100644
--- a/apps/web/pages/settings/admin/orgMigrations/moveUserToOrg.tsx
+++ b/apps/web/pages/settings/admin/orgMigrations/moveUserToOrg.tsx
@@ -1,26 +1,28 @@
+"use client";
+
/**
* It could be an admin feature to move a user to an organization but because it's a temporary thing before mono-user orgs are implemented, it's not right to spend time on it.
* Plus, we need to do it only for cal.com and not provide as a feature to our self hosters.
*/
import { zodResolver } from "@hookform/resolvers/zod";
-import type { GetServerSidePropsContext } from "next";
-import { getSession } from "next-auth/react";
import type { TFunction } from "next-i18next";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useState } from "react";
import { Controller, useForm } from "react-hook-form";
import z from "zod";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { MembershipRole } from "@calcom/prisma/client";
-import { UserPermissionRole } from "@calcom/prisma/enums";
import { getStringAsNumberRequiredSchema } from "@calcom/prisma/zod-utils";
import { Button, Form, Meta, SelectField, TextField, showToast } from "@calcom/ui";
+import { getServerSideProps } from "@lib/settings/admin/orgMigrations/moveUserToOrg/getServerSideProps";
+
import PageWrapper from "@components/PageWrapper";
import { getLayout } from "./_OrgMigrationLayout";
+export { getServerSideProps };
+
function Wrapper({ children }: { children: React.ReactNode }) {
return (
<div>
@@ -182,32 +184,5 @@ export default function MoveUserToOrg() {
);
}
-export async function getServerSideProps(ctx: GetServerSidePropsContext) {
- const session = await getSession(ctx);
- if (!session || !session.user) {
- return {
- redirect: {
- destination: "/login",
- permanent: false,
- },
- };
- }
-
- const isAdmin = session.user.role === UserPermissionRole.ADMIN;
- if (!isAdmin) {
- return {
- redirect: {
- destination: "/",
- permanent: false,
- },
- };
- }
- return {
- props: {
- ...(await serverSideTranslations(ctx.locale || "en", ["common"])),
- },
- };
-}
-
MoveUserToOrg.PageWrapper = PageWrapper;
MoveUserToOrg.getLayout = getLayout;
diff --git a/apps/web/pages/settings/admin/orgMigrations/removeTeamFromOrg.tsx b/apps/web/pages/settings/admin/orgMigrations/removeTeamFromOrg.tsx
index 17a90f115af..2148457abd8 100644
--- a/apps/web/pages/settings/admin/orgMigrations/removeTeamFromOrg.tsx
+++ b/apps/web/pages/settings/admin/orgMigrations/removeTeamFromOrg.tsx
@@ -1,21 +1,23 @@
+"use client";
+
import { zodResolver } from "@hookform/resolvers/zod";
-import type { GetServerSidePropsContext } from "next";
-import { getSession } from "next-auth/react";
import type { TFunction } from "next-i18next";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useState } from "react";
import { useForm } from "react-hook-form";
import z from "zod";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { UserPermissionRole } from "@calcom/prisma/enums";
import { getStringAsNumberRequiredSchema } from "@calcom/prisma/zod-utils";
import { Button, Form, Meta, TextField, showToast } from "@calcom/ui";
+import { getServerSideProps } from "@lib/settings/admin/orgMigrations/removeTeamFromOrg/getServerSideProps";
+
import PageWrapper from "@components/PageWrapper";
import { getLayout } from "./_OrgMigrationLayout";
+export { getServerSideProps };
+
function Wrapper({ children }: { children: React.ReactNode }) {
return (
<div>
@@ -111,32 +113,5 @@ export default function RemoveTeamFromOrg() {
);
}
-export async function getServerSideProps(ctx: GetServerSidePropsContext) {
- const session = await getSession(ctx);
- if (!session || !session.user) {
- return {
- redirect: {
- destination: "/login",
- permanent: false,
- },
- };
- }
-
- const isAdmin = session.user.role === UserPermissionRole.ADMIN;
- if (!isAdmin) {
- return {
- redirect: {
- destination: "/",
- permanent: false,
- },
- };
- }
- return {
- props: {
- ...(await serverSideTranslations(ctx.locale || "en", ["common"])),
- },
- };
-}
-
RemoveTeamFromOrg.PageWrapper = PageWrapper;
RemoveTeamFromOrg.getLayout = getLayout;
diff --git a/apps/web/pages/settings/admin/orgMigrations/removeUserFromOrg.tsx b/apps/web/pages/settings/admin/orgMigrations/removeUserFromOrg.tsx
index ef7710ed379..18d18a15d8a 100644
--- a/apps/web/pages/settings/admin/orgMigrations/removeUserFromOrg.tsx
+++ b/apps/web/pages/settings/admin/orgMigrations/removeUserFromOrg.tsx
@@ -1,25 +1,30 @@
+"use client";
+
import { zodResolver } from "@hookform/resolvers/zod";
-import type { GetServerSidePropsContext } from "next";
-import { getSession } from "next-auth/react";
import type { TFunction } from "next-i18next";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useState } from "react";
import { useForm } from "react-hook-form";
import z from "zod";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { UserPermissionRole } from "@calcom/prisma/enums";
import { getStringAsNumberRequiredSchema } from "@calcom/prisma/zod-utils";
import { Button, TextField, Meta, showToast, Form } from "@calcom/ui";
+import { getServerSideProps } from "@lib/settings/admin/orgMigrations/removeUserFromOrg/getServerSideProps";
+
import PageWrapper from "@components/PageWrapper";
import { getLayout } from "./_OrgMigrationLayout";
+export { getServerSideProps };
+
function Wrapper({ children }: { children: React.ReactNode }) {
return (
<div>
- <Meta title="Organization Migration: Move a team" description="Migrates a team to an organization" />
+ <Meta
+ title="Organization Migration: Revert a user"
+ description="Reverts a migration of a user to an organization"
+ />
{children}
</div>
);
@@ -106,32 +111,5 @@ export default function RemoveUserFromOrg() {
);
}
-export async function getServerSideProps(ctx: GetServerSidePropsContext) {
- const session = await getSession(ctx);
- if (!session || !session.user) {
- return {
- redirect: {
- destination: "/login",
- permanent: false,
- },
- };
- }
-
- const isAdmin = session.user.role === UserPermissionRole.ADMIN;
- if (!isAdmin) {
- return {
- redirect: {
- destination: "/",
- permanent: false,
- },
- };
- }
- return {
- props: {
- ...(await serverSideTranslations(ctx.locale || "en", ["common"])),
- },
- };
-}
-
RemoveUserFromOrg.PageWrapper = PageWrapper;
RemoveUserFromOrg.getLayout = getLayout;
diff --git a/apps/web/pages/settings/admin/organizations/[id]/edit.tsx b/apps/web/pages/settings/admin/organizations/[id]/edit.tsx
index 2236d8f8507..cb60a65ecd8 100644
--- a/apps/web/pages/settings/admin/organizations/[id]/edit.tsx
+++ b/apps/web/pages/settings/admin/organizations/[id]/edit.tsx
@@ -1,9 +1,40 @@
-import OrgEditView from "@calcom/features/ee/organizations/pages/settings/admin/AdminOrgEditPage";
+import { z } from "zod";
+
+import NoSSR from "@calcom/core/components/NoSSR";
+import LicenseRequired from "@calcom/ee/common/components/LicenseRequired";
+import OrgForm from "@calcom/features/ee/organizations/pages/settings/admin/AdminOrgEditPage";
+import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
+import { trpc } from "@calcom/trpc/react";
+import { Meta } from "@calcom/ui";
-import type { CalPageWrapper } from "@components/PageWrapper";
import PageWrapper from "@components/PageWrapper";
+import { getLayout } from "@components/auth/layouts/AdminLayout";
+
+const paramsSchema = z.object({ id: z.coerce.number() });
+
+const Page = () => {
+ const params = useParamsWithFallback();
+ const parsedParams = paramsSchema.safeParse(params);
+
+ if (!parsedParams.success) return <div>Invalid id</div>;
+
+ const [org] = trpc.viewer.organizations.adminGet.useSuspenseQuery({ id: parsedParams.data.id });
-const Page = OrgEditView as CalPageWrapper;
+ return (
+ <div>
+ <LicenseRequired>
+ <Meta
+ title={`Editing organization: ${org.name}`}
+ description="Here you can edit a current organization."
+ />
+ <NoSSR>
+ <OrgForm org={org} />
+ </NoSSR>
+ </LicenseRequired>
+ </div>
+ );
+};
Page.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
export default Page;
diff --git a/apps/web/pages/settings/admin/organizations/index.tsx b/apps/web/pages/settings/admin/organizations/index.tsx
index 9c2d7cc1de4..b5ff176b3e7 100644
--- a/apps/web/pages/settings/admin/organizations/index.tsx
+++ b/apps/web/pages/settings/admin/organizations/index.tsx
@@ -1,9 +1,26 @@
-import AdminOrgsPage from "@calcom/features/ee/organizations/pages/settings/admin/AdminOrgPage";
+import NoSSR from "@calcom/core/components/NoSSR";
+import LicenseRequired from "@calcom/ee/common/components/LicenseRequired";
+import AdminOrgTable from "@calcom/features/ee/organizations/pages/settings/admin/AdminOrgPage";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { Meta } from "@calcom/ui";
-import type { CalPageWrapper } from "@components/PageWrapper";
import PageWrapper from "@components/PageWrapper";
+import { getLayout } from "@components/auth/layouts/AdminLayout";
-const Page = AdminOrgsPage as CalPageWrapper;
+const Page = () => {
+ const { t } = useLocale();
+ return (
+ <div>
+ <LicenseRequired>
+ <Meta title={t("organizations")} description={t("orgs_page_description")} />
+ <NoSSR>
+ <AdminOrgTable />
+ </NoSSR>
+ </LicenseRequired>
+ </div>
+ );
+};
Page.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
export default Page;
diff --git a/apps/web/pages/settings/admin/users/[id]/edit.tsx b/apps/web/pages/settings/admin/users/[id]/edit.tsx
index 0ee1269ccac..9b99ded74f3 100644
--- a/apps/web/pages/settings/admin/users/[id]/edit.tsx
+++ b/apps/web/pages/settings/admin/users/[id]/edit.tsx
@@ -1,9 +1,41 @@
+import { z } from "zod";
+
+import NoSSR from "@calcom/core/components/NoSSR";
+import LicenseRequired from "@calcom/ee/common/components/LicenseRequired";
import UsersEditView from "@calcom/features/ee/users/pages/users-edit-view";
+import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
+import { trpc } from "@calcom/trpc/react";
+import { Meta } from "@calcom/ui";
-import type { CalPageWrapper } from "@components/PageWrapper";
import PageWrapper from "@components/PageWrapper";
+import { getLayout } from "@components/auth/layouts/AdminLayout";
+
+const userIdSchema = z.object({ id: z.coerce.number() });
+
+const Page = () => {
+ const params = useParamsWithFallback();
+ const input = userIdSchema.safeParse(params);
+
+ if (!input.success) return <div>Invalid input</div>;
+
+ const [data] = trpc.viewer.users.get.useSuspenseQuery({ userId: input.data.id });
+ const { user } = data;
+
+ return (
+ <>
+ <Meta title={`Editing user: ${user.username}`} description="Here you can edit a current user." />
+ <div>
+ <LicenseRequired>
+ <NoSSR>
+ <UsersEditView user={user} />
+ </NoSSR>
+ </LicenseRequired>
+ </div>
+ </>
+ );
+};
-const Page = UsersEditView as CalPageWrapper;
Page.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
export default Page;
diff --git a/apps/web/pages/settings/admin/users/add.tsx b/apps/web/pages/settings/admin/users/add.tsx
index 293a90214ec..ce2911b2321 100644
--- a/apps/web/pages/settings/admin/users/add.tsx
+++ b/apps/web/pages/settings/admin/users/add.tsx
@@ -1,9 +1,16 @@
import UsersAddView from "@calcom/features/ee/users/pages/users-add-view";
+import { Meta } from "@calcom/ui";
-import type { CalPageWrapper } from "@components/PageWrapper";
import PageWrapper from "@components/PageWrapper";
+import { getLayout } from "@components/auth/layouts/AdminLayout";
-const Page = UsersAddView as CalPageWrapper;
+const Page = () => (
+ <>
+ <Meta title="Add new user" description="Here you can add a new user." />
+ <UsersAddView />
+ </>
+);
Page.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
export default Page;
diff --git a/apps/web/pages/settings/admin/users/index.tsx b/apps/web/pages/settings/admin/users/index.tsx
index 194c9666826..8a74ba8a102 100644
--- a/apps/web/pages/settings/admin/users/index.tsx
+++ b/apps/web/pages/settings/admin/users/index.tsx
@@ -1,9 +1,28 @@
import UsersListingView from "@calcom/features/ee/users/pages/users-listing-view";
+import { Meta, Button } from "@calcom/ui";
-import type { CalPageWrapper } from "@components/PageWrapper";
import PageWrapper from "@components/PageWrapper";
+import { getLayout } from "@components/auth/layouts/AdminLayout";
-const Page = UsersListingView as CalPageWrapper;
+const Page = () => {
+ return (
+ <>
+ <Meta
+ title="Users"
+ description="A list of all the users in your account including their name, title, email and role."
+ CTA={
+ <div className="mt-4 space-x-5 sm:ml-16 sm:mt-0 sm:flex-none">
+ {/* TODO: Add import users functionality */}
+ {/* <Button disabled>Import users</Button> */}
+ <Button href="/settings/admin/users/add">Add user</Button>
+ </div>
+ }
+ />
+ <UsersListingView />
+ </>
+ );
+};
Page.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
export default Page;
diff --git a/apps/web/pages/settings/billing/index.tsx b/apps/web/pages/settings/billing/index.tsx
index 4ba2f29720d..b4f4cc80af3 100644
--- a/apps/web/pages/settings/billing/index.tsx
+++ b/apps/web/pages/settings/billing/index.tsx
@@ -1,71 +1,23 @@
-"use client";
-
-import { usePathname } from "next/navigation";
-
-import { useIntercom } from "@calcom/features/ee/support/lib/intercom/useIntercom";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
-import { classNames } from "@calcom/lib";
-import { WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { Button, Meta } from "@calcom/ui";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
-interface CtaRowProps {
- title: string;
- description: string;
- children: React.ReactNode;
- className?: string;
-}
+import BillingView from "~/settings/billing/billing-view";
-const CtaRow = ({ title, description, className, children }: CtaRowProps) => {
- return (
- <>
- <section className={classNames("text-default flex flex-col sm:flex-row", className)}>
- <div>
- <h2 className="text-base font-semibold">{title}</h2>
- <p>{description}</p>
- </div>
- <div className="flex-shrink-0 pt-3 sm:ml-auto sm:pl-3 sm:pt-0">{children}</div>
- </section>
- </>
- );
-};
-
-const BillingView = () => {
- const pathname = usePathname();
+const Page = () => {
const { t } = useLocale();
- const { open } = useIntercom();
- const returnTo = pathname;
- const billingHref = `/api/integrations/stripepayment/portal?returnTo=${WEBAPP_URL}${returnTo}`;
-
- const onContactSupportClick = async () => {
- await open();
- };
return (
<>
<Meta title={t("billing")} description={t("manage_billing_description")} borderInShellHeader={true} />
- <div className="border-subtle space-y-6 rounded-b-lg border border-t-0 px-6 py-8 text-sm sm:space-y-8">
- <CtaRow title={t("view_and_manage_billing_details")} description={t("view_and_edit_billing_details")}>
- <Button color="primary" href={billingHref} target="_blank" EndIcon="external-link">
- {t("billing_portal")}
- </Button>
- </CtaRow>
-
- <hr className="border-subtle" />
-
- <CtaRow title={t("need_anything_else")} description={t("further_billing_help")}>
- <Button color="secondary" onClick={onContactSupportClick}>
- {t("contact_support")}
- </Button>
- </CtaRow>
- </div>
+ <BillingView />
</>
);
};
-BillingView.getLayout = getLayout;
-BillingView.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default BillingView;
+export default Page;
diff --git a/apps/web/pages/settings/developer/api-keys.tsx b/apps/web/pages/settings/developer/api-keys.tsx
index b60df18aada..33b8ef2d405 100644
--- a/apps/web/pages/settings/developer/api-keys.tsx
+++ b/apps/web/pages/settings/developer/api-keys.tsx
@@ -1,70 +1,16 @@
-import { useState } from "react";
-
-import type { TApiKeys } from "@calcom/ee/api-keys/components/ApiKeyListItem";
-import LicenseRequired from "@calcom/ee/common/components/LicenseRequired";
-import ApiKeyDialogForm from "@calcom/features/ee/api-keys/components/ApiKeyDialogForm";
-import ApiKeyListItem from "@calcom/features/ee/api-keys/components/ApiKeyListItem";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { APP_NAME } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { trpc } from "@calcom/trpc/react";
-import {
- Button,
- Dialog,
- DialogContent,
- EmptyScreen,
- Meta,
- SkeletonContainer,
- SkeletonText,
-} from "@calcom/ui";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
-const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
- return (
- <SkeletonContainer>
- <Meta title={title} description={description} borderInShellHeader={true} />
- <div className="divide-subtle border-subtle space-y-6 rounded-b-lg border border-t-0 px-6 py-4">
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
- </div>
- </SkeletonContainer>
- );
-};
+import ApiKeysView from "~/settings/developer/api-keys-view";
+import NewApiKeyButton from "~/settings/developer/components/CreateApiKeyButton";
-const ApiKeysView = () => {
+const Page = () => {
const { t } = useLocale();
- const { data, isPending } = trpc.viewer.apiKeys.list.useQuery();
-
- const [apiKeyModal, setApiKeyModal] = useState(false);
- const [apiKeyToEdit, setApiKeyToEdit] = useState<(TApiKeys & { neverExpires?: boolean }) | undefined>(
- undefined
- );
-
- const NewApiKeyButton = () => {
- return (
- <Button
- color="secondary"
- StartIcon="plus"
- onClick={() => {
- setApiKeyToEdit(undefined);
- setApiKeyModal(true);
- }}>
- {t("add")}
- </Button>
- );
- };
-
- if (isPending || !data) {
- return (
- <SkeletonLoader
- title={t("api_keys")}
- description={t("create_first_api_key_description", { appName: APP_NAME })}
- />
- );
- }
-
return (
<>
<Meta
@@ -73,47 +19,12 @@ const ApiKeysView = () => {
CTA={<NewApiKeyButton />}
borderInShellHeader={true}
/>
-
- <LicenseRequired>
- <div>
- {data?.length ? (
- <>
- <div className="border-subtle rounded-b-lg border border-t-0">
- {data.map((apiKey, index) => (
- <ApiKeyListItem
- key={apiKey.id}
- apiKey={apiKey}
- lastItem={data.length === index + 1}
- onEditClick={() => {
- setApiKeyToEdit(apiKey);
- setApiKeyModal(true);
- }}
- />
- ))}
- </div>
- </>
- ) : (
- <EmptyScreen
- Icon="link"
- headline={t("create_first_api_key")}
- description={t("create_first_api_key_description", { appName: APP_NAME })}
- className="rounded-b-lg rounded-t-none border-t-0"
- buttonRaw={<NewApiKeyButton />}
- />
- )}
- </div>
- </LicenseRequired>
-
- <Dialog open={apiKeyModal} onOpenChange={setApiKeyModal}>
- <DialogContent type="creation">
- <ApiKeyDialogForm handleClose={() => setApiKeyModal(false)} defaultValues={apiKeyToEdit} />
- </DialogContent>
- </Dialog>
+ <ApiKeysView />
</>
);
};
-ApiKeysView.getLayout = getLayout;
-ApiKeysView.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default ApiKeysView;
+export default Page;
diff --git a/apps/web/pages/settings/developer/webhooks/[id]/index.tsx b/apps/web/pages/settings/developer/webhooks/[id]/index.tsx
index 9daf00ba80b..b9d17fe6d5c 100644
--- a/apps/web/pages/settings/developer/webhooks/[id]/index.tsx
+++ b/apps/web/pages/settings/developer/webhooks/[id]/index.tsx
@@ -1,9 +1,43 @@
-import WebhookEditView from "@calcom/features/webhooks/pages/webhook-edit-view";
+import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
+import EditWebhookView from "@calcom/features/webhooks/pages/webhook-edit-view";
+import { APP_NAME } from "@calcom/lib/constants";
+import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { trpc } from "@calcom/trpc/react";
+import { SkeletonContainer, Meta } from "@calcom/ui";
-import type { CalPageWrapper } from "@components/PageWrapper";
import PageWrapper from "@components/PageWrapper";
-const Page = WebhookEditView as CalPageWrapper;
+const Page = () => {
+ const searchParams = useCompatSearchParams();
+ const id = searchParams?.get("id") ?? undefined;
+ const { t } = useLocale();
+
+ const { data: webhook } = trpc.viewer.webhook.get.useQuery(
+ { webhookId: id },
+ {
+ suspense: true,
+ enabled: !!id,
+ }
+ );
+
+ if (!id) return <SkeletonContainer />;
+
+ // I think we should do SSR for this page
+ return (
+ <>
+ <Meta
+ title={t("edit_webhook")}
+ description={t("add_webhook_description", { appName: APP_NAME })}
+ borderInShellHeader={true}
+ backButton
+ />
+ <EditWebhookView webhook={webhook} />
+ </>
+ );
+};
+
+Page.getLayout = getLayout;
Page.PageWrapper = PageWrapper;
export default Page;
diff --git a/apps/web/pages/settings/developer/webhooks/index.tsx b/apps/web/pages/settings/developer/webhooks/index.tsx
index ad42580c232..e23bb64712e 100644
--- a/apps/web/pages/settings/developer/webhooks/index.tsx
+++ b/apps/web/pages/settings/developer/webhooks/index.tsx
@@ -1,9 +1,38 @@
+import { useSession } from "next-auth/react";
+
+import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
+import { CreateNewWebhookButton } from "@calcom/features/webhooks/components";
import WebhooksView from "@calcom/features/webhooks/pages/webhooks-view";
+import { APP_NAME } from "@calcom/lib/constants";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { UserPermissionRole } from "@calcom/prisma/enums";
+import { trpc } from "@calcom/trpc/react";
+import { Meta } from "@calcom/ui";
-import type { CalPageWrapper } from "@components/PageWrapper";
import PageWrapper from "@components/PageWrapper";
-const Page = WebhooksView as CalPageWrapper;
+const Page = () => {
+ const { t } = useLocale();
+ const session = useSession();
+ const isAdmin = session.data?.user.role === UserPermissionRole.ADMIN;
+
+ const { data, isPending } = trpc.viewer.webhook.getByViewer.useQuery(undefined, {
+ enabled: session.status === "authenticated",
+ });
+
+ return (
+ <>
+ <Meta
+ title={t("webhooks")}
+ description={t("add_webhook_description", { appName: APP_NAME })}
+ CTA={data && data.webhookGroups.length > 0 ? <CreateNewWebhookButton isAdmin={isAdmin} /> : <></>}
+ borderInShellHeader={(data && data.profiles.length === 1) || !data?.webhookGroups?.length}
+ />
+ <WebhooksView />
+ </>
+ );
+};
+Page.getLayout = getLayout;
Page.PageWrapper = PageWrapper;
export default Page;
diff --git a/apps/web/pages/settings/developer/webhooks/new.tsx b/apps/web/pages/settings/developer/webhooks/new.tsx
index df39aea3f9c..981ddd73e7e 100644
--- a/apps/web/pages/settings/developer/webhooks/new.tsx
+++ b/apps/web/pages/settings/developer/webhooks/new.tsx
@@ -1,9 +1,27 @@
+import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import WebhookNewView from "@calcom/features/webhooks/pages/webhook-new-view";
+import { APP_NAME } from "@calcom/lib/constants";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { Meta } from "@calcom/ui";
-import type { CalPageWrapper } from "@components/PageWrapper";
import PageWrapper from "@components/PageWrapper";
-const Page = WebhookNewView as CalPageWrapper;
+const Page = () => {
+ const { t } = useLocale();
+ return (
+ <>
+ <Meta
+ title={t("add_webhook")}
+ description={t("add_webhook_description", { appName: APP_NAME })}
+ backButton
+ borderInShellHeader={true}
+ />
+ <WebhookNewView />
+ </>
+ );
+};
+
Page.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
export default Page;
diff --git a/apps/web/pages/settings/my-account/appearance.tsx b/apps/web/pages/settings/my-account/appearance.tsx
index b290489c0c7..9fbe4f4adff 100644
--- a/apps/web/pages/settings/my-account/appearance.tsx
+++ b/apps/web/pages/settings/my-account/appearance.tsx
@@ -1,452 +1,23 @@
-"use client";
-
-import { useSession } from "next-auth/react";
-import { useState } from "react";
-import { Controller, useForm } from "react-hook-form";
-import type { z } from "zod";
-
-import { BookerLayoutSelector } from "@calcom/features/settings/BookerLayoutSelector";
-import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
-import ThemeLabel from "@calcom/features/settings/ThemeLabel";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
-import { APP_NAME } from "@calcom/lib/constants";
-import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR } from "@calcom/lib/constants";
-import { checkWCAGContrastColor } from "@calcom/lib/getBrandColours";
-import useGetBrandingColours from "@calcom/lib/getBrandColours";
-import { useHasPaidPlan } from "@calcom/lib/hooks/useHasPaidPlan";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import useTheme from "@calcom/lib/hooks/useTheme";
-import { validateBookerLayouts } from "@calcom/lib/validateBookerLayouts";
-import type { userMetadata } from "@calcom/prisma/zod-utils";
-import { trpc } from "@calcom/trpc/react";
-import type { RouterOutputs } from "@calcom/trpc/react";
-import {
- Alert,
- Button,
- ColorPicker,
- Form,
- Meta,
- showToast,
- SkeletonButton,
- SkeletonContainer,
- SkeletonText,
- SettingsToggle,
- UpgradeTeamsBadge,
- useCalcomTheme,
-} from "@calcom/ui";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
-const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
- return (
- <SkeletonContainer>
- <Meta title={title} description={description} borderInShellHeader={false} />
- <div className="border-subtle mt-6 flex items-center rounded-t-xl border p-6 text-sm">
- <SkeletonText className="h-8 w-1/3" />
- </div>
- <div className="border-subtle space-y-6 border-x px-4 py-6 sm:px-6">
- <div className="[&>*]:bg-emphasis flex w-full items-center justify-center gap-x-2 [&>*]:animate-pulse">
- <div className="h-32 flex-1 rounded-md p-5" />
- <div className="h-32 flex-1 rounded-md p-5" />
- <div className="h-32 flex-1 rounded-md p-5" />
- </div>
- <div className="flex justify-between">
- <SkeletonText className="h-8 w-1/3" />
- <SkeletonText className="h-8 w-1/3" />
- </div>
-
- <SkeletonText className="h-8 w-full" />
- </div>
- <div className="rounded-b-lg">
- <SectionBottomActions align="end">
- <SkeletonButton className="mr-6 h-8 w-20 rounded-md p-5" />
- </SectionBottomActions>
- </div>
- </SkeletonContainer>
- );
-};
-
-const useBrandColors = (
- currentTheme: string | null,
- {
- brandColor,
- darkBrandColor,
- }: {
- brandColor?: string | null;
- darkBrandColor?: string | null;
- }
-): void => {
- const brandTheme = useGetBrandingColours({
- lightVal: brandColor,
- darkVal: darkBrandColor,
- });
- const selectedTheme = currentTheme ? brandTheme[currentTheme as "light" | "dark"] : {};
- useCalcomTheme({
- root: selectedTheme,
- });
-};
+import AppearancePage from "~/settings/my-account/appearance-view";
-const AppearanceView = ({
- user,
- hasPaidPlan,
-}: {
- user: RouterOutputs["viewer"]["me"];
- hasPaidPlan: boolean;
-}) => {
+const Page = () => {
const { t } = useLocale();
- const utils = trpc.useUtils();
- const session = useSession();
- const isApartOfOrganization = session.data?.user.org?.id;
- const [darkModeError, setDarkModeError] = useState(false);
- const [lightModeError, setLightModeError] = useState(false);
- const [isCustomBrandColorChecked, setIsCustomBranColorChecked] = useState(
- user?.brandColor !== DEFAULT_LIGHT_BRAND_COLOR || user?.darkBrandColor !== DEFAULT_DARK_BRAND_COLOR
- );
- const [hideBrandingValue, setHideBrandingValue] = useState(user?.hideBranding ?? false);
- useTheme(user?.appTheme);
- useBrandColors(user?.appTheme ?? null, {
- brandColor: user?.brandColor,
- darkBrandColor: user?.darkBrandColor,
- });
-
- const userAppThemeFormMethods = useForm({
- defaultValues: {
- appTheme: user.appTheme,
- },
- });
-
- const {
- formState: { isSubmitting: isUserAppThemeSubmitting, isDirty: isUserAppThemeDirty },
- reset: resetUserAppThemeReset,
- } = userAppThemeFormMethods;
-
- const userThemeFormMethods = useForm({
- defaultValues: {
- theme: user.theme,
- },
- });
-
- const {
- formState: { isSubmitting: isUserThemeSubmitting, isDirty: isUserThemeDirty },
- reset: resetUserThemeReset,
- } = userThemeFormMethods;
-
- const bookerLayoutFormMethods = useForm({
- defaultValues: {
- metadata: user.metadata as z.infer<typeof userMetadata>,
- },
- });
-
- const {
- formState: { isSubmitting: isBookerLayoutFormSubmitting, isDirty: isBookerLayoutFormDirty },
- reset: resetBookerLayoutThemeReset,
- } = bookerLayoutFormMethods;
-
- const DEFAULT_BRAND_COLOURS = {
- light: user.brandColor ?? DEFAULT_LIGHT_BRAND_COLOR,
- dark: user.darkBrandColor ?? DEFAULT_DARK_BRAND_COLOR,
- };
-
- const brandColorsFormMethods = useForm({
- defaultValues: {
- brandColor: DEFAULT_BRAND_COLOURS.light,
- darkBrandColor: DEFAULT_BRAND_COLOURS.dark,
- },
- });
-
- const {
- formState: { isSubmitting: isBrandColorsFormSubmitting, isDirty: isBrandColorsFormDirty },
- reset: resetBrandColorsThemeReset,
- } = brandColorsFormMethods;
-
- const selectedTheme = userThemeFormMethods.watch("theme");
- const selectedThemeIsDark =
- selectedTheme === "dark" ||
- (selectedTheme === "" &&
- typeof document !== "undefined" &&
- document.documentElement.classList.contains("dark"));
-
- const mutation = trpc.viewer.updateProfile.useMutation({
- onSuccess: async (data) => {
- await utils.viewer.me.invalidate();
- showToast(t("settings_updated_successfully"), "success");
- resetBrandColorsThemeReset({ brandColor: data.brandColor, darkBrandColor: data.darkBrandColor });
- resetBookerLayoutThemeReset({ metadata: data.metadata });
- resetUserThemeReset({ theme: data.theme });
- resetUserAppThemeReset({ appTheme: data.appTheme });
- },
- onError: (error) => {
- if (error.message) {
- showToast(error.message, "error");
- } else {
- showToast(t("error_updating_settings"), "error");
- }
- },
- onSettled: async () => {
- await utils.viewer.me.invalidate();
- },
- });
return (
- <div>
+ <>
<Meta title={t("appearance")} description={t("appearance_description")} borderInShellHeader={false} />
- <div className="border-subtle mt-6 flex items-center rounded-t-lg border p-6 text-sm">
- <div>
- <p className="text-default text-base font-semibold">{t("app_theme")}</p>
- <p className="text-default">{t("app_theme_applies_note")}</p>
- </div>
- </div>
- <Form
- form={userAppThemeFormMethods}
- handleSubmit={(values) => {
- mutation.mutate({
- appTheme: values.appTheme === "" ? null : values.appTheme,
- });
- }}>
- <div className="border-subtle flex flex-col justify-between border-x px-6 py-8 sm:flex-row">
- <ThemeLabel
- variant="system"
- value={undefined}
- label={t("theme_system")}
- defaultChecked={user.appTheme === null}
- register={userAppThemeFormMethods.register}
- fieldName="appTheme"
- />
- <ThemeLabel
- variant="light"
- value="light"
- label={t("light")}
- defaultChecked={user.appTheme === "light"}
- register={userAppThemeFormMethods.register}
- fieldName="appTheme"
- />
- <ThemeLabel
- variant="dark"
- value="dark"
- label={t("dark")}
- defaultChecked={user.appTheme === "dark"}
- register={userAppThemeFormMethods.register}
- fieldName="appTheme"
- />
- </div>
- <SectionBottomActions className="mb-6" align="end">
- <Button
- disabled={isUserAppThemeSubmitting || !isUserAppThemeDirty}
- type="submit"
- data-testid="update-app-theme-btn"
- color="primary">
- {t("update")}
- </Button>
- </SectionBottomActions>
- </Form>
-
- {isApartOfOrganization ? null : (
- <>
- <div className="border-subtle mt-6 flex items-center rounded-t-lg border p-6 text-sm">
- <div>
- <p className="text-default text-base font-semibold">{t("theme")}</p>
- <p className="text-default">{t("theme_applies_note")}</p>
- </div>
- </div>
- <Form
- form={userThemeFormMethods}
- handleSubmit={(values) => {
- mutation.mutate({
- // Radio values don't support null as values, therefore we convert an empty string
- // back to null here.
- theme: values.theme === "" ? null : values.theme,
- });
- }}>
- <div className="border-subtle flex flex-col justify-between border-x px-6 py-8 sm:flex-row">
- <ThemeLabel
- variant="system"
- value={undefined}
- label={t("theme_system")}
- defaultChecked={user.theme === null}
- register={userThemeFormMethods.register}
- />
- <ThemeLabel
- variant="light"
- value="light"
- label={t("light")}
- defaultChecked={user.theme === "light"}
- register={userThemeFormMethods.register}
- />
- <ThemeLabel
- variant="dark"
- value="dark"
- label={t("dark")}
- defaultChecked={user.theme === "dark"}
- register={userThemeFormMethods.register}
- />
- </div>
- <SectionBottomActions className="mb-6" align="end">
- <Button
- loading={mutation.isPending}
- disabled={isUserThemeSubmitting || !isUserThemeDirty}
- type="submit"
- data-testid="update-theme-btn"
- color="primary">
- {t("update")}
- </Button>
- </SectionBottomActions>
- </Form>
-
- <Form
- form={bookerLayoutFormMethods}
- handleSubmit={(values) => {
- const layoutError = validateBookerLayouts(values?.metadata?.defaultBookerLayouts || null);
- if (layoutError) {
- showToast(t(layoutError), "error");
- return;
- } else {
- mutation.mutate(values);
- }
- }}>
- <BookerLayoutSelector
- isDark={selectedThemeIsDark}
- name="metadata.defaultBookerLayouts"
- title={t("bookerlayout_user_settings_title")}
- description={t("bookerlayout_user_settings_description")}
- isDisabled={isBookerLayoutFormSubmitting || !isBookerLayoutFormDirty}
- isLoading={mutation.isPending}
- />
- </Form>
-
- <Form
- form={brandColorsFormMethods}
- handleSubmit={(values) => {
- mutation.mutate(values);
- }}>
- <div className="mt-6">
- <SettingsToggle
- toggleSwitchAtTheEnd={true}
- title={t("custom_brand_colors")}
- description={t("customize_your_brand_colors")}
- checked={isCustomBrandColorChecked}
- onCheckedChange={(checked) => {
- setIsCustomBranColorChecked(checked);
- if (!checked) {
- mutation.mutate({
- brandColor: DEFAULT_LIGHT_BRAND_COLOR,
- darkBrandColor: DEFAULT_DARK_BRAND_COLOR,
- });
- }
- }}
- childrenClassName="lg:ml-0">
- <div className="border-subtle flex flex-col gap-6 border-x p-6">
- <Controller
- name="brandColor"
- control={brandColorsFormMethods.control}
- defaultValue={DEFAULT_BRAND_COLOURS.light}
- render={() => (
- <div>
- <p className="text-default mb-2 block text-sm font-medium">
- {t("light_brand_color")}
- </p>
- <ColorPicker
- defaultValue={DEFAULT_BRAND_COLOURS.light}
- resetDefaultValue={DEFAULT_LIGHT_BRAND_COLOR}
- onChange={(value) => {
- if (checkWCAGContrastColor("#ffffff", value)) {
- setLightModeError(false);
- } else {
- setLightModeError(true);
- }
- brandColorsFormMethods.setValue("brandColor", value, { shouldDirty: true });
- }}
- />
- {lightModeError ? (
- <div className="mt-4">
- <Alert severity="warning" message={t("light_theme_contrast_error")} />
- </div>
- ) : null}
- </div>
- )}
- />
-
- <Controller
- name="darkBrandColor"
- control={brandColorsFormMethods.control}
- defaultValue={DEFAULT_BRAND_COLOURS.dark}
- render={() => (
- <div className="mt-6 sm:mt-0">
- <p className="text-default mb-2 block text-sm font-medium">{t("dark_brand_color")}</p>
- <ColorPicker
- defaultValue={DEFAULT_BRAND_COLOURS.dark}
- resetDefaultValue={DEFAULT_DARK_BRAND_COLOR}
- onChange={(value) => {
- if (checkWCAGContrastColor("#101010", value)) {
- setDarkModeError(false);
- } else {
- setDarkModeError(true);
- }
- brandColorsFormMethods.setValue("darkBrandColor", value, { shouldDirty: true });
- }}
- />
- {darkModeError ? (
- <div className="mt-4">
- <Alert severity="warning" message={t("dark_theme_contrast_error")} />
- </div>
- ) : null}
- </div>
- )}
- />
- </div>
- <SectionBottomActions align="end">
- <Button
- loading={mutation.isPending}
- disabled={isBrandColorsFormSubmitting || !isBrandColorsFormDirty}
- color="primary"
- type="submit">
- {t("update")}
- </Button>
- </SectionBottomActions>
- </SettingsToggle>
- </div>
- </Form>
-
- {/* TODO future PR to preview brandColors */}
- {/* <Button
- color="secondary"
- EndIcon="external-link"
- className="mt-6"
- onClick={() => window.open(`${WEBAPP_URL}/${user.username}/${user.eventTypes[0].title}`, "_blank")}>
- Preview
- </Button> */}
-
- <SettingsToggle
- toggleSwitchAtTheEnd={true}
- title={t("disable_cal_branding", { appName: APP_NAME })}
- disabled={!hasPaidPlan || mutation?.isPending}
- description={t("removes_cal_branding", { appName: APP_NAME })}
- checked={hasPaidPlan ? hideBrandingValue : false}
- Badge={<UpgradeTeamsBadge />}
- onCheckedChange={(checked) => {
- setHideBrandingValue(checked);
- mutation.mutate({ hideBranding: checked });
- }}
- switchContainerClassName="mt-6"
- />
- </>
- )}
- </div>
+ <AppearancePage />
+ </>
);
};
-const AppearanceViewWrapper = () => {
- const { data: user, isPending } = trpc.viewer.me.useQuery();
- const { isPending: isTeamPlanStatusLoading, hasPaidPlan } = useHasPaidPlan();
-
- const { t } = useLocale();
-
- if (isPending || isTeamPlanStatusLoading || !user)
- return <SkeletonLoader title={t("appearance")} description={t("appearance_description")} />;
-
- return <AppearanceView user={user} hasPaidPlan={hasPaidPlan} />;
-};
-
-AppearanceViewWrapper.getLayout = getLayout;
-AppearanceViewWrapper.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default AppearanceViewWrapper;
+export default Page;
diff --git a/apps/web/pages/settings/my-account/calendars.tsx b/apps/web/pages/settings/my-account/calendars.tsx
index 5cfe5e7d0cd..2dfa7cb2959 100644
--- a/apps/web/pages/settings/my-account/calendars.tsx
+++ b/apps/web/pages/settings/my-account/calendars.tsx
@@ -1,42 +1,13 @@
-"use client";
-
-import { Fragment } from "react";
-
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { Button, Meta, SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
import { CalendarListContainer } from "@components/apps/CalendarListContainer";
-const SkeletonLoader = () => {
- return (
- <SkeletonContainer>
- <div className="border-subtle mt-8 space-y-6 rounded-lg border px-4 py-6 sm:px-6">
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
-
- <SkeletonButton className="ml-auto h-8 w-20 rounded-md p-5" />
- </div>
- </SkeletonContainer>
- );
-};
-
-const AddCalendarButton = () => {
- const { t } = useLocale();
-
- return (
- <>
- <Button color="secondary" StartIcon="plus" href="/apps/categories/calendar">
- {t("add_calendar")}
- </Button>
- </>
- );
-};
+import AddCalendarButton from "~/settings/my-account/components/AddCalendarButton";
-const CalendarsView = () => {
+const Page = () => {
const { t } = useLocale();
return (
@@ -54,7 +25,7 @@ const CalendarsView = () => {
);
};
-CalendarsView.getLayout = getLayout;
-CalendarsView.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default CalendarsView;
+export default Page;
diff --git a/apps/web/pages/settings/my-account/conferencing.tsx b/apps/web/pages/settings/my-account/conferencing.tsx
index 4fe4bb0d540..d4f749cff66 100644
--- a/apps/web/pages/settings/my-account/conferencing.tsx
+++ b/apps/web/pages/settings/my-account/conferencing.tsx
@@ -1,125 +1,36 @@
-"use client";
-
-import { useReducer } from "react";
-
-import DisconnectIntegrationModal from "@calcom/features/apps/components/DisconnectIntegrationModal";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { trpc } from "@calcom/trpc/react";
-import { Button, EmptyScreen, Meta, SkeletonContainer, SkeletonText } from "@calcom/ui";
-
-import { QueryCell } from "@lib/QueryCell";
+import { Button, Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
-import { AppList } from "@components/apps/AppList";
-const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
- return (
- <SkeletonContainer>
- <Meta title={title} description={description} borderInShellHeader={true} />
- <div className="divide-subtle border-subtle space-y-6 rounded-b-lg border border-t-0 px-6 py-4">
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
- </div>
- </SkeletonContainer>
- );
-};
+import ConferencingView from "~/settings/my-account/conferencing-view";
-const AddConferencingButton = () => {
+const Page = () => {
const { t } = useLocale();
- return (
- <Button color="secondary" StartIcon="plus" href="/apps/categories/conferencing">
- {t("add")}
- </Button>
- );
-};
-
-type ModalState = {
- isOpen: boolean;
- credentialId: null | number;
-};
-
-const ConferencingLayout = () => {
- const { t } = useLocale();
-
- const [modal, updateModal] = useReducer(
- (data: ModalState, partialData: Partial<ModalState>) => ({ ...data, ...partialData }),
- {
- isOpen: false,
- credentialId: null,
- }
- );
-
- const query = trpc.viewer.integrations.useQuery({
- variant: "conferencing",
- onlyInstalled: true,
- });
-
- const handleModelClose = () => {
- updateModal({ isOpen: false, credentialId: null });
- };
-
- const handleDisconnect = (credentialId: number) => {
- updateModal({ isOpen: true, credentialId });
+ const AddConferencingButton = () => {
+ return (
+ <Button color="secondary" StartIcon="plus" href="/apps/categories/conferencing">
+ {t("add")}
+ </Button>
+ );
};
return (
<>
- <div className="bg-default w-full sm:mx-0 xl:mt-0">
- <Meta
- title={t("conferencing")}
- description={t("conferencing_description")}
- CTA={<AddConferencingButton />}
- borderInShellHeader={true}
- />
- <QueryCell
- query={query}
- customLoader={
- <SkeletonLoader title={t("conferencing")} description={t("conferencing_description")} />
- }
- success={({ data }) => {
- console.log(data);
- if (!data.items.length) {
- return (
- <EmptyScreen
- Icon="calendar"
- headline={t("no_category_apps", {
- category: t("conferencing").toLowerCase(),
- })}
- description={t("no_category_apps_description_conferencing")}
- buttonRaw={
- <Button
- color="secondary"
- data-testid="connect-conferencing-apps"
- href="/apps/categories/conferencing">
- {t("connect_conference_apps")}
- </Button>
- }
- />
- );
- }
- return (
- <AppList
- listClassName="rounded-lg rounded-t-none border-t-0"
- handleDisconnect={handleDisconnect}
- data={data}
- variant="conferencing"
- />
- );
- }}
- />
- </div>
- <DisconnectIntegrationModal
- handleModelClose={handleModelClose}
- isOpen={modal.isOpen}
- credentialId={modal.credentialId}
+ <Meta
+ title={t("conferencing")}
+ description={t("conferencing_description")}
+ CTA={<AddConferencingButton />}
+ borderInShellHeader={true}
/>
+ <ConferencingView />
</>
);
};
-ConferencingLayout.getLayout = getLayout;
-ConferencingLayout.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default ConferencingLayout;
+export default Page;
diff --git a/apps/web/pages/settings/my-account/general.tsx b/apps/web/pages/settings/my-account/general.tsx
index 9bb18622a92..37eb99532c5 100644
--- a/apps/web/pages/settings/my-account/general.tsx
+++ b/apps/web/pages/settings/my-account/general.tsx
@@ -1,387 +1,23 @@
-"use client";
-
-import { useSession } from "next-auth/react";
-import { useState } from "react";
-import { Controller, useForm } from "react-hook-form";
-
-import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
-import { classNames } from "@calcom/lib";
-import { formatLocalizedDateTime } from "@calcom/lib/date-fns";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { localeOptions } from "@calcom/lib/i18n";
-import { nameOfDay } from "@calcom/lib/weekday";
-import type { RouterOutputs } from "@calcom/trpc/react";
-import { trpc } from "@calcom/trpc/react";
-import {
- Button,
- Form,
- Label,
- Meta,
- Select,
- showToast,
- SkeletonButton,
- SkeletonContainer,
- SkeletonText,
- TimezoneSelect,
- SettingsToggle,
-} from "@calcom/ui";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
-import TravelScheduleModal from "@components/settings/TravelScheduleModal";
-
-export type FormValues = {
- locale: {
- value: string;
- label: string;
- };
- timeZone: string;
- timeFormat: {
- value: number;
- label: string | number;
- };
- weekStart: {
- value: string;
- label: string;
- };
- travelSchedules: {
- id?: number;
- startDate: Date;
- endDate?: Date;
- timeZone: string;
- }[];
-};
-
-const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
- return (
- <SkeletonContainer>
- <Meta title={title} description={description} borderInShellHeader={true} />
- <div className="border-subtle space-y-6 rounded-b-xl border border-t-0 px-4 py-8 sm:px-6">
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
-
- <SkeletonButton className="ml-auto h-8 w-20 rounded-md p-5" />
- </div>
- </SkeletonContainer>
- );
-};
-interface GeneralViewProps {
- localeProp: string;
- user: RouterOutputs["viewer"]["me"];
- travelSchedules: RouterOutputs["viewer"]["getTravelSchedules"];
-}
+import GeneralQueryView from "~/settings/my-account/general-view";
-const GeneralQueryView = () => {
+const Page = () => {
const { t } = useLocale();
- const { data: user, isPending } = trpc.viewer.me.useQuery();
-
- const { data: travelSchedules, isPending: isPendingTravelSchedules } =
- trpc.viewer.getTravelSchedules.useQuery();
-
- if (isPending || isPendingTravelSchedules)
- return <SkeletonLoader title={t("general")} description={t("general_description")} />;
- if (!user) {
- throw new Error(t("something_went_wrong"));
- }
- return <GeneralView user={user} travelSchedules={travelSchedules || []} localeProp={user.locale} />;
-};
-
-const GeneralView = ({ localeProp, user, travelSchedules }: GeneralViewProps) => {
- const utils = trpc.useContext();
- const {
- t,
- i18n: { language },
- } = useLocale();
- const { update } = useSession();
- const [isUpdateBtnLoading, setIsUpdateBtnLoading] = useState<boolean>(false);
- const [isTZScheduleOpen, setIsTZScheduleOpen] = useState<boolean>(false);
-
- const mutation = trpc.viewer.updateProfile.useMutation({
- onSuccess: async (res) => {
- await utils.viewer.me.invalidate();
- reset(getValues());
- showToast(t("settings_updated_successfully"), "success");
- await update(res);
-
- if (res.locale) {
- window.calNewLocale = res.locale;
- }
- },
- onError: () => {
- showToast(t("error_updating_settings"), "error");
- },
- onSettled: async () => {
- await utils.viewer.me.invalidate();
- setIsUpdateBtnLoading(false);
- },
- });
-
- const timeFormatOptions = [
- { value: 12, label: t("12_hour") },
- { value: 24, label: t("24_hour") },
- ];
-
- const weekStartOptions = [
- { value: "Sunday", label: nameOfDay(localeProp, 0) },
- { value: "Monday", label: nameOfDay(localeProp, 1) },
- { value: "Tuesday", label: nameOfDay(localeProp, 2) },
- { value: "Wednesday", label: nameOfDay(localeProp, 3) },
- { value: "Thursday", label: nameOfDay(localeProp, 4) },
- { value: "Friday", label: nameOfDay(localeProp, 5) },
- { value: "Saturday", label: nameOfDay(localeProp, 6) },
- ];
-
- const formMethods = useForm<FormValues>({
- defaultValues: {
- locale: {
- value: localeProp || "",
- label: localeOptions.find((option) => option.value === localeProp)?.label || "",
- },
- timeZone: user.timeZone || "",
- timeFormat: {
- value: user.timeFormat || 12,
- label: timeFormatOptions.find((option) => option.value === user.timeFormat)?.label || 12,
- },
- weekStart: {
- value: user.weekStart,
- label: nameOfDay(localeProp, user.weekStart === "Sunday" ? 0 : 1),
- },
- travelSchedules:
- travelSchedules.map((schedule) => {
- return {
- id: schedule.id,
- startDate: schedule.startDate,
- endDate: schedule.endDate ?? undefined,
- timeZone: schedule.timeZone,
- };
- }) || [],
- },
- });
- const {
- formState: { isDirty, isSubmitting },
- reset,
- getValues,
- } = formMethods;
- const isDisabled = isSubmitting || !isDirty;
-
- const [isAllowDynamicBookingChecked, setIsAllowDynamicBookingChecked] = useState(
- !!user.allowDynamicBooking
- );
- const [isAllowSEOIndexingChecked, setIsAllowSEOIndexingChecked] = useState(!!user.allowSEOIndexing);
- const [isReceiveMonthlyDigestEmailChecked, setIsReceiveMonthlyDigestEmailChecked] = useState(
- !!user.receiveMonthlyDigestEmail
- );
-
- const watchedTzSchedules = formMethods.watch("travelSchedules");
-
return (
- <div>
- <Form
- form={formMethods}
- handleSubmit={(values) => {
- setIsUpdateBtnLoading(true);
- mutation.mutate({
- ...values,
- locale: values.locale.value,
- timeFormat: values.timeFormat.value,
- weekStart: values.weekStart.value,
- });
- }}>
- <Meta title={t("general")} description={t("general_description")} borderInShellHeader={true} />
- <div className="border-subtle border-x border-y-0 px-4 py-8 sm:px-6">
- <Controller
- name="locale"
- render={({ field: { value, onChange } }) => (
- <>
- <Label className="text-emphasis">
- <>{t("language")}</>
- </Label>
- <Select<{ label: string; value: string }>
- className="capitalize"
- options={localeOptions}
- value={value}
- onChange={onChange}
- />
- </>
- )}
- />
- <Controller
- name="timeZone"
- control={formMethods.control}
- render={({ field: { value } }) => (
- <>
- <Label className="text-emphasis mt-6">
- <>{t("timezone")}</>
- </Label>
- <TimezoneSelect
- id="timezone"
- value={value}
- onChange={(event) => {
- if (event) formMethods.setValue("timeZone", event.value, { shouldDirty: true });
- }}
- />
- </>
- )}
- />
- {!watchedTzSchedules.length ? (
- <Button color="minimal" className="mt-2" onClick={() => setIsTZScheduleOpen(true)}>
- {t("schedule_timezone_change")}
- </Button>
- ) : (
- <div className="bg-muted border-subtle mt-2 rounded-md border p-4">
- <Label>{t("travel_schedule")}</Label>
- <div className="dark:bg-darkgray-100 border-subtle mt-4 rounded-md border bg-white text-sm">
- {watchedTzSchedules.map((schedule, index) => {
- return (
- <div
- className={classNames(
- "flex items-center p-4",
- index !== 0 ? "border-subtle border-t" : ""
- )}
- key={index}>
- <div>
- <div className="text-emphasis font-semibold">{`${formatLocalizedDateTime(
- schedule.startDate,
- { day: "numeric", month: "long" },
- language
- )} ${
- schedule.endDate
- ? `- ${formatLocalizedDateTime(
- schedule.endDate,
- { day: "numeric", month: "long" },
- language
- )}`
- : ``
- }`}</div>
- <div className="text-subtle">{schedule.timeZone.replace(/_/g, " ")}</div>
- </div>
- <Button
- color="secondary"
- className="ml-auto"
- variant="icon"
- StartIcon="trash-2"
- onClick={() => {
- const updatedSchedules = watchedTzSchedules.filter(
- (s, filterIndex) => filterIndex !== index
- );
- formMethods.setValue("travelSchedules", updatedSchedules, { shouldDirty: true });
- }}
- />
- </div>
- );
- })}
- </div>
- <Button
- StartIcon="plus"
- color="secondary"
- className="mt-4"
- onClick={() => setIsTZScheduleOpen(true)}>
- {t("add")}
- </Button>
- </div>
- )}
-
- <Controller
- name="timeFormat"
- control={formMethods.control}
- render={({ field: { value } }) => (
- <>
- <Label className="text-emphasis mt-6">
- <>{t("time_format")}</>
- </Label>
- <Select
- value={value}
- options={timeFormatOptions}
- onChange={(event) => {
- if (event) formMethods.setValue("timeFormat", { ...event }, { shouldDirty: true });
- }}
- />
- </>
- )}
- />
- <div className="text-gray text-default mt-2 flex items-center text-sm">
- {t("timeformat_profile_hint")}
- </div>
- <Controller
- name="weekStart"
- control={formMethods.control}
- render={({ field: { value } }) => (
- <>
- <Label className="text-emphasis mt-6">
- <>{t("start_of_week")}</>
- </Label>
- <Select
- value={value}
- options={weekStartOptions}
- onChange={(event) => {
- if (event) formMethods.setValue("weekStart", { ...event }, { shouldDirty: true });
- }}
- />
- </>
- )}
- />
- </div>
-
- <SectionBottomActions align="end">
- <Button loading={isUpdateBtnLoading} disabled={isDisabled} color="primary" type="submit">
- <>{t("update")}</>
- </Button>
- </SectionBottomActions>
- </Form>
-
- <SettingsToggle
- toggleSwitchAtTheEnd={true}
- title={t("dynamic_booking")}
- description={t("allow_dynamic_booking")}
- disabled={mutation.isPending}
- checked={isAllowDynamicBookingChecked}
- onCheckedChange={(checked) => {
- setIsAllowDynamicBookingChecked(checked);
- mutation.mutate({ allowDynamicBooking: checked });
- }}
- switchContainerClassName="mt-6"
- />
-
- <SettingsToggle
- toggleSwitchAtTheEnd={true}
- title={t("seo_indexing")}
- description={t("allow_seo_indexing")}
- disabled={mutation.isPending}
- checked={isAllowSEOIndexingChecked}
- onCheckedChange={(checked) => {
- setIsAllowSEOIndexingChecked(checked);
- mutation.mutate({ allowSEOIndexing: checked });
- }}
- switchContainerClassName="mt-6"
- />
-
- <SettingsToggle
- toggleSwitchAtTheEnd={true}
- title={t("monthly_digest_email")}
- description={t("monthly_digest_email_for_teams")}
- disabled={mutation.isPending}
- checked={isReceiveMonthlyDigestEmailChecked}
- onCheckedChange={(checked) => {
- setIsReceiveMonthlyDigestEmailChecked(checked);
- mutation.mutate({ receiveMonthlyDigestEmail: checked });
- }}
- switchContainerClassName="mt-6"
- />
- <TravelScheduleModal
- open={isTZScheduleOpen}
- onOpenChange={() => setIsTZScheduleOpen(false)}
- setValue={formMethods.setValue}
- existingSchedules={formMethods.getValues("travelSchedules") ?? []}
- />
- </div>
+ <>
+ <Meta title={t("general")} description={t("general_description")} borderInShellHeader={true} />
+ <GeneralQueryView />
+ </>
);
};
-GeneralQueryView.getLayout = getLayout;
-GeneralQueryView.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default GeneralQueryView;
+export default Page;
diff --git a/apps/web/pages/settings/my-account/out-of-office/index.tsx b/apps/web/pages/settings/my-account/out-of-office/index.tsx
index f2b845c8f47..89dbb3fdb69 100644
--- a/apps/web/pages/settings/my-account/out-of-office/index.tsx
+++ b/apps/web/pages/settings/my-account/out-of-office/index.tsx
@@ -1,81 +1,31 @@
-import { useSearchParams } from "next/navigation";
-import { useEffect, useState } from "react";
-
-import { CreateOrEditOutOfOfficeEntryModal } from "@calcom/features/settings/CreateOrEditOutOfOfficeModal";
-import { OutOfOfficeEntriesList } from "@calcom/features/settings/OutOfOfficeEntriesList";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
+import CreateNewOutOfOfficeEntryButton from "@calcom/features/settings/outOfOffice/CreateNewOutOfOfficeEntryButton";
+import { OutOfOfficeEntriesList } from "@calcom/features/settings/outOfOffice/OutOfOfficeEntriesList";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
-import { Button, Icon, Meta, SkeletonText } from "@calcom/ui";
+import { Meta, SkeletonText } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
-export type BookingRedirectForm = {
- dateRange: { startDate: Date; endDate: Date };
- offset: number;
- toTeamUserId: number | null;
- reasonId: number;
- notes?: string;
- uuid?: string | null;
-};
-
-const OutOfOfficePage = () => {
+const Page = () => {
const { t } = useLocale();
- const params = useSearchParams();
- const openModalOnStart = !!params?.get("open");
- useEffect(() => {
- if (openModalOnStart) {
- setOpenModal(true);
- }
- }, [openModalOnStart]);
-
- const [openModal, setOpenModal] = useState(false);
- const [currentlyEditingOutOfOfficeEntry, setCurrentlyEditingOutOfOfficeEntry] =
- useState<BookingRedirectForm | null>(null);
-
- const editOutOfOfficeEntry = (entry: BookingRedirectForm) => {
- setCurrentlyEditingOutOfOfficeEntry(entry);
- setOpenModal(true);
- };
-
const { isPending } = trpc.viewer.outOfOfficeReasonList.useQuery();
+
return (
<>
<Meta
title={t("out_of_office")}
description={t("out_of_office_description")}
borderInShellHeader={false}
- CTA={
- isPending ? (
- <SkeletonText className="h-8 w-20" />
- ) : (
- <Button
- color="primary"
- className="flex w-20 items-center justify-between px-4"
- onClick={() => setOpenModal(true)}
- data-testid="add_entry_ooo">
- <Icon name="plus" size={16} /> {t("add")}
- </Button>
- )
- }
+ CTA={isPending ? <SkeletonText className="h-8 w-20" /> : <CreateNewOutOfOfficeEntryButton />}
/>
- {openModal && (
- <CreateOrEditOutOfOfficeEntryModal
- openModal={openModal}
- closeModal={() => {
- setOpenModal(false);
- setCurrentlyEditingOutOfOfficeEntry(null);
- }}
- currentlyEditingOutOfOfficeEntry={currentlyEditingOutOfOfficeEntry}
- />
- )}
- <OutOfOfficeEntriesList editOutOfOfficeEntry={editOutOfOfficeEntry} />
+ <OutOfOfficeEntriesList />
</>
);
};
-OutOfOfficePage.getLayout = getLayout;
-OutOfOfficePage.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default OutOfOfficePage;
+export default Page;
diff --git a/apps/web/pages/settings/my-account/profile.tsx b/apps/web/pages/settings/my-account/profile.tsx
index 1e17681c785..9539cec4b4b 100644
--- a/apps/web/pages/settings/my-account/profile.tsx
+++ b/apps/web/pages/settings/my-account/profile.tsx
@@ -1,278 +1,14 @@
-"use client";
-
-import { zodResolver } from "@hookform/resolvers/zod";
-// eslint-disable-next-line no-restricted-imports
-import { get, pick } from "lodash";
-import { signOut, useSession } from "next-auth/react";
-import type { BaseSyntheticEvent } from "react";
-import React, { useRef, useState } from "react";
-import { Controller, useFieldArray, useForm } from "react-hook-form";
-import { z } from "zod";
-
-import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
-import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
-import { APP_NAME, FULL_NAME_LENGTH_MAX_LIMIT } from "@calcom/lib/constants";
-import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
+import { APP_NAME } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { md } from "@calcom/lib/markdownIt";
-import turndown from "@calcom/lib/turndownService";
-import { IdentityProvider } from "@calcom/prisma/enums";
-import type { TRPCClientErrorLike } from "@calcom/trpc/client";
-import type { RouterOutputs } from "@calcom/trpc/react";
-import { trpc } from "@calcom/trpc/react";
-import type { AppRouter } from "@calcom/trpc/server/routers/_app";
-import {
- Alert,
- Button,
- Dialog,
- DialogClose,
- DialogContent,
- DialogFooter,
- DialogTrigger,
- Editor,
- Form,
- ImageUploader,
- Label,
- Meta,
- PasswordField,
- showToast,
- SkeletonAvatar,
- SkeletonButton,
- SkeletonContainer,
- SkeletonText,
- TextField,
- UserAvatar,
-} from "@calcom/ui";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
-import TwoFactor from "@components/auth/TwoFactor";
-import CustomEmailTextField from "@components/settings/CustomEmailTextField";
-import SecondaryEmailConfirmModal from "@components/settings/SecondaryEmailConfirmModal";
-import SecondaryEmailModal from "@components/settings/SecondaryEmailModal";
-import { UsernameAvailabilityField } from "@components/ui/UsernameAvailability";
-
-const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
- return (
- <SkeletonContainer>
- <Meta title={title} description={description} borderInShellHeader={true} />
- <div className="border-subtle space-y-6 rounded-b-lg border border-t-0 px-4 py-8">
- <div className="flex items-center">
- <SkeletonAvatar className="me-4 mt-0 h-16 w-16 px-4" />
- <SkeletonButton className="h-6 w-32 rounded-md p-5" />
- </div>
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
-
- <SkeletonButton className="mr-6 h-8 w-20 rounded-md p-5" />
- </div>
- </SkeletonContainer>
- );
-};
-
-interface DeleteAccountValues {
- totpCode: string;
-}
-type Email = {
- id: number;
- email: string;
- emailVerified: string | null;
- emailPrimary: boolean;
-};
-
-export type FormValues = {
- username: string;
- avatarUrl: string | null;
- name: string;
- email: string;
- bio: string;
- secondaryEmails: Email[];
-};
+import ProfileView from "~/settings/my-account/profile-view";
-const ProfileView = () => {
+const Page = () => {
const { t } = useLocale();
- const utils = trpc.useUtils();
- const { update } = useSession();
- const { data: user, isPending } = trpc.viewer.me.useQuery({ includePasswordAdded: true });
-
- const updateProfileMutation = trpc.viewer.updateProfile.useMutation({
- onSuccess: async (res) => {
- await update(res);
- utils.viewer.me.invalidate();
- utils.viewer.shouldVerifyEmail.invalidate();
-
- if (res.hasEmailBeenChanged && res.sendEmailVerification) {
- showToast(t("change_of_email_toast", { email: tempFormValues?.email }), "success");
- } else {
- showToast(t("settings_updated_successfully"), "success");
- }
-
- setTempFormValues(null);
- },
- onError: (e) => {
- switch (e.message) {
- // TODO: Add error codes.
- case "email_already_used":
- {
- showToast(t(e.message), "error");
- }
- return;
- default:
- showToast(t("error_updating_settings"), "error");
- }
- },
- });
- const unlinkConnectedAccountMutation = trpc.viewer.unlinkConnectedAccount.useMutation({
- onSuccess: async (res) => {
- showToast(t(res.message), "success");
- utils.viewer.me.invalidate();
- },
- onError: (e) => {
- showToast(t(e.message), "error");
- },
- });
-
- const addSecondaryEmailMutation = trpc.viewer.addSecondaryEmail.useMutation({
- onSuccess: (res) => {
- setShowSecondaryEmailModalOpen(false);
- setNewlyAddedSecondaryEmail(res?.data?.email);
- utils.viewer.me.invalidate();
- },
- onError: (error) => {
- setSecondaryEmailAddErrorMessage(error?.message || "");
- },
- });
-
- const resendVerifyEmailMutation = trpc.viewer.auth.resendVerifyEmail.useMutation();
-
- const [confirmPasswordOpen, setConfirmPasswordOpen] = useState(false);
- const [tempFormValues, setTempFormValues] = useState<ExtendedFormValues | null>(null);
- const [confirmPasswordErrorMessage, setConfirmPasswordDeleteErrorMessage] = useState("");
- const [showCreateAccountPasswordDialog, setShowCreateAccountPasswordDialog] = useState(false);
- const [showAccountDisconnectWarning, setShowAccountDisconnectWarning] = useState(false);
- const [showSecondaryEmailModalOpen, setShowSecondaryEmailModalOpen] = useState(false);
- const [secondaryEmailAddErrorMessage, setSecondaryEmailAddErrorMessage] = useState("");
- const [newlyAddedSecondaryEmail, setNewlyAddedSecondaryEmail] = useState<undefined | string>(undefined);
-
- const [deleteAccountOpen, setDeleteAccountOpen] = useState(false);
- const [hasDeleteErrors, setHasDeleteErrors] = useState(false);
- const [deleteErrorMessage, setDeleteErrorMessage] = useState("");
- const form = useForm<DeleteAccountValues>();
-
- const onDeleteMeSuccessMutation = async () => {
- await utils.viewer.me.invalidate();
- showToast(t("Your account was deleted"), "success");
-
- setHasDeleteErrors(false); // dismiss any open errors
- if (process.env.NEXT_PUBLIC_WEBAPP_URL === "https://app.cal.com") {
- signOut({ callbackUrl: "/auth/logout?survey=true" });
- } else {
- signOut({ callbackUrl: "/auth/logout" });
- }
- };
-
- const confirmPasswordMutation = trpc.viewer.auth.verifyPassword.useMutation({
- onSuccess() {
- if (tempFormValues) updateProfileMutation.mutate(tempFormValues);
- setConfirmPasswordOpen(false);
- },
- onError() {
- setConfirmPasswordDeleteErrorMessage(t("incorrect_password"));
- },
- });
-
- const onDeleteMeErrorMutation = (error: TRPCClientErrorLike<AppRouter>) => {
- setHasDeleteErrors(true);
- setDeleteErrorMessage(errorMessages[error.message]);
- };
- const deleteMeMutation = trpc.viewer.deleteMe.useMutation({
- onSuccess: onDeleteMeSuccessMutation,
- onError: onDeleteMeErrorMutation,
- async onSettled() {
- await utils.viewer.me.invalidate();
- },
- });
- const deleteMeWithoutPasswordMutation = trpc.viewer.deleteMeWithoutPassword.useMutation({
- onSuccess: onDeleteMeSuccessMutation,
- onError: onDeleteMeErrorMutation,
- async onSettled() {
- await utils.viewer.me.invalidate();
- },
- });
-
- const isCALIdentityProvider = user?.identityProvider === IdentityProvider.CAL;
-
- const onConfirmPassword = (e: Event | React.MouseEvent<HTMLElement, MouseEvent>) => {
- e.preventDefault();
-
- const password = passwordRef.current.value;
- confirmPasswordMutation.mutate({ passwordInput: password });
- };
-
- const onConfirmButton = (e: Event | React.MouseEvent<HTMLElement, MouseEvent>) => {
- e.preventDefault();
- if (isCALIdentityProvider) {
- const totpCode = form.getValues("totpCode");
- const password = passwordRef.current.value;
- deleteMeMutation.mutate({ password, totpCode });
- } else {
- deleteMeWithoutPasswordMutation.mutate();
- }
- };
-
- const onConfirm = ({ totpCode }: DeleteAccountValues, e: BaseSyntheticEvent | undefined) => {
- e?.preventDefault();
- if (isCALIdentityProvider) {
- const password = passwordRef.current.value;
- deleteMeMutation.mutate({ password, totpCode });
- } else {
- deleteMeWithoutPasswordMutation.mutate();
- }
- };
-
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- const passwordRef = useRef<HTMLInputElement>(null!);
-
- const errorMessages: { [key: string]: string } = {
- [ErrorCode.SecondFactorRequired]: t("2fa_enabled_instructions"),
- [ErrorCode.IncorrectPassword]: `${t("incorrect_password")} ${t("please_try_again")}`,
- [ErrorCode.UserNotFound]: t("no_account_exists"),
- [ErrorCode.IncorrectTwoFactorCode]: `${t("incorrect_2fa_code")} ${t("please_try_again")}`,
- [ErrorCode.InternalServerError]: `${t("something_went_wrong")} ${t("please_try_again_and_contact_us")}`,
- [ErrorCode.ThirdPartyIdentityProviderEnabled]: t("account_created_with_identity_provider"),
- };
-
- if (isPending || !user) {
- return (
- <SkeletonLoader title={t("profile")} description={t("profile_description", { appName: APP_NAME })} />
- );
- }
-
- const userEmail = user.email || "";
- const defaultValues = {
- username: user.username || "",
- avatarUrl: user.avatarUrl,
- name: user.name || "",
- email: userEmail,
- bio: user.bio || "",
- // We add the primary email as the first item in the list
- secondaryEmails: [
- {
- id: 0,
- email: userEmail,
- emailVerified: user.emailVerified?.toString() || null,
- emailPrimary: true,
- },
- ...(user.secondaryEmails || []).map((secondaryEmail) => ({
- ...secondaryEmail,
- emailVerified: secondaryEmail.emailVerified?.toString() || null,
- emailPrimary: false,
- })),
- ],
- };
-
return (
<>
<Meta
@@ -280,465 +16,12 @@ const ProfileView = () => {
description={t("profile_description", { appName: APP_NAME })}
borderInShellHeader={true}
/>
- <ProfileForm
- key={JSON.stringify(defaultValues)}
- defaultValues={defaultValues}
- isPending={updateProfileMutation.isPending}
- isFallbackImg={!user.avatarUrl}
- user={user}
- userOrganization={user.organization}
- onSubmit={(values) => {
- if (values.email !== user.email && isCALIdentityProvider) {
- setTempFormValues(values);
- setConfirmPasswordOpen(true);
- } else {
- updateProfileMutation.mutate(values);
- }
- }}
- handleAddSecondaryEmail={() => setShowSecondaryEmailModalOpen(true)}
- handleResendVerifyEmail={(email) => {
- resendVerifyEmailMutation.mutate({ email });
- showToast(t("email_sent"), "success");
- }}
- handleAccountDisconnect={(values) => {
- if (isCALIdentityProvider) return;
- if (user?.passwordAdded) {
- setTempFormValues(values);
- setShowAccountDisconnectWarning(true);
- return;
- }
- setShowCreateAccountPasswordDialog(true);
- }}
- extraField={
- <div className="mt-6">
- <UsernameAvailabilityField
- onSuccessMutation={async () => {
- showToast(t("settings_updated_successfully"), "success");
- await utils.viewer.me.invalidate();
- }}
- onErrorMutation={() => {
- showToast(t("error_updating_settings"), "error");
- }}
- />
- </div>
- }
- isCALIdentityProvider={isCALIdentityProvider}
- />
-
- <div className="border-subtle mt-6 rounded-lg rounded-b-none border border-b-0 p-6">
- <Label className="mb-0 text-base font-semibold text-red-700">{t("danger_zone")}</Label>
- <p className="text-subtle text-sm">{t("account_deletion_cannot_be_undone")}</p>
- </div>
- {/* Delete account Dialog */}
- <Dialog open={deleteAccountOpen} onOpenChange={setDeleteAccountOpen}>
- <SectionBottomActions align="end">
- <DialogTrigger asChild>
- <Button data-testid="delete-account" color="destructive" className="mt-1" StartIcon="trash-2">
- {t("delete_account")}
- </Button>
- </DialogTrigger>
- </SectionBottomActions>
- <DialogContent
- title={t("delete_account_modal_title")}
- description={t("confirm_delete_account_modal", { appName: APP_NAME })}
- type="creation"
- Icon="triangle-alert">
- <>
- <div className="mb-10">
- <p className="text-default mb-4">{t("delete_account_confirmation_message")}</p>
- {isCALIdentityProvider && (
- <PasswordField
- data-testid="password"
- name="password"
- id="password"
- autoComplete="current-password"
- required
- label="Password"
- ref={passwordRef}
- />
- )}
-
- {user?.twoFactorEnabled && isCALIdentityProvider && (
- <Form handleSubmit={onConfirm} className="pb-4" form={form}>
- <TwoFactor center={false} />
- </Form>
- )}
-
- {hasDeleteErrors && <Alert severity="error" title={deleteErrorMessage} />}
- </div>
- <DialogFooter showDivider>
- <DialogClose />
- <Button
- color="primary"
- data-testid="delete-account-confirm"
- onClick={(e) => onConfirmButton(e)}>
- {t("delete_my_account")}
- </Button>
- </DialogFooter>
- </>
- </DialogContent>
- </Dialog>
-
- {/* If changing email, confirm password */}
- <Dialog open={confirmPasswordOpen} onOpenChange={setConfirmPasswordOpen}>
- <DialogContent
- title={t("confirm_password")}
- description={t("confirm_password_change_email")}
- type="creation"
- Icon="triangle-alert">
- <div className="mb-10">
- <div className="mb-4 grid gap-2 md:grid-cols-2">
- <div>
- <span className="text-emphasis mb-2 block text-sm font-medium leading-none">
- {t("old_email_address")}
- </span>
- <p className="text-subtle leading-none">{user.email}</p>
- </div>
- <div>
- <span className="text-emphasis mb-2 block text-sm font-medium leading-none">
- {t("new_email_address")}
- </span>
- <p className="text-subtle leading-none">{tempFormValues?.email}</p>
- </div>
- </div>
- <PasswordField
- data-testid="password"
- name="password"
- id="password"
- autoComplete="current-password"
- required
- label="Password"
- ref={passwordRef}
- />
-
- {confirmPasswordErrorMessage && <Alert severity="error" title={confirmPasswordErrorMessage} />}
- </div>
- <DialogFooter showDivider>
- <Button
- data-testid="profile-update-email-submit-button"
- color="primary"
- loading={confirmPasswordMutation.isPending}
- onClick={(e) => onConfirmPassword(e)}>
- {t("confirm")}
- </Button>
- <DialogClose />
- </DialogFooter>
- </DialogContent>
- </Dialog>
-
- <Dialog open={showCreateAccountPasswordDialog} onOpenChange={setShowCreateAccountPasswordDialog}>
- <DialogContent
- title={t("create_account_password")}
- description={t("create_account_password_hint")}
- type="creation"
- Icon="triangle-alert">
- <DialogFooter>
- <DialogClose />
- </DialogFooter>
- </DialogContent>
- </Dialog>
-
- <Dialog open={showAccountDisconnectWarning} onOpenChange={setShowAccountDisconnectWarning}>
- <DialogContent
- title={t("disconnect_account")}
- description={t("disconnect_account_hint")}
- type="creation"
- Icon="triangle-alert">
- <DialogFooter>
- <Button
- color="primary"
- onClick={() => {
- unlinkConnectedAccountMutation.mutate();
- setShowAccountDisconnectWarning(false);
- }}>
- {t("confirm")}
- </Button>
- <DialogClose />
- </DialogFooter>
- </DialogContent>
- </Dialog>
-
- {showSecondaryEmailModalOpen && (
- <SecondaryEmailModal
- isLoading={addSecondaryEmailMutation.isPending}
- errorMessage={secondaryEmailAddErrorMessage}
- handleAddEmail={(values) => {
- setSecondaryEmailAddErrorMessage("");
- addSecondaryEmailMutation.mutate(values);
- }}
- onCancel={() => {
- setSecondaryEmailAddErrorMessage("");
- setShowSecondaryEmailModalOpen(false);
- }}
- clearErrorMessage={() => {
- addSecondaryEmailMutation.reset();
- setSecondaryEmailAddErrorMessage("");
- }}
- />
- )}
- {!!newlyAddedSecondaryEmail && (
- <SecondaryEmailConfirmModal
- email={newlyAddedSecondaryEmail}
- onCancel={() => setNewlyAddedSecondaryEmail(undefined)}
- />
- )}
+ <ProfileView />
</>
);
};
-type SecondaryEmailApiPayload = {
- id: number;
- email: string;
- isDeleted: boolean;
-};
-
-type ExtendedFormValues = Omit<FormValues, "secondaryEmails"> & {
- secondaryEmails: SecondaryEmailApiPayload[];
-};
-
-const ProfileForm = ({
- defaultValues,
- onSubmit,
- handleAddSecondaryEmail,
- handleResendVerifyEmail,
- handleAccountDisconnect,
- extraField,
- isPending = false,
- isFallbackImg,
- user,
- userOrganization,
- isCALIdentityProvider,
-}: {
- defaultValues: FormValues;
- onSubmit: (values: ExtendedFormValues) => void;
- handleAddSecondaryEmail: () => void;
- handleResendVerifyEmail: (email: string) => void;
- handleAccountDisconnect: (values: ExtendedFormValues) => void;
- extraField?: React.ReactNode;
- isPending: boolean;
- isFallbackImg: boolean;
- user: RouterOutputs["viewer"]["me"];
- userOrganization: RouterOutputs["viewer"]["me"]["organization"];
- isCALIdentityProvider: boolean;
-}) => {
- const { t } = useLocale();
- const [firstRender, setFirstRender] = useState(true);
-
- const profileFormSchema = z.object({
- username: z.string(),
- avatarUrl: z.string().nullable(),
- name: z
- .string()
- .trim()
- .min(1, t("you_need_to_add_a_name"))
- .max(FULL_NAME_LENGTH_MAX_LIMIT, {
- message: t("max_limit_allowed_hint", { limit: FULL_NAME_LENGTH_MAX_LIMIT }),
- }),
- email: z.string().email(),
- bio: z.string(),
- secondaryEmails: z.array(
- z.object({
- id: z.number(),
- email: z.string().email(),
- emailVerified: z.union([z.string(), z.null()]).optional(),
- emailPrimary: z.boolean().optional(),
- })
- ),
- });
-
- const formMethods = useForm<FormValues>({
- defaultValues,
- resolver: zodResolver(profileFormSchema),
- });
-
- const {
- fields: secondaryEmailFields,
- remove: deleteSecondaryEmail,
- replace: updateAllSecondaryEmailFields,
- } = useFieldArray({
- control: formMethods.control,
- name: "secondaryEmails",
- keyName: "itemId",
- });
-
- const getUpdatedFormValues = (values: FormValues) => {
- const changedFields = formMethods.formState.dirtyFields?.secondaryEmails || [];
- const updatedValues: FormValues = {
- ...values,
- };
-
- // If the primary email is changed, we will need to update
- const primaryEmailIndex = updatedValues.secondaryEmails.findIndex(
- (secondaryEmail) => secondaryEmail.emailPrimary
- );
- if (primaryEmailIndex >= 0) {
- // Add the new updated value as primary email
- updatedValues.email = updatedValues.secondaryEmails[primaryEmailIndex].email;
- }
-
- // We will only send the emails which have already changed
- const updatedEmails: Email[] = [];
- changedFields.map((field, index) => {
- // If the email changed and if its only secondary email, we add it for updation, the first
- // item in the list is always primary email
- if (field?.email && updatedValues.secondaryEmails[index]?.id) {
- updatedEmails.push(updatedValues.secondaryEmails[index]);
- }
- });
-
- const deletedEmails = (user?.secondaryEmails || []).filter(
- (secondaryEmail) => !updatedValues.secondaryEmails.find((val) => val.id && val.id === secondaryEmail.id)
- );
- const secondaryEmails = [
- ...updatedEmails.map((email) => ({ ...email, isDeleted: false })),
- ...deletedEmails.map((email) => ({ ...email, isDeleted: true })),
- ].map((secondaryEmail) => pick(secondaryEmail, ["id", "email", "isDeleted"]));
-
- return {
- ...updatedValues,
- secondaryEmails,
- };
- };
-
- const handleFormSubmit = (values: FormValues) => {
- onSubmit(getUpdatedFormValues(values));
- };
-
- const onDisconnect = () => {
- handleAccountDisconnect(getUpdatedFormValues(formMethods.getValues()));
- };
-
- const {
- formState: { isSubmitting, isDirty },
- } = formMethods;
-
- const isDisabled = isSubmitting || !isDirty;
- return (
- <Form form={formMethods} handleSubmit={handleFormSubmit}>
- <div className="border-subtle border-x px-4 pb-10 pt-8 sm:px-6">
- <div className="flex items-center">
- <Controller
- control={formMethods.control}
- name="avatarUrl"
- render={({ field: { value, onChange } }) => {
- const showRemoveAvatarButton = value !== null;
- return (
- <>
- <UserAvatar data-testid="profile-upload-avatar" previewSrc={value} size="lg" user={user} />
- <div className="ms-4">
- <h2 className="mb-2 text-sm font-medium">{t("profile_picture")}</h2>
- <div className="flex gap-2">
- <ImageUploader
- target="avatar"
- id="avatar-upload"
- buttonMsg={t("upload_avatar")}
- handleAvatarChange={(newAvatar) => {
- onChange(newAvatar);
- }}
- imageSrc={getUserAvatarUrl({ avatarUrl: value })}
- triggerButtonColor={showRemoveAvatarButton ? "secondary" : "primary"}
- />
-
- {showRemoveAvatarButton && (
- <Button
- color="destructive"
- onClick={() => {
- onChange(null);
- }}>
- {t("remove")}
- </Button>
- )}
- </div>
- </div>
- </>
- );
- }}
- />
- </div>
- {extraField}
- <div className="mt-6">
- <TextField label={t("full_name")} {...formMethods.register("name")} />
- </div>
- <div className="mt-6">
- <Label>{t("email")}</Label>
- {secondaryEmailFields.map((field, index) => (
- <CustomEmailTextField
- key={field.itemId}
- formMethods={formMethods}
- formMethodFieldName={`secondaryEmails.${index}.email` as keyof FormValues}
- errorMessage={get(formMethods.formState.errors, `secondaryEmails.${index}.email.message`)}
- emailVerified={Boolean(field.emailVerified)}
- emailPrimary={field.emailPrimary}
- dataTestId={`profile-form-email-${index}`}
- handleChangePrimary={() => {
- const fields = secondaryEmailFields.map((secondaryField, cIndex) => ({
- ...secondaryField,
- emailPrimary: cIndex === index,
- }));
- updateAllSecondaryEmailFields(fields);
- }}
- handleVerifyEmail={() => handleResendVerifyEmail(field.email)}
- handleItemDelete={() => deleteSecondaryEmail(index)}
- />
- ))}
- <div className="text-default mt-2 flex items-center text-sm">{t("change_email_hint")}</div>
- <Button
- color="minimal"
- StartIcon="plus"
- className="mt-2"
- onClick={() => handleAddSecondaryEmail()}
- data-testid="add-secondary-email">
- {t("add_email")}
- </Button>
- </div>
- <div className="mt-6">
- <Label>{t("about")}</Label>
- <Editor
- getText={() => md.render(formMethods.getValues("bio") || "")}
- setText={(value: string) => {
- formMethods.setValue("bio", turndown(value), { shouldDirty: true });
- }}
- excludedToolbarItems={["blockType"]}
- disableLists
- firstRender={firstRender}
- setFirstRender={setFirstRender}
- height="80px"
- />
- </div>
- {/* // For Non-Cal indentities, we merge the values from DB and the user logging in,
- so essentially there is no point in allowing them to disconnect, since when they log in they will get logged into the same account */}
- {!isCALIdentityProvider && user.email !== user.identityProviderEmail && (
- <div className="mt-6">
- <Label>Connected accounts</Label>
- <div className="flex items-center">
- <span className="text-default text-sm capitalize">{user.identityProvider.toLowerCase()}</span>
- {user.identityProviderEmail && (
- <span className="text-default ml-2 text-sm">{user.identityProviderEmail}</span>
- )}
- <div className="flex flex-1 justify-end">
- <Button color="destructive" onClick={onDisconnect}>
- {t("disconnect")}
- </Button>
- </div>
- </div>
- </div>
- )}
- </div>
- <SectionBottomActions align="end">
- <Button
- loading={isPending}
- disabled={isDisabled}
- color="primary"
- type="submit"
- data-testid="profile-submit-button">
- {t("update")}
- </Button>
- </SectionBottomActions>
- </Form>
- );
-};
-
-ProfileView.getLayout = getLayout;
-ProfileView.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default ProfileView;
+export default Page;
diff --git a/apps/web/pages/settings/organizations/admin-api.tsx b/apps/web/pages/settings/organizations/admin-api.tsx
index 1b59b2a7e53..08a766232d8 100644
--- a/apps/web/pages/settings/organizations/admin-api.tsx
+++ b/apps/web/pages/settings/organizations/admin-api.tsx
@@ -1,9 +1,25 @@
import AdminAPIView from "@calcom/features/ee/organizations/pages/settings/admin-api";
+import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { Meta } from "@calcom/ui";
-import type { CalPageWrapper } from "@components/PageWrapper";
import PageWrapper from "@components/PageWrapper";
-const Page = AdminAPIView as CalPageWrapper;
+const Page = () => {
+ const { t } = useLocale();
+ return (
+ <>
+ <Meta
+ title={`${t("admin")} ${t("api_reference")}`}
+ description={t("leverage_our_api")}
+ borderInShellHeader={false}
+ />
+ <AdminAPIView />
+ </>
+ );
+};
+
Page.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
export default Page;
diff --git a/apps/web/pages/settings/security/impersonation.tsx b/apps/web/pages/settings/security/impersonation.tsx
index b38d09bf4ae..b8a365fdb1e 100644
--- a/apps/web/pages/settings/security/impersonation.tsx
+++ b/apps/web/pages/settings/security/impersonation.tsx
@@ -1,57 +1,13 @@
-"use client";
-
-import { useState } from "react";
-
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { trpc } from "@calcom/trpc/react";
-import type { RouterOutputs } from "@calcom/trpc/react";
-import { Meta, showToast, SettingsToggle, SkeletonContainer, SkeletonText } from "@calcom/ui";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
-const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
- return (
- <SkeletonContainer>
- <Meta title={title} description={description} borderInShellHeader={true} />
- <div className="border-subtle space-y-6 border border-t-0 px-4 py-8 sm:px-6">
- <SkeletonText className="h-8 w-full" />
- </div>
- </SkeletonContainer>
- );
-};
+import ProfileImpersonationViewWrapper from "~/settings/security/impersonation-view";
-const ProfileImpersonationView = ({ user }: { user: RouterOutputs["viewer"]["me"] }) => {
+const Page = () => {
const { t } = useLocale();
- const utils = trpc.useUtils();
- const [disableImpersonation, setDisableImpersonation] = useState<boolean | undefined>(
- user?.disableImpersonation
- );
-
- const mutation = trpc.viewer.updateProfile.useMutation({
- onSuccess: () => {
- showToast(t("profile_updated_successfully"), "success");
- },
- onSettled: () => {
- utils.viewer.me.invalidate();
- },
- onMutate: async ({ disableImpersonation }) => {
- await utils.viewer.me.cancel();
- const previousValue = utils.viewer.me.getData();
-
- setDisableImpersonation(disableImpersonation);
-
- return { previousValue };
- },
- onError: (error, variables, context) => {
- if (context?.previousValue) {
- utils.viewer.me.setData(undefined, context.previousValue);
- setDisableImpersonation(context.previousValue?.disableImpersonation);
- }
- showToast(`${t("error")}, ${error.message}`, "error");
- },
- });
-
return (
<>
<Meta
@@ -59,34 +15,12 @@ const ProfileImpersonationView = ({ user }: { user: RouterOutputs["viewer"]["me"
description={t("impersonation_description")}
borderInShellHeader={true}
/>
- <div>
- <SettingsToggle
- toggleSwitchAtTheEnd={true}
- title={t("user_impersonation_heading")}
- description={t("user_impersonation_description")}
- checked={!disableImpersonation}
- onCheckedChange={(checked) => {
- mutation.mutate({ disableImpersonation: !checked });
- }}
- switchContainerClassName="rounded-t-none border-t-0"
- disabled={mutation.isPending}
- />
- </div>
+ <ProfileImpersonationViewWrapper />
</>
);
};
-const ProfileImpersonationViewWrapper = () => {
- const { data: user, isPending } = trpc.viewer.me.useQuery();
- const { t } = useLocale();
-
- if (isPending || !user)
- return <SkeletonLoader title={t("impersonation")} description={t("impersonation_description")} />;
-
- return <ProfileImpersonationView user={user} />;
-};
-
-ProfileImpersonationViewWrapper.getLayout = getLayout;
-ProfileImpersonationViewWrapper.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default ProfileImpersonationViewWrapper;
+export default Page;
diff --git a/apps/web/pages/settings/security/password.tsx b/apps/web/pages/settings/security/password.tsx
index 48f99f3f48a..ca051d7baed 100644
--- a/apps/web/pages/settings/security/password.tsx
+++ b/apps/web/pages/settings/security/password.tsx
@@ -1,325 +1,23 @@
-"use client";
-
-import { signOut, useSession } from "next-auth/react";
-import { useState } from "react";
-import { useForm } from "react-hook-form";
-
-import { identityProviderNameMap } from "@calcom/features/auth/lib/identityProviderNameMap";
-import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
-import { classNames } from "@calcom/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { IdentityProvider } from "@calcom/prisma/enums";
-import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils";
-import type { RouterOutputs } from "@calcom/trpc/react";
-import { trpc } from "@calcom/trpc/react";
-import {
- Alert,
- Button,
- Form,
- Meta,
- PasswordField,
- Select,
- SettingsToggle,
- showToast,
- SkeletonButton,
- SkeletonContainer,
- SkeletonText,
-} from "@calcom/ui";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
-type ChangePasswordSessionFormValues = {
- oldPassword: string;
- newPassword: string;
- sessionTimeout?: number;
- apiError: string;
-};
-
-interface PasswordViewProps {
- user: RouterOutputs["viewer"]["me"];
-}
-
-const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
- return (
- <SkeletonContainer>
- <Meta title={title} description={description} borderInShellHeader={true} />
- <div className="border-subtle space-y-6 border-x px-4 py-8 sm:px-6">
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
- <SkeletonText className="h-8 w-full" />
- </div>
- <div className="rounded-b-xl">
- <SectionBottomActions align="end">
- <SkeletonButton className="ml-auto h-8 w-20 rounded-md" />
- </SectionBottomActions>
- </div>
- </SkeletonContainer>
- );
-};
+import PasswordViewWrapper from "~/settings/security/password-view";
-const PasswordView = ({ user }: PasswordViewProps) => {
- const { data } = useSession();
+const Page = () => {
const { t } = useLocale();
- const utils = trpc.useUtils();
- const metadata = userMetadataSchema.safeParse(user?.metadata);
- const initialSessionTimeout = metadata.success ? metadata.data?.sessionTimeout : undefined;
-
- const [sessionTimeout, setSessionTimeout] = useState<number | undefined>(initialSessionTimeout);
-
- const sessionMutation = trpc.viewer.updateProfile.useMutation({
- onSuccess: (data) => {
- showToast(t("session_timeout_changed"), "success");
- formMethods.reset(formMethods.getValues());
- setSessionTimeout(data.metadata?.sessionTimeout);
- },
- onSettled: () => {
- utils.viewer.me.invalidate();
- },
- onMutate: async () => {
- await utils.viewer.me.cancel();
- const previousValue = await utils.viewer.me.getData();
- const previousMetadata = userMetadataSchema.safeParse(previousValue?.metadata);
-
- if (previousValue && sessionTimeout && previousMetadata.success) {
- utils.viewer.me.setData(undefined, {
- ...previousValue,
- metadata: { ...previousMetadata?.data, sessionTimeout: sessionTimeout },
- });
- return { previousValue };
- }
- },
- onError: (error, _, context) => {
- if (context?.previousValue) {
- utils.viewer.me.setData(undefined, context.previousValue);
- }
- showToast(`${t("session_timeout_change_error")}, ${error.message}`, "error");
- },
- });
- const passwordMutation = trpc.viewer.auth.changePassword.useMutation({
- onSuccess: () => {
- showToast(t("password_has_been_changed"), "success");
- formMethods.resetField("oldPassword");
- formMethods.resetField("newPassword");
-
- if (data?.user.role === "INACTIVE_ADMIN") {
- /*
- AdminPasswordBanner component relies on the role returned from the session.
- Next-Auth doesn't provide a way to revalidate the session cookie,
- so this a workaround to hide the banner after updating the password.
- discussion: https://github.com/nextauthjs/next-auth/discussions/4229
- */
- signOut({ callbackUrl: "/auth/login" });
- }
- },
- onError: (error) => {
- showToast(`${t("error_updating_password")}, ${t(error.message)}`, "error");
-
- formMethods.setError("apiError", {
- message: t(error.message),
- type: "custom",
- });
- },
- });
-
- const createAccountPasswordMutation = trpc.viewer.auth.createAccountPassword.useMutation({
- onSuccess: () => {
- showToast(t("password_reset_email", { email: user.email }), "success");
- },
- onError: (error) => {
- showToast(`${t("error_creating_account_password")}, ${t(error.message)}`, "error");
- },
- });
-
- const formMethods = useForm<ChangePasswordSessionFormValues>({
- defaultValues: {
- oldPassword: "",
- newPassword: "",
- },
- });
-
- const handleSubmit = (values: ChangePasswordSessionFormValues) => {
- const { oldPassword, newPassword } = values;
-
- if (!oldPassword.length) {
- formMethods.setError(
- "oldPassword",
- { type: "required", message: t("error_required_field") },
- { shouldFocus: true }
- );
- }
-
- if (!newPassword.length) {
- formMethods.setError(
- "newPassword",
- { type: "required", message: t("error_required_field") },
- { shouldFocus: true }
- );
- }
-
- if (oldPassword && newPassword) {
- passwordMutation.mutate({ oldPassword, newPassword });
- }
- };
-
- const timeoutOptions = [5, 10, 15].map((mins) => ({
- label: t("multiple_duration_mins", { count: mins }),
- value: mins,
- }));
-
- const isDisabled = formMethods.formState.isSubmitting || !formMethods.formState.isDirty;
-
- const passwordMinLength = data?.user.role === "USER" ? 7 : 15;
- const isUser = data?.user.role === "USER";
return (
<>
<Meta title={t("password")} description={t("password_description")} borderInShellHeader={true} />
- {user && user.identityProvider !== IdentityProvider.CAL && !user.passwordAdded ? (
- <div className="border-subtle rounded-b-xl border border-t-0">
- <div className="px-4 py-6 sm:px-6">
- <h2 className="font-cal text-emphasis text-lg font-medium leading-6">
- {t("account_managed_by_identity_provider", {
- provider: identityProviderNameMap[user.identityProvider],
- })}
- </h2>
-
- <p className="text-subtle mt-1 text-sm">
- {t("account_managed_by_identity_provider_description", {
- provider: identityProviderNameMap[user.identityProvider],
- })}
- </p>
- <Button
- className="mt-3"
- onClick={() => createAccountPasswordMutation.mutate()}
- loading={createAccountPasswordMutation.isPending}>
- {t("create_account_password")}
- </Button>
- </div>
- </div>
- ) : (
- <Form form={formMethods} handleSubmit={handleSubmit}>
- <div className="border-subtle border-x px-4 py-6 sm:px-6">
- {formMethods.formState.errors.apiError && (
- <div className="pb-6">
- <Alert severity="error" message={formMethods.formState.errors.apiError?.message} />
- </div>
- )}
- <div className="w-full sm:grid sm:grid-cols-2 sm:gap-x-6">
- <div>
- <PasswordField {...formMethods.register("oldPassword")} label={t("old_password")} />
- </div>
- <div>
- <PasswordField
- {...formMethods.register("newPassword", {
- minLength: {
- message: t(isUser ? "password_hint_min" : "password_hint_admin_min"),
- value: passwordMinLength,
- },
- pattern: {
- message: "Should contain a number, uppercase and lowercase letters",
- value: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).*$/gm,
- },
- })}
- label={t("new_password")}
- />
- </div>
- </div>
- <p className="text-default mt-4 w-full text-sm">
- {t("invalid_password_hint", { passwordLength: passwordMinLength })}
- </p>
- </div>
- <SectionBottomActions align="end">
- <Button
- color="primary"
- type="submit"
- loading={passwordMutation.isPending}
- onClick={() => formMethods.clearErrors("apiError")}
- disabled={isDisabled || passwordMutation.isPending || sessionMutation.isPending}>
- {t("update")}
- </Button>
- </SectionBottomActions>
- <div className="mt-6">
- <SettingsToggle
- toggleSwitchAtTheEnd={true}
- title={t("session_timeout")}
- description={t("session_timeout_description")}
- checked={sessionTimeout !== undefined}
- data-testid="session-check"
- onCheckedChange={(e) => {
- if (!e) {
- setSessionTimeout(undefined);
-
- if (metadata.success) {
- sessionMutation.mutate({
- metadata: { ...metadata.data, sessionTimeout: undefined },
- });
- }
- } else {
- setSessionTimeout(10);
- }
- }}
- childrenClassName="lg:ml-0"
- switchContainerClassName={classNames(
- "py-6 px-4 sm:px-6 border-subtle rounded-xl border",
- !!sessionTimeout && "rounded-b-none"
- )}>
- <>
- <div className="border-subtle border-x p-6 pb-8">
- <div className="flex flex-col">
- <p className="text-default mb-2 font-medium">{t("session_timeout_after")}</p>
- <Select
- options={timeoutOptions}
- defaultValue={
- sessionTimeout
- ? timeoutOptions.find((tmo) => tmo.value === sessionTimeout)
- : timeoutOptions[1]
- }
- isSearchable={false}
- className="block h-[36px] !w-auto min-w-0 flex-none rounded-md text-sm"
- onChange={(event) => {
- setSessionTimeout(event?.value);
- }}
- />
- </div>
- </div>
- <SectionBottomActions align="end">
- <Button
- color="primary"
- loading={sessionMutation.isPending}
- onClick={() => {
- sessionMutation.mutate({
- metadata: { ...metadata, sessionTimeout },
- });
- formMethods.clearErrors("apiError");
- }}
- disabled={
- initialSessionTimeout === sessionTimeout ||
- passwordMutation.isPending ||
- sessionMutation.isPending
- }>
- {t("update")}
- </Button>
- </SectionBottomActions>
- </>
- </SettingsToggle>
- </div>
- </Form>
- )}
+ <PasswordViewWrapper />
</>
);
};
-const PasswordViewWrapper = () => {
- const { data: user, isPending } = trpc.viewer.me.useQuery({ includePasswordAdded: true });
- const { t } = useLocale();
- if (isPending || !user)
- return <SkeletonLoader title={t("password")} description={t("password_description")} />;
-
- return <PasswordView user={user} />;
-};
-
-PasswordViewWrapper.getLayout = getLayout;
-PasswordViewWrapper.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default PasswordViewWrapper;
+export default Page;
diff --git a/apps/web/pages/settings/security/sso.tsx b/apps/web/pages/settings/security/sso.tsx
index e20f72e7cd5..93cfa3bfda4 100644
--- a/apps/web/pages/settings/security/sso.tsx
+++ b/apps/web/pages/settings/security/sso.tsx
@@ -1,9 +1,25 @@
import UserSSOView from "@calcom/features/ee/sso/page/user-sso-view";
+import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { Meta } from "@calcom/ui";
-import type { CalPageWrapper } from "@components/PageWrapper";
import PageWrapper from "@components/PageWrapper";
-const Page = UserSSOView as CalPageWrapper;
+const Page = () => {
+ const { t } = useLocale();
+
+ return (
+ <>
+ <Meta
+ title={t("sso_configuration")}
+ description={t("sso_configuration_description")}
+ borderInShellHeader={true}
+ />
+ <UserSSOView />
+ </>
+ );
+};
Page.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
export default Page;
diff --git a/apps/web/pages/settings/security/two-factor-auth.tsx b/apps/web/pages/settings/security/two-factor-auth.tsx
index 30c4adb0cff..d098f2b2728 100644
--- a/apps/web/pages/settings/security/two-factor-auth.tsx
+++ b/apps/web/pages/settings/security/two-factor-auth.tsx
@@ -1,102 +1,22 @@
-"use client";
-
-import { useState } from "react";
-
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { trpc } from "@calcom/trpc/react";
-import {
- Badge,
- Meta,
- SkeletonButton,
- SkeletonContainer,
- SkeletonText,
- Alert,
- SettingsToggle,
-} from "@calcom/ui";
+import { Meta } from "@calcom/ui";
import PageWrapper from "@components/PageWrapper";
-import DisableTwoFactorModal from "@components/settings/DisableTwoFactorModal";
-import EnableTwoFactorModal from "@components/settings/EnableTwoFactorModal";
-
-const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
- return (
- <SkeletonContainer>
- <Meta title={title} description={description} borderInShellHeader={true} />
- <div className="mb-8 mt-6 space-y-6">
- <div className="flex items-center">
- <SkeletonButton className="mr-6 h-8 w-20 rounded-md p-5" />
- <SkeletonText className="h-8 w-full" />
- </div>
- </div>
- </SkeletonContainer>
- );
-};
-const TwoFactorAuthView = () => {
- const utils = trpc.useUtils();
+import TwoFactorAuthView from "~/settings/security/two-factor-auth-view";
+const Page = () => {
const { t } = useLocale();
- const { data: user, isPending } = trpc.viewer.me.useQuery({ includePasswordAdded: true });
-
- const [enableModalOpen, setEnableModalOpen] = useState<boolean>(false);
- const [disableModalOpen, setDisableModalOpen] = useState<boolean>(false);
-
- if (isPending)
- return <SkeletonLoader title={t("2fa")} description={t("set_up_two_factor_authentication")} />;
-
- const isCalProvider = user?.identityProvider === "CAL";
- const canSetupTwoFactor = !isCalProvider && !user?.twoFactorEnabled && !user?.passwordAdded;
return (
<>
<Meta title={t("2fa")} description={t("set_up_two_factor_authentication")} borderInShellHeader={true} />
- {canSetupTwoFactor && <Alert severity="neutral" message={t("2fa_disabled")} />}
- <SettingsToggle
- toggleSwitchAtTheEnd={true}
- data-testid="two-factor-switch"
- title={t("two_factor_auth")}
- description={t("add_an_extra_layer_of_security")}
- checked={user?.twoFactorEnabled ?? false}
- onCheckedChange={() =>
- user?.twoFactorEnabled ? setDisableModalOpen(true) : setEnableModalOpen(true)
- }
- Badge={
- <Badge className="mx-2 text-xs" variant={user?.twoFactorEnabled ? "success" : "gray"}>
- {user?.twoFactorEnabled ? t("enabled") : t("disabled")}
- </Badge>
- }
- switchContainerClassName="rounded-t-none border-t-0"
- />
-
- <EnableTwoFactorModal
- open={enableModalOpen}
- onOpenChange={() => setEnableModalOpen(!enableModalOpen)}
- onEnable={() => {
- setEnableModalOpen(false);
- utils.viewer.me.invalidate();
- }}
- onCancel={() => {
- setEnableModalOpen(false);
- }}
- />
-
- <DisableTwoFactorModal
- open={disableModalOpen}
- disablePassword={!isCalProvider}
- onOpenChange={() => setDisableModalOpen(!disableModalOpen)}
- onDisable={() => {
- setDisableModalOpen(false);
- utils.viewer.me.invalidate();
- }}
- onCancel={() => {
- setDisableModalOpen(false);
- }}
- />
+ <TwoFactorAuthView />
</>
);
};
-TwoFactorAuthView.getLayout = getLayout;
-TwoFactorAuthView.PageWrapper = PageWrapper;
+Page.getLayout = getLayout;
+Page.PageWrapper = PageWrapper;
-export default TwoFactorAuthView;
+export default Page;
diff --git a/packages/features/apps/AdminAppsList.tsx b/packages/features/apps/AdminAppsList.tsx
index b40c1ec91e9..34749b1cd68 100644
--- a/packages/features/apps/AdminAppsList.tsx
+++ b/packages/features/apps/AdminAppsList.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import { zodResolver } from "@hookform/resolvers/zod";
// eslint-disable-next-line no-restricted-imports
import { noop } from "lodash";
diff --git a/packages/features/ee/common/components/LicenseRequired.tsx b/packages/features/ee/common/components/LicenseRequired.tsx
index e48af649631..4b8d23c73d4 100644
--- a/packages/features/ee/common/components/LicenseRequired.tsx
+++ b/packages/features/ee/common/components/LicenseRequired.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import { useSession } from "next-auth/react";
import type { AriaRole, ComponentType } from "react";
import React, { Fragment, useEffect } from "react";
@@ -70,9 +72,11 @@ export const withLicenseRequired =
// eslint-disable-next-line react/display-name
(hocProps: T) =>
(
- <LicenseRequired>
- <Component {...hocProps} />
- </LicenseRequired>
+ <div>
+ <LicenseRequired>
+ <Component {...hocProps} />
+ </LicenseRequired>
+ </div>
);
export default LicenseRequired;
diff --git a/packages/features/ee/organizations/pages/settings/admin-api.tsx b/packages/features/ee/organizations/pages/settings/admin-api.tsx
index 6264d1506d6..9c776bb06da 100644
--- a/packages/features/ee/organizations/pages/settings/admin-api.tsx
+++ b/packages/features/ee/organizations/pages/settings/admin-api.tsx
@@ -1,12 +1,11 @@
"use client";
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
-import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
import { UpgradeTip } from "@calcom/features/tips";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { Button, Icon, Meta, ButtonGroup } from "@calcom/ui";
+import { Button, Icon, ButtonGroup } from "@calcom/ui";
-const AdminAPIViewWrapper = () => {
+export const AdminAPIView = () => {
const { t } = useLocale();
const features = [
@@ -28,11 +27,6 @@ const AdminAPIViewWrapper = () => {
];
return (
<LicenseRequired>
- <Meta
- title={`${t("admin")} ${t("api_reference")}`}
- description={t("leverage_our_api")}
- borderInShellHeader={false}
- />
<div className="mt-8">
<UpgradeTip
plan="enterprise"
@@ -59,6 +53,4 @@ const AdminAPIViewWrapper = () => {
);
};
-AdminAPIViewWrapper.getLayout = getLayout;
-
-export default AdminAPIViewWrapper;
+export default AdminAPIView;
diff --git a/packages/features/ee/organizations/pages/settings/admin/AdminOrgEditPage.tsx b/packages/features/ee/organizations/pages/settings/admin/AdminOrgEditPage.tsx
index 3a22b2af31a..6ead4803aea 100644
--- a/packages/features/ee/organizations/pages/settings/admin/AdminOrgEditPage.tsx
+++ b/packages/features/ee/organizations/pages/settings/admin/AdminOrgEditPage.tsx
@@ -1,44 +1,14 @@
+"use client";
+
import type { Team } from "@prisma/client";
import { useRouter } from "next/navigation";
import { useForm } from "react-hook-form";
-import { z } from "zod";
+import type { z } from "zod";
-import NoSSR from "@calcom/core/components/NoSSR";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
import type { orgSettingsSchema } from "@calcom/prisma/zod-utils";
import { trpc } from "@calcom/trpc/react";
-import { Button, Form, Meta, TextField, showToast } from "@calcom/ui";
-
-import { getLayout } from "../../../../../settings/layouts/SettingsLayout";
-import LicenseRequired from "../../../../common/components/LicenseRequired";
-
-const paramsSchema = z.object({ id: z.coerce.number() });
-
-const OrgEditPage = () => {
- const params = useParamsWithFallback();
- const parsedParams = paramsSchema.safeParse(params);
-
- if (!parsedParams.success) return <div>Invalid id</div>;
-
- return <OrgEditView orgId={parsedParams.data.id} />;
-};
-
-const OrgEditView = ({ orgId }: { orgId: number }) => {
- const [org] = trpc.viewer.organizations.adminGet.useSuspenseQuery({ id: orgId });
-
- return (
- <LicenseRequired>
- <Meta
- title={`Editing organization: ${org.name}`}
- description="Here you can edit a current organization."
- />
- <NoSSR>
- <OrgForm org={org} />
- </NoSSR>
- </LicenseRequired>
- );
-};
+import { Button, Form, TextField, showToast } from "@calcom/ui";
type FormValues = {
name: Team["name"];
@@ -46,7 +16,7 @@ type FormValues = {
organizationSettings: z.infer<typeof orgSettingsSchema>;
};
-const OrgForm = ({
+export const OrgForm = ({
org,
}: {
org: FormValues & {
@@ -108,6 +78,4 @@ const OrgForm = ({
);
};
-OrgEditPage.getLayout = getLayout;
-
-export default OrgEditPage;
+export default OrgForm;
diff --git a/packages/features/ee/organizations/pages/settings/admin/AdminOrgPage.tsx b/packages/features/ee/organizations/pages/settings/admin/AdminOrgPage.tsx
index 0e42e9230b7..d931de362a8 100644
--- a/packages/features/ee/organizations/pages/settings/admin/AdminOrgPage.tsx
+++ b/packages/features/ee/organizations/pages/settings/admin/AdminOrgPage.tsx
@@ -3,39 +3,18 @@
import { Trans } from "next-i18next";
import { useState } from "react";
-import NoSSR from "@calcom/core/components/NoSSR";
-import LicenseRequired from "@calcom/ee/common/components/LicenseRequired";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
-import {
- Badge,
- ConfirmationDialogContent,
- Dialog,
- DropdownActions,
- Meta,
- showToast,
- Table,
-} from "@calcom/ui";
+import { Badge, ConfirmationDialogContent, Dialog, DropdownActions, showToast, Table } from "@calcom/ui";
-import { getLayout } from "../../../../../settings/layouts/SettingsLayout";
import { subdomainSuffix } from "../../../../organizations/lib/orgDomains";
const { Body, Cell, ColumnTitle, Header, Row } = Table;
-function AdminOrgTable() {
+export function AdminOrgTable() {
const { t } = useLocale();
const utils = trpc.useUtils();
const [data] = trpc.viewer.organizations.adminGetAll.useSuspenseQuery();
- const verifyMutation = trpc.viewer.organizations.adminVerify.useMutation({
- onSuccess: async (_data, variables) => {
- showToast(t("org_has_been_processed"), "success");
- await invalidateQueries(utils, variables);
- },
- onError: (err) => {
- console.error(err.message);
- showToast(t("org_error_processing"), "error");
- },
- });
const updateMutation = trpc.viewer.organizations.adminUpdate.useMutation({
onSuccess: async (_data, variables) => {
showToast(t("org_has_been_processed"), "success");
@@ -240,21 +219,7 @@ function AdminOrgTable() {
);
}
-const AdminOrgList = () => {
- const { t } = useLocale();
- return (
- <LicenseRequired>
- <Meta title={t("organizations")} description={t("orgs_page_description")} />
- <NoSSR>
- <AdminOrgTable />
- </NoSSR>
- </LicenseRequired>
- );
-};
-
-AdminOrgList.getLayout = getLayout;
-
-export default AdminOrgList;
+export default AdminOrgTable;
const DeleteOrgDialog = ({
org,
diff --git a/packages/features/ee/sso/page/user-sso-view.tsx b/packages/features/ee/sso/page/user-sso-view.tsx
index 84b3d6bf8cd..11566247ec8 100644
--- a/packages/features/ee/sso/page/user-sso-view.tsx
+++ b/packages/features/ee/sso/page/user-sso-view.tsx
@@ -5,9 +5,7 @@ import { useEffect } from "react";
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { Meta } from "@calcom/ui";
-import { getLayout } from "../../../settings/layouts/SettingsLayout";
import SSOConfiguration from "../components/SSOConfiguration";
const SAMLSSO = () => {
@@ -22,16 +20,9 @@ const SAMLSSO = () => {
return (
<div className="bg-default w-full sm:mx-0">
- <Meta
- title={t("sso_configuration")}
- description={t("sso_configuration_description")}
- borderInShellHeader={true}
- />
<SSOConfiguration teamId={null} />
</div>
);
};
-SAMLSSO.getLayout = getLayout;
-
export default SAMLSSO;
diff --git a/packages/features/ee/users/components/UsersTable.tsx b/packages/features/ee/users/components/UsersTable.tsx
index fc8bc52545f..291d95008f3 100644
--- a/packages/features/ee/users/components/UsersTable.tsx
+++ b/packages/features/ee/users/components/UsersTable.tsx
@@ -150,7 +150,7 @@ function UsersTableBare() {
const [userToDelete, setUserToDelete] = useState<number | null>(null);
return (
- <>
+ <div>
<TextField
placeholder="username or email"
label="Search"
@@ -293,7 +293,7 @@ function UsersTableBare() {
</DialogContent>
</Dialog>
)}
- </>
+ </div>
);
}
diff --git a/packages/features/ee/users/pages/users-add-view.tsx b/packages/features/ee/users/pages/users-add-view.tsx
index 9ebc493b05a..01d67ad759b 100644
--- a/packages/features/ee/users/pages/users-add-view.tsx
+++ b/packages/features/ee/users/pages/users-add-view.tsx
@@ -4,9 +4,8 @@ import { usePathname, useRouter } from "next/navigation";
import { getParserWithGeneric } from "@calcom/prisma/zod-utils";
import { trpc } from "@calcom/trpc/react";
-import { Meta, showToast } from "@calcom/ui";
+import { showToast } from "@calcom/ui";
-import { getLayout } from "../../../settings/layouts/SettingsLayout";
import LicenseRequired from "../../common/components/LicenseRequired";
import { UserForm } from "../components/UserForm";
import { userBodySchema } from "../schemas/userBodySchema";
@@ -30,20 +29,19 @@ const UsersAddView = () => {
},
});
return (
- <LicenseRequired>
- <Meta title="Add new user" description="Here you can add a new user." />
- <UserForm
- submitLabel="Add user"
- onSubmit={async (values) => {
- const parser = getParserWithGeneric(userBodySchema);
- const parsedValues = parser(values);
- mutation.mutate(parsedValues);
- }}
- />
- </LicenseRequired>
+ <div>
+ <LicenseRequired>
+ <UserForm
+ submitLabel="Add user"
+ onSubmit={async (values) => {
+ const parser = getParserWithGeneric(userBodySchema);
+ const parsedValues = parser(values);
+ mutation.mutate(parsedValues);
+ }}
+ />
+ </LicenseRequired>
+ </div>
);
};
-UsersAddView.getLayout = getLayout;
-
export default UsersAddView;
diff --git a/packages/features/ee/users/pages/users-edit-view.tsx b/packages/features/ee/users/pages/users-edit-view.tsx
index 00ed0d7b92d..c2146074934 100644
--- a/packages/features/ee/users/pages/users-edit-view.tsx
+++ b/packages/features/ee/users/pages/users-edit-view.tsx
@@ -7,13 +7,14 @@ import NoSSR from "@calcom/core/components/NoSSR";
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
import { getParserWithGeneric } from "@calcom/prisma/zod-utils";
import { trpc } from "@calcom/trpc/react";
-import { Meta, showToast } from "@calcom/ui";
+import { showToast } from "@calcom/ui";
-import { getLayout } from "../../../settings/layouts/SettingsLayout";
import LicenseRequired from "../../common/components/LicenseRequired";
import { UserForm } from "../components/UserForm";
import { userBodySchema } from "../schemas/userBodySchema";
+import type { UserAdminRouterOutputs } from "../server/trpc-router";
+type User = UserAdminRouterOutputs["get"]["user"];
const userIdSchema = z.object({ id: z.coerce.number() });
const UsersEditPage = () => {
@@ -22,14 +23,22 @@ const UsersEditPage = () => {
if (!input.success) return <div>Invalid input</div>;
- return <UsersEditView userId={input.data.id} />;
+ const [data] = trpc.viewer.users.get.useSuspenseQuery({ userId: input.data.id });
+ const { user } = data;
+
+ return (
+ <LicenseRequired>
+ <NoSSR>
+ <UsersEditView user={user} />
+ </NoSSR>
+ </LicenseRequired>
+ );
};
-const UsersEditView = ({ userId }: { userId: number }) => {
+export const UsersEditView = ({ user }: { user: User }) => {
const pathname = usePathname();
const router = useRouter();
- const [data] = trpc.viewer.users.get.useSuspenseQuery({ userId });
- const { user } = data;
+
const utils = trpc.useUtils();
const mutation = trpc.viewer.users.update.useMutation({
onSuccess: async () => {
@@ -43,29 +52,22 @@ const UsersEditView = ({ userId }: { userId: number }) => {
},
});
return (
- <LicenseRequired>
- <Meta title={`Editing user: ${user.username}`} description="Here you can edit a current user." />
- <NoSSR>
- <UserForm
- key={JSON.stringify(user)}
- onSubmit={(values) => {
- const parser = getParserWithGeneric(userBodySchema);
- const parsedValues = parser(values);
- const data: Partial<typeof parsedValues & { userId: number }> = {
- ...parsedValues,
- userId: user.id,
- };
- // Don't send username if it's the same as the current one
- if (user.username === data.username) delete data.username;
- mutation.mutate(data);
- }}
- defaultValues={user}
- />
- </NoSSR>
- </LicenseRequired>
+ <UserForm
+ key={JSON.stringify(user)}
+ onSubmit={(values) => {
+ const parser = getParserWithGeneric(userBodySchema);
+ const parsedValues = parser(values);
+ const data: Partial<typeof parsedValues & { userId: number }> = {
+ ...parsedValues,
+ userId: user.id,
+ };
+ // Don't send username if it's the same as the current one
+ if (user.username === data.username) delete data.username;
+ mutation.mutate(data);
+ }}
+ defaultValues={user}
+ />
);
};
-UsersEditPage.getLayout = getLayout;
-
-export default UsersEditPage;
+export default UsersEditView;
diff --git a/packages/features/ee/users/pages/users-listing-view.tsx b/packages/features/ee/users/pages/users-listing-view.tsx
index 51b8dfa229f..ee9fd5038ea 100644
--- a/packages/features/ee/users/pages/users-listing-view.tsx
+++ b/packages/features/ee/users/pages/users-listing-view.tsx
@@ -1,7 +1,6 @@
"use client";
import NoSSR from "@calcom/core/components/NoSSR";
-import { Button, Meta } from "@calcom/ui";
import { getLayout } from "../../../settings/layouts/SettingsLayout";
import { UsersTable } from "../components/UsersTable";
@@ -9,17 +8,6 @@ import { UsersTable } from "../components/UsersTable";
const DeploymentUsersListPage = () => {
return (
<>
- <Meta
- title="Users"
- description="A list of all the users in your account including their name, title, email and role."
- CTA={
- <div className="mt-4 space-x-5 sm:ml-16 sm:mt-0 sm:flex-none">
- {/* TODO: Add import users functionality */}
- {/* <Button disabled>Import users</Button> */}
- <Button href="/settings/admin/users/add">Add user</Button>
- </div>
- }
- />
<NoSSR>
<UsersTable />
</NoSSR>
diff --git a/packages/features/flags/pages/flag-listing-view.tsx b/packages/features/flags/pages/flag-listing-view.tsx
index 1bd0c3443ea..23f08ed768e 100644
--- a/packages/features/flags/pages/flag-listing-view.tsx
+++ b/packages/features/flags/pages/flag-listing-view.tsx
@@ -1,7 +1,9 @@
+"use client";
+
import { Suspense } from "react";
import NoSSR from "@calcom/core/components/NoSSR";
-import { Meta, SkeletonText, SkeletonContainer } from "@calcom/ui";
+import { SkeletonText, SkeletonContainer } from "@calcom/ui";
import { FlagAdminList } from "../components/FlagAdminList";
@@ -18,13 +20,10 @@ const SkeletonLoader = () => {
export const FlagListingView = () => {
return (
- <>
- <Meta title="Feature Flags" description="Here you can toggle your Cal.com instance features." />
- <NoSSR>
- <Suspense fallback={<SkeletonLoader />}>
- <FlagAdminList />
- </Suspense>
- </NoSSR>
- </>
+ <NoSSR>
+ <Suspense fallback={<SkeletonLoader />}>
+ <FlagAdminList />
+ </Suspense>
+ </NoSSR>
);
};
diff --git a/packages/features/settings/appDir/SettingsHeader.tsx b/packages/features/settings/appDir/SettingsHeader.tsx
new file mode 100644
index 00000000000..8299b0d7fc4
--- /dev/null
+++ b/packages/features/settings/appDir/SettingsHeader.tsx
@@ -0,0 +1,57 @@
+import React, { Suspense } from "react";
+
+import { classNames } from "@calcom/lib";
+import { Icon } from "@calcom/ui";
+
+interface HeaderProps {
+ children: React.ReactNode;
+ title?: string;
+ description?: string;
+ CTA?: React.ReactNode;
+ borderInShellHeader?: boolean;
+ backButton?: boolean;
+}
+
+export default function Header({
+ children,
+ title,
+ description,
+ CTA,
+ borderInShellHeader,
+ backButton,
+}: HeaderProps) {
+ return (
+ <div>
+ <header
+ className={classNames(
+ "border-subtle mx-auto block justify-between sm:flex",
+ borderInShellHeader && "rounded-t-lg border px-4 py-6 sm:px-6",
+ borderInShellHeader === undefined && "mb-8 border-b pb-8"
+ )}>
+ <div className="flex w-full items-center">
+ {backButton && (
+ <a href="javascript:history.back()">
+ <Icon name="arrow-left" className="mr-7" />
+ </a>
+ )}
+ <div>
+ {title ? (
+ <h1 className="font-cal text-emphasis mb-1 text-xl font-semibold leading-5 tracking-wide">
+ {title}
+ </h1>
+ ) : (
+ <div className="bg-emphasis mb-1 h-5 w-24 animate-pulse rounded-lg" />
+ )}
+ {description ? (
+ <p className="text-default text-sm ltr:mr-4 rtl:ml-4">{description}</p>
+ ) : (
+ <div className="bg-emphasis h-5 w-32 animate-pulse rounded-lg" />
+ )}
+ </div>
+ <div className="ms-auto flex-shrink-0">{CTA}</div>
+ </div>
+ </header>
+ <Suspense fallback={<Icon name="loader" />}>{children}</Suspense>
+ </div>
+ );
+}
diff --git a/packages/features/settings/layouts/SettingsLayoutAppDir.tsx b/packages/features/settings/appDir/SettingsLayoutAppDir.tsx
similarity index 62%
rename from packages/features/settings/layouts/SettingsLayoutAppDir.tsx
rename to packages/features/settings/appDir/SettingsLayoutAppDir.tsx
index c20fdbfd705..d96b7f79722 100644
--- a/packages/features/settings/layouts/SettingsLayoutAppDir.tsx
+++ b/packages/features/settings/appDir/SettingsLayoutAppDir.tsx
@@ -5,7 +5,7 @@ import { useSession } from "next-auth/react";
import Link from "next/link";
import { usePathname, useRouter } from "next/navigation";
import type { ComponentProps } from "react";
-import React, { Suspense, useEffect, useState } from "react";
+import React, { useEffect, useState, useMemo } from "react";
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
import Shell from "@calcom/features/shell/Shell";
@@ -18,7 +18,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { IdentityProvider, MembershipRole, UserPermissionRole } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
import type { VerticalTabItemProps } from "@calcom/ui";
-import { Badge, Button, ErrorBoundary, Icon, Skeleton, useMeta, VerticalTabItem } from "@calcom/ui";
+import { Badge, Button, ErrorBoundary, Icon, Skeleton, VerticalTabItem } from "@calcom/ui";
const tabs: VerticalTabItemProps[] = [
{
@@ -31,6 +31,7 @@ const tabs: VerticalTabItemProps[] = [
{ name: "calendars", href: "/settings/my-account/calendars" },
{ name: "conferencing", href: "/settings/my-account/conferencing" },
{ name: "appearance", href: "/settings/my-account/appearance" },
+ { name: "out_of_office", href: "/settings/my-account/out-of-office" },
// TODO
// { name: "referrals", href: "/settings/my-account/referrals" },
],
@@ -59,6 +60,7 @@ const tabs: VerticalTabItemProps[] = [
//
{ name: "webhooks", href: "/settings/developer/webhooks" },
{ name: "api_keys", href: "/settings/developer/api-keys" },
+ { name: "admin_api", href: "/settings/organizations/admin-api" },
// TODO: Add profile level for embeds
// { name: "embeds", href: "/v2/settings/developer/embeds" },
],
@@ -80,13 +82,26 @@ const tabs: VerticalTabItemProps[] = [
href: "/settings/organizations/members",
},
{
- name: "appearance",
- href: "/settings/organizations/appearance",
+ name: "privacy",
+ href: "/settings/organizations/privacy",
},
{
name: "billing",
href: "/settings/organizations/billing",
},
+ { name: "OAuth Clients", href: "/settings/organizations/platform/oauth-clients" },
+ {
+ name: "SSO",
+ href: "/settings/organizations/sso",
+ },
+ {
+ name: "directory_sync",
+ href: "/settings/organizations/dsync",
+ },
+ {
+ name: "admin_api",
+ href: "https://cal.com/docs/enterprise-features/api/api-reference/bookings#admin-access",
+ },
],
},
{
@@ -95,6 +110,12 @@ const tabs: VerticalTabItemProps[] = [
icon: "users",
children: [],
},
+ {
+ name: "other_teams",
+ href: "/settings/organizations/teams/other",
+ icon: "users",
+ children: [],
+ },
{
name: "admin",
href: "/settings/admin",
@@ -114,57 +135,92 @@ const tabs: VerticalTabItemProps[] = [
];
tabs.find((tab) => {
- // Add "SAML SSO" to the tab
if (tab.name === "security" && !HOSTED_CAL_FEATURES) {
tab.children?.push({ name: "sso_configuration", href: "/settings/security/sso" });
+ // TODO: Enable dsync for self hosters
+ // tab.children?.push({ name: "directory_sync", href: "/settings/security/dsync" });
}
});
// The following keys are assigned to admin only
const adminRequiredKeys = ["admin"];
const organizationRequiredKeys = ["organization"];
+const organizationAdminKeys = ["privacy", "billing", "OAuth Clients", "SSO", "directory_sync"];
const useTabs = () => {
const session = useSession();
- const { data: user } = trpc.viewer.me.useQuery();
+ const { data: user } = trpc.viewer.me.useQuery({ includePasswordAdded: true });
const orgBranding = useOrgBranding();
-
const isAdmin = session.data?.user.role === UserPermissionRole.ADMIN;
+ const isOrgAdminOrOwner =
+ orgBranding?.role === MembershipRole.ADMIN || orgBranding?.role === MembershipRole.OWNER;
+
+ const processTabsMemod = useMemo(() => {
+ const processedTabs = tabs.map((tab) => {
+ if (tab.href === "/settings/my-account") {
+ return {
+ ...tab,
+ name: user?.name || "my_account",
+ icon: undefined,
+ avatar: getUserAvatarUrl(user),
+ };
+ } else if (tab.href === "/settings/organizations") {
+ const newArray = (tab?.children ?? []).filter(
+ (child) => isOrgAdminOrOwner || !organizationAdminKeys.includes(child.name)
+ );
+
+ // TODO: figure out feature flag as it doesnt cause a re-render of the component when loaded.
+ // You have to refresh the page to see the changes.
+ if (true) {
+ newArray.splice(4, 0, {
+ name: "attributes",
+ href: "/settings/organizations/attributes",
+ });
+ }
+
+ return {
+ ...tab,
+ children: newArray,
+ name: orgBranding?.name || "organization",
+ avatar: getPlaceholderAvatar(orgBranding?.logoUrl, orgBranding?.name),
+ };
+ } else if (
+ tab.href === "/settings/security" &&
+ user?.identityProvider === IdentityProvider.GOOGLE &&
+ !user?.twoFactorEnabled &&
+ !user?.passwordAdded
+ ) {
+ const filtered = tab?.children?.filter(
+ (childTab) => childTab.href !== "/settings/security/two-factor-auth"
+ );
+ return { ...tab, children: filtered };
+ } else if (tab.href === "/settings/developer") {
+ const filtered = tab?.children?.filter(
+ (childTab) => isOrgAdminOrOwner || childTab.name !== "admin_api"
+ );
+ return { ...tab, children: filtered };
+ }
+ return tab;
+ });
- tabs.map((tab) => {
- if (tab.href === "/settings/my-account") {
- tab.name = user?.name || "my_account";
- tab.icon = undefined;
- tab.avatar = getUserAvatarUrl(user);
- } else if (tab.href === "/settings/organizations") {
- tab.name = orgBranding?.name || "organization";
- tab.avatar = `${orgBranding?.fullDomain}/org/${orgBranding?.slug}/avatar.png`;
- } else if (
- tab.href === "/settings/security" &&
- user?.identityProvider === IdentityProvider.GOOGLE &&
- !user?.twoFactorEnabled
- ) {
- tab.children = tab?.children?.filter(
- (childTab) => childTab.href !== "/settings/security/two-factor-auth"
- );
- }
- return tab;
- });
+ // check if name is in adminRequiredKeys
+ return processedTabs.filter((tab) => {
+ if (organizationRequiredKeys.includes(tab.name)) return !!orgBranding;
+ if (tab.name === "other_teams" && !isOrgAdminOrOwner) return false;
- // check if name is in adminRequiredKeys
- return tabs.filter((tab) => {
- if (organizationRequiredKeys.includes(tab.name)) return !!session.data?.user?.org;
+ if (isAdmin) return true;
+ return !adminRequiredKeys.includes(tab.name);
+ });
+ }, [isAdmin, orgBranding, isOrgAdminOrOwner, user]);
- if (isAdmin) return true;
- return !adminRequiredKeys.includes(tab.name);
- });
+ return processTabsMemod;
};
const BackButtonInSidebar = ({ name }: { name: string }) => {
return (
<Link
href="/"
- className="hover:bg-subtle [&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis group-hover:text-default text-emphasis group my-6 flex h-6 max-h-6 w-full flex-row items-center rounded-md px-3 py-2 text-sm font-medium leading-4 transition"
+ className="hover:bg-subtle todesktop:mt-10 [&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis group-hover:text-default text-emphasis group my-6 flex h-6 max-h-6 w-full flex-row items-center rounded-md px-3 py-2 text-sm font-medium leading-4 transition"
data-testid={`vertical-tab-${name}`}>
<Icon
name="arrow-left"
@@ -183,6 +239,146 @@ interface SettingsSidebarContainerProps {
bannersHeight?: number;
}
+const TeamListCollapsible = () => {
+ const { data: teams } = trpc.viewer.teams.list.useQuery();
+ const { t } = useLocale();
+ const [teamMenuState, setTeamMenuState] =
+ useState<{ teamId: number | undefined; teamMenuOpen: boolean }[]>();
+ const searchParams = useCompatSearchParams();
+ useEffect(() => {
+ if (teams) {
+ const teamStates = teams?.map((team) => ({
+ teamId: team.id,
+ teamMenuOpen: String(team.id) === searchParams?.get("id"),
+ }));
+ setTeamMenuState(teamStates);
+ setTimeout(() => {
+ const tabMembers = Array.from(document.getElementsByTagName("a")).filter(
+ (bottom) => bottom.dataset.testid === "vertical-tab-Members"
+ )[1];
+ tabMembers?.scrollIntoView({ behavior: "smooth" });
+ }, 100);
+ }
+ }, [searchParams?.get("id"), teams]);
+
+ return (
+ <>
+ {teams &&
+ teamMenuState &&
+ teams.map((team, index: number) => {
+ if (!teamMenuState[index]) {
+ return null;
+ }
+ if (teamMenuState.some((teamState) => teamState.teamId === team.id))
+ return (
+ <Collapsible
+ className="cursor-pointer"
+ key={team.id}
+ open={teamMenuState[index].teamMenuOpen}
+ onOpenChange={() =>
+ setTeamMenuState([
+ ...teamMenuState,
+ (teamMenuState[index] = {
+ ...teamMenuState[index],
+ teamMenuOpen: !teamMenuState[index].teamMenuOpen,
+ }),
+ ])
+ }>
+ <CollapsibleTrigger asChild>
+ <div
+ className="hover:bg-subtle [&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis text-default flex h-9 w-full flex-row items-center rounded-md px-2 py-[10px] text-left text-sm font-medium leading-none transition"
+ onClick={() =>
+ setTeamMenuState([
+ ...teamMenuState,
+ (teamMenuState[index] = {
+ ...teamMenuState[index],
+ teamMenuOpen: !teamMenuState[index].teamMenuOpen,
+ }),
+ ])
+ }>
+ <div className="me-3">
+ {teamMenuState[index].teamMenuOpen ? (
+ <Icon name="chevron-down" className="h-4 w-4" />
+ ) : (
+ <Icon name="chevron-right" className="h-4 w-4" />
+ )}
+ </div>
+ {!team.parentId && (
+ <img
+ src={getPlaceholderAvatar(team.logoUrl, team.name)}
+ className="h-[16px] w-[16px] self-start rounded-full stroke-[2px] ltr:mr-2 rtl:ml-2 md:mt-0"
+ alt={team.name || "Team logo"}
+ />
+ )}
+ <p className="w-1/2 truncate leading-normal">{team.name}</p>
+ {!team.accepted && (
+ <Badge className="ms-3" variant="orange">
+ Inv.
+ </Badge>
+ )}
+ </div>
+ </CollapsibleTrigger>
+ <CollapsibleContent className="space-y-0.5">
+ {team.accepted && (
+ <VerticalTabItem
+ name={t("profile")}
+ href={`/settings/teams/${team.id}/profile`}
+ textClassNames="px-3 text-emphasis font-medium text-sm"
+ disableChevron
+ />
+ )}
+ <VerticalTabItem
+ name={t("members")}
+ href={`/settings/teams/${team.id}/members`}
+ textClassNames="px-3 text-emphasis font-medium text-sm"
+ disableChevron
+ />
+ <VerticalTabItem
+ name={t("event_types_page_title")}
+ href={`/event-types?teamIds=${team.id}`}
+ textClassNames="px-3 text-emphasis font-medium text-sm"
+ disableChevron
+ />
+ {(team.role === MembershipRole.OWNER ||
+ team.role === MembershipRole.ADMIN ||
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore this exists wtf?
+ (team.isOrgAdmin && team.isOrgAdmin)) && (
+ <>
+ {/* TODO */}
+ {/* <VerticalTabItem
+ name={t("general")}
+ href={`${WEBAPP_URL}/settings/my-account/appearance`}
+ textClassNames="px-3 text-emphasis font-medium text-sm"
+ disableChevron
+ /> */}
+ <VerticalTabItem
+ name={t("appearance")}
+ href={`/settings/teams/${team.id}/appearance`}
+ textClassNames="px-3 text-emphasis font-medium text-sm"
+ disableChevron
+ />
+ {/* Hide if there is a parent ID */}
+ {!team.parentId ? (
+ <>
+ <VerticalTabItem
+ name={t("billing")}
+ href={`/settings/teams/${team.id}/billing`}
+ textClassNames="px-3 text-emphasis font-medium text-sm"
+ disableChevron
+ />
+ </>
+ ) : null}
+ </>
+ )}
+ </CollapsibleContent>
+ </Collapsible>
+ );
+ })}
+ </>
+ );
+};
+
const SettingsSidebarContainer = ({
className = "",
navigationIsOpenedOnMobile,
@@ -191,37 +387,20 @@ const SettingsSidebarContainer = ({
const searchParams = useCompatSearchParams();
const { t } = useLocale();
const tabsWithPermissions = useTabs();
- const [teamMenuState, setTeamMenuState] =
- useState<{ teamId: number | undefined; teamMenuOpen: boolean }[]>();
const [otherTeamMenuState, setOtherTeamMenuState] = useState<
{
teamId: number | undefined;
teamMenuOpen: boolean;
}[]
>();
- const { data: teams } = trpc.viewer.teams.list.useQuery();
const session = useSession();
const { data: currentOrg } = trpc.viewer.organizations.listCurrent.useQuery(undefined, {
enabled: !!session.data?.user?.org,
});
- const { data: otherTeams } = trpc.viewer.organizations.listOtherTeams.useQuery();
-
- useEffect(() => {
- if (teams) {
- const teamStates = teams?.map((team) => ({
- teamId: team.id,
- teamMenuOpen: String(team.id) === searchParams?.get("id"),
- }));
- setTeamMenuState(teamStates);
- setTimeout(() => {
- const tabMembers = Array.from(document.getElementsByTagName("a")).filter(
- (bottom) => bottom.dataset.testid === "vertical-tab-Members"
- )[1];
- tabMembers?.scrollIntoView({ behavior: "smooth" });
- }, 100);
- }
- }, [searchParams?.get("id"), teams]);
+ const { data: otherTeams } = trpc.viewer.organizations.listOtherTeams.useQuery(undefined, {
+ enabled: !!session.data?.user?.org,
+ });
// Same as above but for otherTeams
useEffect(() => {
@@ -244,17 +423,6 @@ const SettingsSidebarContainer = ({
const isOrgAdminOrOwner =
currentOrg && currentOrg?.user?.role && ["OWNER", "ADMIN"].includes(currentOrg?.user?.role);
- if (isOrgAdminOrOwner) {
- const teamsIndex = tabsWithPermissions.findIndex((tab) => tab.name === "teams");
-
- tabsWithPermissions.splice(teamsIndex + 1, 0, {
- name: "other_teams",
- href: "/settings/organizations/teams/other",
- icon: "users",
- children: [],
- });
- }
-
return (
<nav
style={{ maxHeight: `calc(100vh - ${bannersHeight}px)`, top: `${bannersHeight}px` }}
@@ -274,38 +442,38 @@ const SettingsSidebarContainer = ({
{!["teams", "other_teams"].includes(tab.name) && (
<React.Fragment key={tab.href}>
<div className={`${!tab.children?.length ? "!mb-3" : ""}`}>
- <div className="[&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis text-default group flex h-9 w-full flex-row items-center rounded-md px-2 text-sm font-medium leading-none">
+ <div className="[&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis text-default group flex h-7 w-full flex-row items-center rounded-md px-2 text-sm font-medium leading-none">
{tab && tab.icon && (
<Icon
name={tab.icon}
- className="h-[16px] w-[16px] stroke-[2px] ltr:mr-3 rtl:ml-3 md:mt-0"
+ className="text-subtle h-[16px] w-[16px] stroke-[2px] ltr:mr-3 rtl:ml-3 md:mt-0"
/>
)}
{!tab.icon && tab?.avatar && (
<img
className="h-4 w-4 rounded-full ltr:mr-3 rtl:ml-3"
src={tab?.avatar}
- alt="User Avatar"
+ alt="Organization Logo"
/>
)}
<Skeleton
title={tab.name}
as="p"
- className="truncate text-sm font-medium leading-5"
+ className="text-subtle truncate text-sm font-medium leading-5"
loadingClassName="ms-3">
{t(tab.name)}
</Skeleton>
</div>
</div>
- <div className="my-3 space-y-0.5">
+ <div className="my-3 space-y-px">
{tab.children?.map((child, index) => (
<VerticalTabItem
key={child.href}
name={t(child.name)}
isExternalLink={child.isExternalLink}
href={child.href || "/"}
- textClassNames="px-3 text-emphasis font-medium text-sm"
- className={`my-0.5 me-5 h-7 ${
+ textClassNames="text-emphasis font-medium text-sm"
+ className={`me-5 h-7 !px-2 ${
tab.children && index === tab.children?.length - 1 && "!mb-3"
}`}
disableChevron
@@ -317,144 +485,25 @@ const SettingsSidebarContainer = ({
{tab.name === "teams" && (
<React.Fragment key={tab.href}>
- <div className={`${!tab.children?.length ? "mb-3" : ""}`}>
+ <div data-testid="tab-teams" className={`${!tab.children?.length ? "mb-3" : ""}`}>
<Link href={tab.href}>
- <div className="hover:bg-subtle [&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis group-hover:text-default text-default group flex h-9 w-full flex-row items-center rounded-md px-2 py-[10px] text-sm font-medium leading-none transition">
+ <div className="hover:bg-subtle [&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis group-hover:text-default text-default group flex h-9 w-full flex-row items-center rounded-md px-2 py-[10px] text-sm font-medium leading-none transition">
{tab && tab.icon && (
<Icon
name={tab.icon}
- className="h-[16px] w-[16px] stroke-[2px] ltr:mr-3 rtl:ml-3 md:mt-0"
+ className="text-subtle h-[16px] w-[16px] stroke-[2px] ltr:mr-3 rtl:ml-3 md:mt-0"
/>
)}
<Skeleton
title={tab.name}
as="p"
- className="truncate text-sm font-medium leading-5"
+ className="text-subtle truncate text-sm font-medium leading-5"
loadingClassName="ms-3">
{t(isOrgAdminOrOwner ? "my_teams" : tab.name)}
</Skeleton>
</div>
</Link>
- {teams &&
- teamMenuState &&
- teams.map((team, index: number) => {
- if (!teamMenuState[index]) {
- return null;
- }
- if (teamMenuState.some((teamState) => teamState.teamId === team.id))
- return (
- <Collapsible
- className="cursor-pointer"
- key={team.id}
- open={teamMenuState[index].teamMenuOpen}
- onOpenChange={() =>
- setTeamMenuState([
- ...teamMenuState,
- (teamMenuState[index] = {
- ...teamMenuState[index],
- teamMenuOpen: !teamMenuState[index].teamMenuOpen,
- }),
- ])
- }>
- <CollapsibleTrigger asChild>
- <div
- className="hover:bg-subtle [&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis text-default flex h-9 w-full flex-row items-center rounded-md px-3 py-[10px] text-left text-sm font-medium leading-none transition"
- onClick={() =>
- setTeamMenuState([
- ...teamMenuState,
- (teamMenuState[index] = {
- ...teamMenuState[index],
- teamMenuOpen: !teamMenuState[index].teamMenuOpen,
- }),
- ])
- }>
- <div className="me-3">
- {teamMenuState[index].teamMenuOpen ? (
- <Icon name="chevron-down" className="h-4 w-4" />
- ) : (
- <Icon name="chevron-right" className="h-4 w-4" />
- )}
- </div>
- {!team.parentId && (
- <img
- src={getPlaceholderAvatar(team.logoUrl, team.name)}
- className="h-[16px] w-[16px] self-start rounded-full stroke-[2px] ltr:mr-2 rtl:ml-2 md:mt-0"
- alt={team.name || "Team logo"}
- />
- )}
- <p className="w-1/2 truncate leading-normal">{team.name}</p>
- {!team.accepted && (
- <Badge className="ms-3" variant="orange">
- Inv.
- </Badge>
- )}
- </div>
- </CollapsibleTrigger>
- <CollapsibleContent className="space-y-0.5">
- {team.accepted && (
- <VerticalTabItem
- name={t("profile")}
- href={`/settings/teams/${team.id}/profile`}
- textClassNames="px-3 text-emphasis font-medium text-sm"
- disableChevron
- />
- )}
- <VerticalTabItem
- name={t("members")}
- href={`/settings/teams/${team.id}/members`}
- textClassNames="px-3 text-emphasis font-medium text-sm"
- disableChevron
- />
- <VerticalTabItem
- name={t("event_types_page_title")}
- href={`/event-types?teamIds=${team.id}`}
- textClassNames="px-3 text-emphasis font-medium text-sm"
- disableChevron
- />
- {(team.role === MembershipRole.OWNER ||
- team.role === MembershipRole.ADMIN ||
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore this exists wtf?
- (team.isOrgAdmin && team.isOrgAdmin)) && (
- <>
- {/* TODO */}
- {/* <VerticalTabItem
- name={t("general")}
- href={`${WEBAPP_URL}/settings/my-account/appearance`}
- textClassNames="px-3 text-emphasis font-medium text-sm"
- disableChevron
- /> */}
- <VerticalTabItem
- name={t("appearance")}
- href={`/settings/teams/${team.id}/appearance`}
- textClassNames="px-3 text-emphasis font-medium text-sm"
- disableChevron
- />
- {/* Hide if there is a parent ID */}
- {!team.parentId ? (
- <>
- <VerticalTabItem
- name={t("billing")}
- href={`/settings/teams/${team.id}/billing`}
- textClassNames="px-3 text-emphasis font-medium text-sm"
- disableChevron
- />
- {HOSTED_CAL_FEATURES && (
- <VerticalTabItem
- name={t("saml_config")}
- href={`/settings/teams/${team.id}/sso`}
- textClassNames="px-3 text-emphasis font-medium text-sm"
- disableChevron
- />
- )}
- </>
- ) : null}
- </>
- )}
- </CollapsibleContent>
- </Collapsible>
- );
- })}
+ <TeamListCollapsible />
{(!currentOrg || (currentOrg && currentOrg?.user?.role !== "MEMBER")) && (
<VerticalTabItem
name={t("add_a_team")}
@@ -476,13 +525,13 @@ const SettingsSidebarContainer = ({
{tab && tab.icon && (
<Icon
name={tab.icon}
- className="h-[16px] w-[16px] stroke-[2px] ltr:mr-3 rtl:ml-3 md:mt-0"
+ className="text-subtle h-[16px] w-[16px] stroke-[2px] ltr:mr-3 rtl:ml-3 md:mt-0"
/>
)}
<Skeleton
title={t("org_admin_other_teams")}
as="p"
- className="truncate text-sm font-medium leading-5"
+ className="text-subtle truncate text-sm font-medium leading-5"
loadingClassName="ms-3">
{t("org_admin_other_teams")}
</Skeleton>
@@ -511,7 +560,7 @@ const SettingsSidebarContainer = ({
}>
<CollapsibleTrigger asChild>
<div
- className="hover:bg-subtle [&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis text-default flex h-9 w-full flex-row items-center rounded-md px-3 py-[10px] text-left text-sm font-medium leading-none transition"
+ className="hover:bg-subtle [&[aria-current='page']]:bg-emphasis [&[aria-current='page']]:text-emphasis text-default flex h-9 w-full flex-row items-center rounded-md px-2 py-[10px] text-left text-sm font-medium leading-none transition"
onClick={() =>
setOtherTeamMenuState([
...otherTeamMenuState,
@@ -582,8 +631,8 @@ const MobileSettingsContainer = (props: { onSideContainerOpen?: () => void }) =>
return (
<>
- <nav className="bg-muted border-muted sticky top-0 z-20 flex w-full items-center justify-between border-b py-2 sm:relative lg:hidden">
- <div className="flex items-center space-x-3 ">
+ <nav className="bg-muted border-muted sticky top-0 z-20 flex w-full items-center justify-between border-b px-2 py-2 sm:relative lg:hidden">
+ <div className="flex items-center space-x-3">
<Button StartIcon="menu" color="minimal" variant="icon" onClick={props.onSideContainerOpen}>
<span className="sr-only">{t("show_navigation")}</span>
</Button>
@@ -603,10 +652,11 @@ const MobileSettingsContainer = (props: { onSideContainerOpen?: () => void }) =>
export default function SettingsLayout({
children,
...rest
-}: { children: React.ReactNode } & ComponentProps<typeof Shell>) {
+}: {
+ children: React.ReactNode;
+} & ComponentProps<typeof Shell>) {
const pathname = usePathname();
const state = useState(false);
- const { t } = useLocale();
const [sideContainerOpen, setSideContainerOpen] = state;
useEffect(() => {
@@ -646,11 +696,8 @@ export default function SettingsLayout({
<MobileSettingsContainer onSideContainerOpen={() => setSideContainerOpen(!sideContainerOpen)} />
}>
<div className="flex flex-1 [&>*]:flex-1">
- <div className="mx-auto max-w-full justify-center lg:max-w-4xl">
- <ShellHeader />
- <ErrorBoundary>
- <Suspense fallback={<Icon name="loader" />}>{children}</Suspense>
- </ErrorBoundary>
+ <div className="mx-auto max-w-full justify-center lg:max-w-3xl">
+ <ErrorBoundary>{children}</ErrorBoundary>
</div>
</div>
</Shell>
@@ -688,41 +735,3 @@ type SidebarContainerElementProps = {
};
export const getLayout = (page: React.ReactElement) => <SettingsLayout>{page}</SettingsLayout>;
-
-export function ShellHeader() {
- const { meta } = useMeta();
- const { t, isLocaleReady } = useLocale();
- return (
- <>
- <header
- className={classNames(
- "border-subtle mx-auto block justify-between sm:flex",
- meta.borderInShellHeader && "rounded-t-lg border px-4 py-6 sm:px-6",
- meta.borderInShellHeader === undefined && "mb-8 border-b pb-8"
- )}>
- <div className="flex w-full items-center">
- {meta.backButton && (
- <a href="javascript:history.back()">
- <Icon name="arrow-left" className="mr-7" />
- </a>
- )}
- <div>
- {meta.title && isLocaleReady ? (
- <h1 className="font-cal text-emphasis mb-1 text-xl font-semibold leading-5 tracking-wide">
- {t(meta.title)}
- </h1>
- ) : (
- <div className="bg-emphasis mb-1 h-5 w-24 animate-pulse rounded-lg" />
- )}
- {meta.description && isLocaleReady ? (
- <p className="text-default text-sm ltr:mr-4 rtl:ml-4">{t(meta.description)}</p>
- ) : (
- <div className="bg-emphasis h-5 w-32 animate-pulse rounded-lg" />
- )}
- </div>
- <div className="ms-auto flex-shrink-0">{meta.CTA}</div>
- </div>
- </header>
- </>
- );
-}
diff --git a/packages/features/settings/layouts/SettingsLayout.tsx b/packages/features/settings/layouts/SettingsLayout.tsx
index aa7eb5faf01..36bb7f3e444 100644
--- a/packages/features/settings/layouts/SettingsLayout.tsx
+++ b/packages/features/settings/layouts/SettingsLayout.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@radix-ui/react-collapsible";
import { useSession } from "next-auth/react";
import Link from "next/link";
diff --git a/packages/features/settings/outOfOffice/CreateNewOutOfOfficeEntryButton.tsx b/packages/features/settings/outOfOffice/CreateNewOutOfOfficeEntryButton.tsx
new file mode 100644
index 00000000000..782fe3724b6
--- /dev/null
+++ b/packages/features/settings/outOfOffice/CreateNewOutOfOfficeEntryButton.tsx
@@ -0,0 +1,46 @@
+"use client";
+
+import { useSearchParams } from "next/navigation";
+import { useState, useEffect } from "react";
+
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { Button, Icon } from "@calcom/ui";
+
+import { CreateOrEditOutOfOfficeEntryModal } from "./CreateOrEditOutOfOfficeModal";
+
+const CreateNewOutOfOfficeEntry = () => {
+ const { t } = useLocale();
+
+ const params = useSearchParams();
+ const openModalOnStart = !!params?.get("om");
+ useEffect(() => {
+ if (openModalOnStart) {
+ setOpenModal(true);
+ }
+ }, [openModalOnStart]);
+
+ const [openModal, setOpenModal] = useState(false);
+
+ return (
+ <>
+ <Button
+ color="primary"
+ className="flex w-20 items-center justify-between px-4"
+ onClick={() => setOpenModal(true)}
+ data-testid="add_entry_ooo">
+ <Icon name="plus" size={16} /> {t("add")}
+ </Button>
+ {openModal && (
+ <CreateOrEditOutOfOfficeEntryModal
+ openModal={openModal}
+ closeModal={() => {
+ setOpenModal(false);
+ }}
+ currentlyEditingOutOfOfficeEntry={null}
+ />
+ )}
+ </>
+ );
+};
+
+export default CreateNewOutOfOfficeEntry;
diff --git a/packages/features/settings/CreateOrEditOutOfOfficeModal.tsx b/packages/features/settings/outOfOffice/CreateOrEditOutOfOfficeModal.tsx
similarity index 97%
rename from packages/features/settings/CreateOrEditOutOfOfficeModal.tsx
rename to packages/features/settings/outOfOffice/CreateOrEditOutOfOfficeModal.tsx
index 34e89267cd3..f2955b2be6a 100644
--- a/packages/features/settings/CreateOrEditOutOfOfficeModal.tsx
+++ b/packages/features/settings/outOfOffice/CreateOrEditOutOfOfficeModal.tsx
@@ -19,7 +19,15 @@ import {
TextArea,
UpgradeTeamsBadge,
} from "@calcom/ui";
-import type { BookingRedirectForm } from "@calcom/web/pages/settings/my-account/out-of-office";
+
+export type BookingRedirectForm = {
+ dateRange: { startDate: Date; endDate: Date };
+ offset: number;
+ toTeamUserId: number | null;
+ reasonId: number;
+ notes?: string;
+ uuid?: string | null;
+};
export const CreateOrEditOutOfOfficeEntryModal = ({
openModal,
diff --git a/packages/features/settings/OutOfOfficeEntriesList.tsx b/packages/features/settings/outOfOffice/OutOfOfficeEntriesList.tsx
similarity index 88%
rename from packages/features/settings/OutOfOfficeEntriesList.tsx
rename to packages/features/settings/outOfOffice/OutOfOfficeEntriesList.tsx
index 1b801cd2913..7d57c823f65 100644
--- a/packages/features/settings/OutOfOfficeEntriesList.tsx
+++ b/packages/features/settings/outOfOffice/OutOfOfficeEntriesList.tsx
@@ -1,4 +1,7 @@
+"use client";
+
import { Trans } from "next-i18next";
+import { useState } from "react";
import { useFormState } from "react-hook-form";
import dayjs from "@calcom/dayjs";
@@ -16,13 +19,11 @@ import {
TableRow,
Tooltip,
} from "@calcom/ui";
-import type { BookingRedirectForm } from "@calcom/web/pages/settings/my-account/out-of-office";
-export const OutOfOfficeEntriesList = ({
- editOutOfOfficeEntry,
-}: {
- editOutOfOfficeEntry: (entry: BookingRedirectForm) => void;
-}) => {
+import { CreateOrEditOutOfOfficeEntryModal } from "./CreateOrEditOutOfOfficeModal";
+import type { BookingRedirectForm } from "./CreateOrEditOutOfOfficeModal";
+
+export const OutOfOfficeEntriesList = () => {
const { t } = useLocale();
const utils = trpc.useUtils();
const { data, isPending } = trpc.viewer.outOfOfficeEntriesList.useQuery();
@@ -36,6 +37,16 @@ export const OutOfOfficeEntriesList = ({
showToast(`An error ocurred`, "error");
},
});
+
+ const [currentlyEditingOutOfOfficeEntry, setCurrentlyEditingOutOfOfficeEntry] =
+ useState<BookingRedirectForm | null>(null);
+ const [openModal, setOpenModal] = useState(false);
+
+ const editOutOfOfficeEntry = (entry: BookingRedirectForm) => {
+ setCurrentlyEditingOutOfOfficeEntry(entry);
+ setOpenModal(true);
+ };
+
if (data === null || data?.length === 0 || (data === undefined && !isPending))
return (
<EmptyScreen
@@ -168,6 +179,16 @@ export const OutOfOfficeEntriesList = ({
)}
</TableBody>
</TableNew>
+ {openModal && (
+ <CreateOrEditOutOfOfficeEntryModal
+ openModal={openModal}
+ closeModal={() => {
+ setOpenModal(false);
+ setCurrentlyEditingOutOfOfficeEntry(null);
+ }}
+ currentlyEditingOutOfOfficeEntry={currentlyEditingOutOfOfficeEntry}
+ />
+ )}
</div>
);
};
diff --git a/packages/features/webhooks/components/CreateNewWebhookButton.tsx b/packages/features/webhooks/components/CreateNewWebhookButton.tsx
new file mode 100644
index 00000000000..eaaa4eb83ea
--- /dev/null
+++ b/packages/features/webhooks/components/CreateNewWebhookButton.tsx
@@ -0,0 +1,31 @@
+"use client";
+
+import { useRouter } from "next/navigation";
+
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { CreateButtonWithTeamsList } from "@calcom/ui";
+
+export const CreateNewWebhookButton = ({ isAdmin }: { isAdmin: boolean }) => {
+ const router = useRouter();
+ const { t } = useLocale();
+ const createFunction = (teamId?: number, platform?: boolean) => {
+ if (platform) {
+ router.push(`webhooks/new${platform ? `?platform=${platform}` : ""}`);
+ } else {
+ router.push(`webhooks/new${teamId ? `?teamId=${teamId}` : ""}`);
+ }
+ };
+
+ return (
+ <CreateButtonWithTeamsList
+ color="secondary"
+ subtitle={t("create_for").toUpperCase()}
+ isAdmin={isAdmin}
+ createFunction={createFunction}
+ data-testid="new_webhook"
+ includeOrg={true}
+ />
+ );
+};
+
+export default CreateNewWebhookButton;
diff --git a/packages/features/webhooks/components/index.ts b/packages/features/webhooks/components/index.ts
index 86351d5243a..fcdf9accfd0 100644
--- a/packages/features/webhooks/components/index.ts
+++ b/packages/features/webhooks/components/index.ts
@@ -3,3 +3,4 @@ export { default as WebhookListItem } from "./WebhookListItem";
export { default as WebhookListItemSkeleton } from "./WebhookListItemSkeleton";
export { default as WebhookListSkeleton } from "./WebhookListSkeleton";
export { default as WebhookTestDisclosure } from "./WebhookTestDisclosure";
+export { default as CreateNewWebhookButton } from "./CreateNewWebhookButton";
diff --git a/packages/features/webhooks/lib/getNewWebhookUrl.ts b/packages/features/webhooks/lib/getNewWebhookUrl.ts
new file mode 100644
index 00000000000..e7b1f02860a
--- /dev/null
+++ b/packages/features/webhooks/lib/getNewWebhookUrl.ts
@@ -0,0 +1,9 @@
+const getNewWebhookUrl = (teamId?: number, platform?: boolean) => {
+ if (platform) {
+ return `webhooks/new${platform ? `?platform=${platform}` : ""}`;
+ } else {
+ return `webhooks/new${teamId ? `?teamId=${teamId}` : ""}`;
+ }
+};
+
+export default getNewWebhookUrl;
diff --git a/packages/features/webhooks/pages/webhook-edit-view.tsx b/packages/features/webhooks/pages/webhook-edit-view.tsx
index 3336de83220..a067d4be5bb 100644
--- a/packages/features/webhooks/pages/webhook-edit-view.tsx
+++ b/packages/features/webhooks/pages/webhook-edit-view.tsx
@@ -1,27 +1,29 @@
+"use client";
+
import { useRouter } from "next/navigation";
-import { APP_NAME } from "@calcom/lib/constants";
-import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
import { useLocale } from "@calcom/lib/hooks/useLocale";
+import type { WebhookTriggerEvents } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
-import { Meta, showToast, SkeletonContainer } from "@calcom/ui";
+import { showToast, SkeletonContainer } from "@calcom/ui";
-import { getLayout } from "../../settings/layouts/SettingsLayout";
import type { WebhookFormSubmitData } from "../components/WebhookForm";
import WebhookForm from "../components/WebhookForm";
import { subscriberUrlReserved } from "../lib/subscriberUrlReserved";
-const EditWebhook = () => {
- const searchParams = useCompatSearchParams();
- const id = searchParams?.get("id");
-
- if (!id) return <SkeletonContainer />;
-
- // I think we should do SSR for this page
- return <Component webhookId={id} />;
+type WebhookProps = {
+ id: string;
+ userId: number | null;
+ teamId: number | null;
+ subscriberUrl: string;
+ payloadTemplate: string | null;
+ active: boolean;
+ eventTriggers: WebhookTriggerEvents[];
+ secret: string | null;
+ platform: boolean;
};
-function Component({ webhookId }: { webhookId: string }) {
+export function EditWebhookView({ webhook }: { webhook?: WebhookProps }) {
const { t } = useLocale();
const utils = trpc.useUtils();
const router = useRouter();
@@ -29,24 +31,18 @@ function Component({ webhookId }: { webhookId: string }) {
{ variant: "other", onlyInstalled: true },
{
suspense: true,
- enabled: !!webhookId,
- }
- );
- const { data: webhook } = trpc.viewer.webhook.get.useQuery(
- { webhookId },
- {
- suspense: true,
- enabled: !!webhookId,
+ enabled: !!webhook,
}
);
+
const { data: webhooks } = trpc.viewer.webhook.list.useQuery(undefined, {
suspense: true,
- enabled: !!webhookId,
+ enabled: !!webhook,
});
const editWebhookMutation = trpc.viewer.webhook.edit.useMutation({
async onSuccess() {
await utils.viewer.webhook.list.invalidate();
- await utils.viewer.webhook.get.invalidate({ webhookId });
+ await utils.viewer.webhook.get.invalidate({ webhookId: webhook?.id });
showToast(t("webhook_updated_successfully"), "success");
router.back();
},
@@ -59,12 +55,6 @@ function Component({ webhookId }: { webhookId: string }) {
return (
<>
- <Meta
- title={t("edit_webhook")}
- description={t("add_webhook_description", { appName: APP_NAME })}
- borderInShellHeader={true}
- backButton
- />
<WebhookForm
noRoutingFormTriggers={false}
webhook={webhook}
@@ -106,6 +96,4 @@ function Component({ webhookId }: { webhookId: string }) {
);
}
-EditWebhook.getLayout = getLayout;
-
-export default EditWebhook;
+export default EditWebhookView;
diff --git a/packages/features/webhooks/pages/webhook-new-view.tsx b/packages/features/webhooks/pages/webhook-new-view.tsx
index 07c0b950858..de24bfa327b 100644
--- a/packages/features/webhooks/pages/webhook-new-view.tsx
+++ b/packages/features/webhooks/pages/webhook-new-view.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import { useSession } from "next-auth/react";
import { useRouter } from "next/navigation";
@@ -7,7 +9,6 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Meta, showToast, SkeletonContainer, SkeletonText } from "@calcom/ui";
-import { getLayout } from "../../settings/layouts/SettingsLayout";
import type { WebhookFormSubmitData } from "../components/WebhookForm";
import WebhookForm from "../components/WebhookForm";
import { subscriberUrlReserved } from "../lib/subscriberUrlReserved";
@@ -23,7 +24,7 @@ const SkeletonLoader = ({ title, description }: { title: string; description: st
</SkeletonContainer>
);
};
-const NewWebhookView = () => {
+export const NewWebhookView = () => {
const searchParams = useCompatSearchParams();
const { t } = useLocale();
const utils = trpc.useUtils();
@@ -95,22 +96,12 @@ const NewWebhookView = () => {
);
return (
- <>
- <Meta
- title={t("add_webhook")}
- description={t("add_webhook_description", { appName: APP_NAME })}
- backButton
- borderInShellHeader={true}
- />
- <WebhookForm
- noRoutingFormTriggers={false}
- onSubmit={onCreateWebhook}
- apps={installedApps?.items.map((app) => app.slug)}
- />
- </>
+ <WebhookForm
+ noRoutingFormTriggers={false}
+ onSubmit={onCreateWebhook}
+ apps={installedApps?.items.map((app) => app.slug)}
+ />
);
};
-NewWebhookView.getLayout = getLayout;
-
export default NewWebhookView;
diff --git a/packages/features/webhooks/pages/webhooks-view.tsx b/packages/features/webhooks/pages/webhooks-view.tsx
index 783893cb663..860510602cc 100644
--- a/packages/features/webhooks/pages/webhooks-view.tsx
+++ b/packages/features/webhooks/pages/webhooks-view.tsx
@@ -1,6 +1,9 @@
+"use client";
+
import { useSession } from "next-auth/react";
import { useRouter } from "next/navigation";
+import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
import classNames from "@calcom/lib/classNames";
import { APP_NAME, WEBAPP_URL } from "@calcom/lib/constants";
import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
@@ -8,17 +11,9 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { UserPermissionRole } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
import type { WebhooksByViewer } from "@calcom/trpc/server/routers/viewer/webhook/getByViewer.handler";
-import {
- Avatar,
- CreateButtonWithTeamsList,
- EmptyScreen,
- Meta,
- SkeletonContainer,
- SkeletonText,
-} from "@calcom/ui";
-
-import { getLayout } from "../../settings/layouts/SettingsLayout";
-import { WebhookListItem } from "../components";
+import { Avatar, EmptyScreen, Meta, SkeletonContainer, SkeletonText } from "@calcom/ui";
+
+import { WebhookListItem, CreateNewWebhookButton } from "../components";
const SkeletonLoader = ({
title,
@@ -42,7 +37,6 @@ const SkeletonLoader = ({
const WebhooksView = () => {
const { t } = useLocale();
- const router = useRouter();
const session = useSession();
const isAdmin = session.data?.user.role === UserPermissionRole.ADMIN;
@@ -50,13 +44,6 @@ const WebhooksView = () => {
enabled: session.status === "authenticated",
});
- const createFunction = (teamId?: number, platform?: boolean) => {
- if (platform) {
- router.push(`webhooks/new${platform ? `?platform=${platform}` : ""}`);
- } else {
- router.push(`webhooks/new${teamId ? `?teamId=${teamId}` : ""}`);
- }
- };
if (isPending || !data) {
return (
<SkeletonLoader
@@ -69,28 +56,43 @@ const WebhooksView = () => {
return (
<>
- <Meta
+ <div>
+ <WebhooksList webhooksByViewer={data} isAdmin={isAdmin} />
+ </div>
+ </>
+ );
+};
+
+export const WebhooksViewAppDir = () => {
+ const { t } = useLocale();
+ const session = useSession();
+ const isAdmin = session.data?.user.role === UserPermissionRole.ADMIN;
+
+ const { data, isPending } = trpc.viewer.webhook.getByViewer.useQuery(undefined, {
+ enabled: session.status === "authenticated",
+ });
+
+ if (isPending || !data) {
+ return (
+ <SkeletonLoader
title={t("webhooks")}
description={t("add_webhook_description", { appName: APP_NAME })}
- CTA={
- data && data.webhookGroups.length > 0 ? (
- <CreateButtonWithTeamsList
- color="secondary"
- subtitle={t("create_for").toUpperCase()}
- isAdmin={isAdmin}
- createFunction={createFunction}
- data-testid="new_webhook"
- includeOrg={true}
- />
- ) : (
- <></>
- )
- }
- borderInShellHeader={(data && data.profiles.length === 1) || !data?.webhookGroups?.length}
+ borderInShellHeader={true}
/>
- <div>
- <WebhooksList webhooksByViewer={data} isAdmin={isAdmin} createFunction={createFunction} />
- </div>
+ );
+ }
+
+ return (
+ <>
+ <SettingsHeader
+ title={t("webhooks")}
+ description={t("add_webhook_description", { appName: APP_NAME })}
+ CTA={data && data.webhookGroups.length > 0 ? <CreateNewWebhookButton isAdmin={isAdmin} /> : <></>}
+ borderInShellHeader={(data && data.profiles.length === 1) || !data?.webhookGroups?.length}>
+ <div>
+ <WebhooksList webhooksByViewer={data} isAdmin={isAdmin} />
+ </div>
+ </SettingsHeader>
</>
);
};
@@ -98,15 +100,12 @@ const WebhooksView = () => {
const WebhooksList = ({
webhooksByViewer,
isAdmin,
- createFunction,
}: {
webhooksByViewer: WebhooksByViewer;
isAdmin: boolean;
- createFunction: (teamId?: number, platform?: boolean) => void;
}) => {
const { t } = useLocale();
const router = useRouter();
-
const { profiles, webhookGroups } = webhooksByViewer;
const bookerUrl = useBookerUrl();
@@ -146,7 +145,7 @@ const WebhooksList = ({
readOnly={group.metadata?.readOnly ?? false}
lastItem={group.webhooks.length === index + 1}
onEditWebhook={() =>
- router.push(`${WEBAPP_URL}/settings/developer/webhooks/${webhook.id} `)
+ router.push(`${WEBAPP_URL}/settings/developer/webhooks/${webhook.id}`)
}
/>
))}
@@ -162,15 +161,8 @@ const WebhooksList = ({
headline={t("create_your_first_webhook")}
description={t("create_your_first_webhook_description", { appName: APP_NAME })}
className="rounded-b-lg rounded-t-none border-t-0"
- buttonRaw={
- <CreateButtonWithTeamsList
- subtitle={t("create_for").toUpperCase()}
- isAdmin={isAdmin}
- createFunction={createFunction}
- data-testid="new_webhook"
- includeOrg={true}
- />
- }
+ buttonRaw={<CreateNewWebhookButton isAdmin={isAdmin} />}
+ border={true}
/>
)}
</>
@@ -179,6 +171,4 @@ const WebhooksList = ({
);
};
-WebhooksView.getLayout = getLayout;
-
export default WebhooksView;
diff --git a/packages/lib/server/repository/organization.ts b/packages/lib/server/repository/organization.ts
index aba6247cba9..177b0a33795 100644
--- a/packages/lib/server/repository/organization.ts
+++ b/packages/lib/server/repository/organization.ts
@@ -4,6 +4,7 @@ import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { prisma } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
+import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
import { createAProfileForAnExistingUser } from "../../createAProfileForAnExistingUser";
import { getParsedTeam } from "./teamUtils";
@@ -192,4 +193,50 @@ export class OrganizationRepository {
}
return getParsedTeam(org);
}
+
+ static async adminFindById({ id }: { id: number }) {
+ const org = await prisma.team.findUnique({
+ where: {
+ id,
+ },
+ select: {
+ id: true,
+ name: true,
+ slug: true,
+ metadata: true,
+ isOrganization: true,
+ members: {
+ where: {
+ role: "OWNER",
+ },
+ select: {
+ user: {
+ select: {
+ id: true,
+ name: true,
+ email: true,
+ },
+ },
+ },
+ },
+ organizationSettings: {
+ select: {
+ isOrganizationConfigured: true,
+ isOrganizationVerified: true,
+ orgAutoAcceptEmail: true,
+ },
+ },
+ },
+ });
+
+ if (!org) {
+ throw new Error("Organization not found");
+ }
+
+ const parsedMetadata = teamMetadataSchema.parse(org.metadata);
+ if (!org?.isOrganization) {
+ throw new Error("Organization not found");
+ }
+ return { ...org, metadata: parsedMetadata };
+ }
}
diff --git a/packages/lib/server/repository/user.ts b/packages/lib/server/repository/user.ts
index e9cd304ae10..8e39cfb36e5 100644
--- a/packages/lib/server/repository/user.ts
+++ b/packages/lib/server/repository/user.ts
@@ -553,4 +553,12 @@ export class UserRepository {
}
return teamIds;
}
+
+ static async adminFindById(userId: number) {
+ return await prisma.user.findUniqueOrThrow({
+ where: {
+ id: userId,
+ },
+ });
+ }
}
diff --git a/packages/lib/server/repository/webhook.ts b/packages/lib/server/repository/webhook.ts
new file mode 100644
index 00000000000..ba02b96f1d8
--- /dev/null
+++ b/packages/lib/server/repository/webhook.ts
@@ -0,0 +1,180 @@
+import { compareMembership } from "@calcom/lib/event-types/getEventTypesByViewer";
+import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
+import { prisma } from "@calcom/prisma";
+import type { Webhook } from "@calcom/prisma/client";
+import type { UserPermissionRole } from "@calcom/prisma/enums";
+import { MembershipRole } from "@calcom/prisma/enums";
+
+type WebhookGroup = {
+ teamId?: number | null;
+ profile: {
+ slug: string | null;
+ name: string | null;
+ image?: string;
+ };
+ metadata?: {
+ readOnly: boolean;
+ };
+ webhooks: Webhook[];
+};
+
+const filterWebhooks = (webhook: Webhook) => {
+ const appIds = [
+ "zapier",
+ // Add more if needed
+ ];
+
+ return !appIds.some((appId: string) => webhook.appId == appId);
+};
+
+export class WebhookRepository {
+ static async getAllWebhooksByUserId({
+ userId,
+ organizationId,
+ userRole,
+ }: {
+ userId: number;
+ organizationId?: number | null;
+ userRole?: UserPermissionRole;
+ }) {
+ const user = await prisma.user.findUnique({
+ where: {
+ id: userId,
+ },
+ select: {
+ username: true,
+ avatarUrl: true,
+ name: true,
+ webhooks: true,
+ teams: {
+ where: {
+ accepted: true,
+ },
+ select: {
+ role: true,
+ team: {
+ select: {
+ id: true,
+ isOrganization: true,
+ name: true,
+ slug: true,
+ parentId: true,
+ metadata: true,
+ members: {
+ select: {
+ userId: true,
+ },
+ },
+ webhooks: true,
+ },
+ },
+ },
+ },
+ },
+ });
+
+ if (!user) {
+ throw new Error("User not found");
+ }
+
+ let userWebhooks = user.webhooks;
+ userWebhooks = userWebhooks.filter(filterWebhooks);
+ let webhookGroups: WebhookGroup[] = [];
+ const bookerUrl = await getBookerBaseUrl(organizationId ?? null);
+
+ const image = user?.username ? `${bookerUrl}/${user.username}/avatar.png` : undefined;
+ webhookGroups.push({
+ teamId: null,
+ profile: {
+ slug: user.username,
+ name: user.name,
+ image,
+ },
+ webhooks: userWebhooks,
+ metadata: {
+ readOnly: false,
+ },
+ });
+
+ const teamMemberships = user.teams.map((membership) => ({
+ teamId: membership.team.id,
+ membershipRole: membership.role,
+ }));
+
+ const teamWebhookGroups: WebhookGroup[] = user.teams.map((membership) => {
+ const orgMembership = teamMemberships.find(
+ (teamM) => teamM.teamId === membership.team.parentId
+ )?.membershipRole;
+ return {
+ teamId: membership.team.id,
+ profile: {
+ name: membership.team.name,
+ slug: membership.team.slug
+ ? !membership.team.parentId
+ ? `/team`
+ : `${membership.team.slug}`
+ : null,
+ image: `${bookerUrl}/team/${membership.team.slug}/avatar.png`,
+ },
+ metadata: {
+ readOnly:
+ membership.role ===
+ (membership.team.parentId
+ ? orgMembership && compareMembership(orgMembership, membership.role)
+ ? orgMembership
+ : MembershipRole.MEMBER
+ : MembershipRole.MEMBER),
+ },
+ webhooks: membership.team.webhooks.filter(filterWebhooks),
+ };
+ });
+
+ webhookGroups = webhookGroups.concat(teamWebhookGroups);
+
+ if (userRole === "ADMIN") {
+ const platformWebhooks = await prisma.webhook.findMany({
+ where: { platform: true },
+ });
+ webhookGroups.push({
+ teamId: null,
+ profile: {
+ slug: "Platform",
+ name: "Platform",
+ image,
+ },
+ webhooks: platformWebhooks,
+ metadata: {
+ readOnly: false,
+ },
+ });
+ }
+
+ return {
+ webhookGroups: webhookGroups.filter((groupBy) => !!groupBy.webhooks?.length),
+ profiles: webhookGroups.map((group) => ({
+ teamId: group.teamId,
+ ...group.profile,
+ ...group.metadata,
+ })),
+ };
+ }
+
+ static async findByWebhookId(webhookId?: string) {
+ return await prisma.webhook.findUniqueOrThrow({
+ where: {
+ id: webhookId,
+ },
+ select: {
+ id: true,
+ subscriberUrl: true,
+ payloadTemplate: true,
+ active: true,
+ eventTriggers: true,
+ secret: true,
+ teamId: true,
+ userId: true,
+ platform: true,
+ },
+ });
+ }
+}
diff --git a/packages/platform/atoms/destination-calendar/DestinationCalendarSelector.tsx b/packages/platform/atoms/destination-calendar/DestinationCalendarSelector.tsx
index c202d2374d9..ae0596ff9cb 100644
--- a/packages/platform/atoms/destination-calendar/DestinationCalendarSelector.tsx
+++ b/packages/platform/atoms/destination-calendar/DestinationCalendarSelector.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import { useState, useEffect, useMemo } from "react";
import { SingleValueComponent } from "@calcom/features/calendars/DestinationCalendarSelector";
diff --git a/packages/trpc/server/routers/viewer/organizations/adminGet.handler.ts b/packages/trpc/server/routers/viewer/organizations/adminGet.handler.ts
index a7466421a1e..09e3beb2b09 100644
--- a/packages/trpc/server/routers/viewer/organizations/adminGet.handler.ts
+++ b/packages/trpc/server/routers/viewer/organizations/adminGet.handler.ts
@@ -1,7 +1,4 @@
-import { prisma } from "@calcom/prisma";
-import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
-
-import { TRPCError } from "@trpc/server";
+import { OrganizationRepository } from "@calcom/lib/server/repository/organization";
import type { TrpcSessionUser } from "../../../trpc";
import type { TAdminGet } from "./adminGet.schema";
@@ -14,54 +11,7 @@ type AdminGetOptions = {
};
export const adminGetHandler = async ({ input }: AdminGetOptions) => {
- const org = await prisma.team.findUnique({
- where: {
- id: input.id,
- },
- select: {
- id: true,
- name: true,
- slug: true,
- metadata: true,
- isOrganization: true,
- members: {
- where: {
- role: "OWNER",
- },
- select: {
- user: {
- select: {
- id: true,
- name: true,
- email: true,
- },
- },
- },
- },
- organizationSettings: {
- select: {
- isOrganizationConfigured: true,
- isOrganizationVerified: true,
- orgAutoAcceptEmail: true,
- },
- },
- },
- });
-
- if (!org) {
- throw new TRPCError({
- code: "NOT_FOUND",
- message: "Organization not found",
- });
- }
- const parsedMetadata = teamMetadataSchema.parse(org.metadata);
- if (!org?.isOrganization) {
- throw new TRPCError({
- code: "NOT_FOUND",
- message: "Organization not found",
- });
- }
- return { ...org, metadata: parsedMetadata };
+ return await OrganizationRepository.adminFindById({ id: input.id });
};
export default adminGetHandler;
diff --git a/packages/trpc/server/routers/viewer/webhook/get.handler.ts b/packages/trpc/server/routers/viewer/webhook/get.handler.ts
index ec986c361b2..bf623ca1ff6 100644
--- a/packages/trpc/server/routers/viewer/webhook/get.handler.ts
+++ b/packages/trpc/server/routers/viewer/webhook/get.handler.ts
@@ -1,4 +1,4 @@
-import { prisma } from "@calcom/prisma";
+import { WebhookRepository } from "@calcom/lib/server/repository/webhook";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
import type { TGetInputSchema } from "./get.schema";
@@ -11,20 +11,5 @@ type GetOptions = {
};
export const getHandler = async ({ ctx: _ctx, input }: GetOptions) => {
- return await prisma.webhook.findUniqueOrThrow({
- where: {
- id: input.webhookId,
- },
- select: {
- id: true,
- subscriberUrl: true,
- payloadTemplate: true,
- active: true,
- eventTriggers: true,
- secret: true,
- teamId: true,
- userId: true,
- platform: true,
- },
- });
+ return await WebhookRepository.findByWebhookId(input.webhookId);
};
diff --git a/packages/trpc/server/routers/viewer/webhook/getByViewer.handler.ts b/packages/trpc/server/routers/viewer/webhook/getByViewer.handler.ts
index 8048e267350..6e146d9bfec 100644
--- a/packages/trpc/server/routers/viewer/webhook/getByViewer.handler.ts
+++ b/packages/trpc/server/routers/viewer/webhook/getByViewer.handler.ts
@@ -1,12 +1,7 @@
-import { compareMembership } from "@calcom/lib/event-types/getEventTypesByViewer";
-import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
-import { prisma } from "@calcom/prisma";
+import { WebhookRepository } from "@calcom/lib/server/repository/webhook";
import type { Webhook } from "@calcom/prisma/client";
-import { MembershipRole } from "@calcom/prisma/enums";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
-import { TRPCError } from "@trpc/server";
-
type GetByViewerOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
@@ -37,130 +32,10 @@ export type WebhooksByViewer = {
}[];
};
-const filterWebhooks = (webhook: Webhook) => {
- const appIds = [
- "zapier",
- // Add more if needed
- ];
-
- return !appIds.some((appId: string) => webhook.appId == appId);
-};
-
export const getByViewerHandler = async ({ ctx }: GetByViewerOptions) => {
- const user = await prisma.user.findUnique({
- where: {
- id: ctx.user.id,
- },
- select: {
- username: true,
- avatarUrl: true,
- name: true,
- webhooks: true,
- teams: {
- where: {
- accepted: true,
- },
- select: {
- role: true,
- team: {
- select: {
- id: true,
- isOrganization: true,
- name: true,
- slug: true,
- parentId: true,
- metadata: true,
- members: {
- select: {
- userId: true,
- },
- },
- webhooks: true,
- },
- },
- },
- },
- },
- });
-
- if (!user) {
- throw new TRPCError({ code: "INTERNAL_SERVER_ERROR" });
- }
-
- let userWebhooks = user.webhooks;
- userWebhooks = userWebhooks.filter(filterWebhooks);
- let webhookGroups: WebhookGroup[] = [];
- const bookerUrl = await getBookerBaseUrl(ctx.user.profile?.organizationId ?? null);
-
- const image = user?.username ? `${bookerUrl}/${user.username}/avatar.png` : undefined;
- webhookGroups.push({
- teamId: null,
- profile: {
- slug: user.username,
- name: user.name,
- image,
- },
- webhooks: userWebhooks,
- metadata: {
- readOnly: false,
- },
+ return await WebhookRepository.getAllWebhooksByUserId({
+ userId: ctx.user.id,
+ organizationId: ctx.user.profile?.organizationId,
+ userRole: ctx.user.role,
});
-
- const teamMemberships = user.teams.map((membership) => ({
- teamId: membership.team.id,
- membershipRole: membership.role,
- }));
-
- const teamWebhookGroups: WebhookGroup[] = user.teams.map((membership) => {
- const orgMembership = teamMemberships.find(
- (teamM) => teamM.teamId === membership.team.parentId
- )?.membershipRole;
- return {
- teamId: membership.team.id,
- profile: {
- name: membership.team.name,
- slug: membership.team.slug ? (!membership.team.parentId ? `/team` : `${membership.team.slug}`) : null,
- image: `${bookerUrl}/team/${membership.team.slug}/avatar.png`,
- },
- metadata: {
- readOnly:
- membership.role ===
- (membership.team.parentId
- ? orgMembership && compareMembership(orgMembership, membership.role)
- ? orgMembership
- : MembershipRole.MEMBER
- : MembershipRole.MEMBER),
- },
- webhooks: membership.team.webhooks.filter(filterWebhooks),
- };
- });
-
- webhookGroups = webhookGroups.concat(teamWebhookGroups);
-
- if (ctx.user.role === "ADMIN") {
- const platformWebhooks = await prisma.webhook.findMany({
- where: { platform: true },
- });
- webhookGroups.push({
- teamId: null,
- profile: {
- slug: "Platform",
- name: "Platform",
- image,
- },
- webhooks: platformWebhooks,
- metadata: {
- readOnly: false,
- },
- });
- }
-
- return {
- webhookGroups: webhookGroups.filter((groupBy) => !!groupBy.webhooks?.length),
- profiles: webhookGroups.map((group) => ({
- teamId: group.teamId,
- ...group.profile,
- ...group.metadata,
- })),
- };
};
diff --git a/packages/ui/components/createButton/CreateButtonWithTeamsList.tsx b/packages/ui/components/createButton/CreateButtonWithTeamsList.tsx
index 23af0d266a6..36a1c8bc1b2 100644
--- a/packages/ui/components/createButton/CreateButtonWithTeamsList.tsx
+++ b/packages/ui/components/createButton/CreateButtonWithTeamsList.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import { trpc } from "@calcom/trpc/react";
import type { CreateBtnProps, Option } from "./CreateButton";
diff --git a/packages/ui/components/list/List.tsx b/packages/ui/components/list/List.tsx
index 94b7c496322..85e652e302e 100644
--- a/packages/ui/components/list/List.tsx
+++ b/packages/ui/components/list/List.tsx
@@ -139,7 +139,7 @@ export function ListItemText<TComponent extends keyof JSX.IntrinsicElements = "s
component,
{
...passThroughProps,
- className: classNames("text-sm text-subtle truncate", props.className),
+ className: classNames("text-sm text-subtle truncate prose", props.className),
"data-testid": "list-item-text",
},
props.children
diff --git a/packages/ui/components/tooltip/Tooltip.tsx b/packages/ui/components/tooltip/Tooltip.tsx
index d784cab9587..edb222b0121 100644
--- a/packages/ui/components/tooltip/Tooltip.tsx
+++ b/packages/ui/components/tooltip/Tooltip.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import React from "react";