chore: settings/organizations - remove pages router and use app router (#16774)

* remove pages router and use app router

* remove future/settings/organizations files

* fix billing page

* sync SettingsLayoutAppDirClient and fix members page

* fix attribute pages

* remove isAppDir where not needed anymore

* add CTA button for members view
This commit is contained in:
Benny Joo authored and GitHub committed 2024-11-25 16:49:00 -05:00
1 parent aea8588a21
commit f097f852ad
61 files changed
+154 -504

No files matched your search

@@ -37,7 +37,7 @@ export default function MemberListItem(props: Props) {
<UserAvatar noOrganizationIndicator size="sm" user={user} className="h-10 w-10 rounded-full" />
<div className="ms-3 inline-block overflow-hidden">
<div className="mb-1 flex">
<div className="mb-1 flex items-center">
<span className="text-default mr-1 text-sm font-bold leading-4">{name}</span>
{!props.member.accepted && <TeamPill color="orange" text={t("pending")} />}
@@ -6,7 +6,6 @@ import { useFormContext } from "react-hook-form";
import { z } from "zod";
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
import SettingsLayout from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Button, useMeta, showToast } from "@calcom/ui";
@@ -89,8 +88,5 @@ function CreateAttributeHeader(props: { isPending: boolean }) {
</>
);
}
export function getLayout(page: React.ReactElement) {
return <SettingsLayout hideHeader>{page}</SettingsLayout>;
}
export default CreateAttributesPage;
@@ -6,7 +6,6 @@ import { useFormContext } from "react-hook-form";
import { z } from "zod";
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
import SettingsLayout from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Button, useMeta, showToast } from "@calcom/ui";
@@ -109,8 +108,4 @@ function EditAttributeHeader(props: { isPending: boolean }) {
);
}
export function getLayout(page: React.ReactElement) {
return <SettingsLayout hideHeader>{page}</SettingsLayout>;
}
export default CreateAttributesPage;
@@ -4,7 +4,6 @@ import type { Dispatch, SetStateAction } from "react";
import { useState } from "react";
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
import SettingsLayout from "@calcom/features/settings/layouts/SettingsLayout";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { RouterOutputs } from "@calcom/trpc/react";
import { trpc } from "@calcom/trpc/react";
@@ -208,8 +207,4 @@ function ListAttributeHeader() {
);
}
export function getLayout(page: React.ReactElement) {
return <SettingsLayout hideHeader>{page}</SettingsLayout>;
}
export default OrganizationAttributesPage;
@@ -28,18 +28,9 @@ import {
import { LockEventTypeSwitch } from "../components/LockEventTypeSwitch";
import { NoSlotsNotificationSwitch } from "../components/NoSlotsNotificationSwitch";
const SkeletonLoader = ({
title,
description,
isAppDir,
}: {
title: string;
description: string;
isAppDir?: boolean;
}) => {
const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
return (
<SkeletonContainer>
{!isAppDir ? <Meta title={title} description={description} borderInShellHeader={true} /> : null}
<div className="mb-8 mt-6 space-y-6">
<SkeletonText className="h-8 w-full" />
<SkeletonText className="h-8 w-full" />
@@ -58,7 +49,7 @@ interface GeneralViewProps {
localeProp: string;
}
const OrgGeneralView = ({ isAppDir }: { isAppDir?: boolean }) => {
const OrgGeneralView = () => {
const { t } = useLocale();
const router = useRouter();
const session = useSession();
@@ -92,7 +83,6 @@ const OrgGeneralView = ({ isAppDir }: { isAppDir?: boolean }) => {
currentOrg={currentOrg}
isAdminOrOwner={isAdminOrOwner}
localeProp={user?.locale ?? "en"}
isAppDir={isAppDir}
/>
<LockEventTypeSwitch currentOrg={currentOrg} isAdminOrOwner={!!isAdminOrOwner} />
@@ -101,12 +91,7 @@ const OrgGeneralView = ({ isAppDir }: { isAppDir?: boolean }) => {
);
};
const GeneralView = ({
currentOrg,
isAdminOrOwner,
localeProp,
isAppDir,
}: GeneralViewProps & { isAppDir?: boolean }) => {
const GeneralView = ({ currentOrg, isAdminOrOwner, localeProp }: GeneralViewProps) => {
const { t } = useLocale();
const mutation = trpc.viewer.organizations.update.useMutation({
@@ -165,13 +150,6 @@ const GeneralView = ({
weekStart: values.weekStart.value,
});
}}>
{!isAppDir ? (
<Meta
title={t("general")}
description={t("organization_general_description")}
borderInShellHeader={true}
/>
) : null}
<div className="border-subtle border-x border-y-0 px-4 py-8 sm:px-6">
<Controller
name="timeZone"
@@ -7,7 +7,7 @@ import { MembershipRole } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
import { Meta } from "@calcom/ui";
const MembersView = ({ isAppDir }: { isAppDir?: boolean }) => {
const MembersView = () => {
const { t } = useLocale();
const { data: currentOrg, isPending } = trpc.viewer.organizations.listCurrent.useQuery();
@@ -20,9 +20,6 @@ const MembersView = ({ isAppDir }: { isAppDir?: boolean }) => {
return (
<LicenseRequired>
{!isAppDir ? (
<Meta title={t("organization_members")} description={t("organization_description")} />
) : null}
<div>{!isPending && canLoggedInUserSeeMembers && <UserListTable />}</div>
{!canLoggedInUserSeeMembers && (
<div className="border-subtle rounded-xl border p-6" data-testId="members-privacy-warning">
@@ -5,13 +5,10 @@ import { Meta } from "@calcom/ui";
import { OtherTeamsListing } from "./../components/OtherTeamsListing";
const OtherTeamListingView = ({ isAppDir }: { isAppDir?: boolean }): React.ReactElement => {
const OtherTeamListingView = (): React.ReactElement => {
const { t } = useLocale();
return (
<>
{!isAppDir ? (
<Meta title={t("org_admin_other_teams")} description={t("org_admin_other_teams_description")} />
) : null}
<OtherTeamsListing />
</>
);
@@ -12,7 +12,7 @@ import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
import { MembershipRole } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
import type { RouterOutputs } from "@calcom/trpc/react";
import { Meta, showToast, Button } from "@calcom/ui";
import { showToast, Button } from "@calcom/ui";
import MakeTeamPrivateSwitch from "../../../teams/components/MakeTeamPrivateSwitch";
import MemberListItem from "../components/MemberListItem";
@@ -59,7 +59,37 @@ function MembersList(props: MembersListProps) {
);
}
const MembersView = ({ isAppDir }: { isAppDir?: boolean }) => {
export const memberInvitationModalRef = {
current: null as null | ((show: boolean) => void),
};
export const TeamMembersCTA = () => {
const { t } = useLocale();
const session = useSession();
const { data: currentOrg } = trpc.viewer.organizations.listCurrent.useQuery(undefined, {
enabled: !!session.data?.user?.org,
});
const isOrgAdminOrOwner =
currentOrg &&
(currentOrg.user.role === MembershipRole.OWNER || currentOrg.user.role === MembershipRole.ADMIN);
if (!isOrgAdminOrOwner) return null;
return (
<Button
type="button"
color="primary"
StartIcon="plus"
className="ml-auto"
onClick={() => memberInvitationModalRef.current?.(true)}
data-testid="new-member-button">
{t("add")}
</Button>
);
};
const MembersView = () => {
const { t, i18n } = useLocale();
const router = useRouter();
const params = useParamsWithFallback();
@@ -71,9 +101,6 @@ const MembersView = ({ isAppDir }: { isAppDir?: boolean }) => {
const limit = 20;
const [showMemberInvitationModal, setShowMemberInvitationModal] = useState<boolean>(false);
const { data: currentOrg } = trpc.viewer.organizations.listCurrent.useQuery(undefined, {
enabled: !!session.data?.user?.org,
});
const {
data: team,
isPending: isTeamLoading,
@@ -119,6 +146,13 @@ const MembersView = ({ isAppDir }: { isAppDir?: boolean }) => {
[router, otherMembersError, otherTeamError]
);
useEffect(() => {
memberInvitationModalRef.current = setShowMemberInvitationModal;
return () => {
memberInvitationModalRef.current = null;
};
}, []);
const isPending = isTeamLoading || isOrgListLoading;
const inviteMemberMutation = trpc.viewer.teams.inviteMember.useMutation({
onSuccess: () => {
@@ -129,33 +163,8 @@ const MembersView = ({ isAppDir }: { isAppDir?: boolean }) => {
},
});
const isOrgAdminOrOwner =
currentOrg &&
(currentOrg.user.role === MembershipRole.OWNER || currentOrg.user.role === MembershipRole.ADMIN);
return (
<>
{!isAppDir ? (
<Meta
title={t("team_members")}
description={t("members_team_description")}
CTA={
isOrgAdminOrOwner ? (
<Button
type="button"
color="primary"
StartIcon="plus"
className="ml-auto"
onClick={() => setShowMemberInvitationModal(true)}
data-testid="new-member-button">
{t("add")}
</Button>
) : (
<></>
)
}
/>
) : null}
{!isPending && (
<>
<div>
@@ -54,7 +54,7 @@ const teamProfileFormSchema = z.object({
bio: z.string(),
});
const OtherTeamProfileView = ({ isAppDir }: { isAppDir?: boolean }) => {
const OtherTeamProfileView = () => {
const { t } = useLocale();
const router = useRouter();
const utils = trpc.useUtils();
@@ -169,7 +169,6 @@ const OtherTeamProfileView = ({ isAppDir }: { isAppDir?: boolean }) => {
return (
<>
{!isAppDir ? <Meta title={t("profile")} description={t("profile_team_description")} /> : null}
{!isPending ? (
<>
{isAdmin ? (
@@ -57,18 +57,9 @@ type FormValues = {
calVideoLogo: string | null;
};
const SkeletonLoader = ({
title,
description,
isAppDir,
}: {
title: string;
description: string;
isAppDir?: boolean;
}) => {
const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
return (
<SkeletonContainer>
{!isAppDir ? <Meta title={title} description={description} borderInShellHeader={true} /> : null}
<div className="border-subtle space-y-6 rounded-b-xl 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" />
@@ -84,7 +75,7 @@ const SkeletonLoader = ({
);
};
const OrgProfileView = ({ isAppDir }: { isAppDir?: boolean }) => {
const OrgProfileView = () => {
const { t } = useLocale();
const router = useRouter();
@@ -110,9 +101,7 @@ const OrgProfileView = ({ isAppDir }: { isAppDir?: boolean }) => {
);
if (isPending || !orgBranding || !currentOrganisation) {
return (
<SkeletonLoader isAppDir={isAppDir} title={t("profile")} description={t("profile_org_description")} />
);
return <SkeletonLoader title={t("profile")} description={t("profile_org_description")} />;
}
const isOrgAdminOrOwner =
@@ -138,9 +127,6 @@ const OrgProfileView = ({ isAppDir }: { isAppDir?: boolean }) => {
return (
<LicenseRequired>
{!isAppDir ? (
<Meta title={t("profile")} description={t("profile_org_description")} borderInShellHeader={true} />
) : null}
<>
{isOrgAdminOrOwner ? (
<>
@@ -8,7 +8,7 @@ import { AppSkeletonLoader as SkeletonLoader, Meta } from "@calcom/ui";
import SSOConfiguration from "../components/SSOConfiguration";
const SAMLSSO = ({ isAppDir }: { isAppDir?: boolean }) => {
const SAMLSSO = () => {
const { t } = useLocale();
const { data, status } = useSession();
@@ -25,9 +25,6 @@ const SAMLSSO = ({ isAppDir }: { isAppDir?: boolean }) => {
return !!isAdminOrOwner ? (
<div className="bg-default w-full sm:mx-0 xl:mt-0">
{!isAppDir ? (
<Meta title={t("sso_configuration")} description={t("sso_configuration_description_orgs")} />
) : null}
<SSOConfiguration teamId={org.id} />
</div>
) : (
@@ -672,6 +672,7 @@ export type SettingsLayoutProps = {
children: React.ReactNode;
currentOrg: Awaited<ReturnType<typeof OrganizationRepository.findCurrentOrg>> | null;
otherTeams: Awaited<ReturnType<typeof OrganizationRepository.findTeamsInOrgIamNotPartOf>> | null;
containerClassName?: string;
} & ComponentProps<typeof Shell>;
export default function SettingsLayoutAppDirClient({
@@ -723,7 +724,8 @@ export default function SettingsLayoutAppDirClient({
<MobileSettingsContainer onSideContainerOpen={() => setSideContainerOpen(!sideContainerOpen)} />
}>
<div className="flex flex-1 [&>*]:flex-1">
<div className="mx-auto max-w-full justify-center lg:max-w-3xl">
<div
className={classNames("mx-auto max-w-full justify-center lg:max-w-3xl", rest.containerClassName)}>
<ErrorBoundary>{children}</ErrorBoundary>
</div>
</div>