Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PageLoading } from "@/components/core/loaders";
import PermissionsManagement from "@/components/core/permissions-management";
import PageSection from "@/components/core/section";
import PageTitle from "@/components/layout/page-title";
import { isPersonalTenant } from "@/lib/utils/tenant";
import { useTRPC } from "@/trpc/client";

export default function ProjectSettings() {
Expand All @@ -21,7 +22,7 @@ export default function ProjectSettings() {
}),
);

const isOrgAdmin = tenant === "me";
const isOrgAdmin = isPersonalTenant(tenant);

if (isLoading || !project) return <PageLoading />;

Expand Down
42 changes: 27 additions & 15 deletions app/(dashboard)/[tenant]/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ import { ProfileSettings } from "@/components/settings/profile-settings";
import { TeamSettings } from "@/components/settings/team-settings";
import { WorkspaceSettings } from "@/components/settings/workspace-settings";
import { bytesToMegabytes } from "@/lib/blobStore";
import { isPersonalTenant } from "@/lib/utils/tenant";
import { caller } from "@/trpc/server";

export default async function Settings() {
export default async function Settings({
params,
}: {
params: Promise<{ tenant: string }>;
}) {
const { tenant } = await params;
const isPersonal = isPersonalTenant(tenant);

const [storage, timezone, projectsData] = await Promise.all([
caller.settings.getStorageUsage(),
caller.settings.getTimezone(),
Expand All @@ -20,21 +28,25 @@ export default async function Settings() {
<>
<PageTitle title="Settings" />

<PageSection
title="Workspace"
titleIcon={<Building2 className="w-5 h-5" />}
bottomMargin
>
<WorkspaceSettings />
</PageSection>
{!isPersonal && (
<PageSection
title="Workspace"
titleIcon={<Building2 className="w-5 h-5" />}
bottomMargin
>
<WorkspaceSettings />
</PageSection>
)}

<PageSection
title="Team"
titleIcon={<Users className="w-5 h-5" />}
bottomMargin
>
<TeamSettings />
</PageSection>
{!isPersonal && (
<PageSection
title="Team"
titleIcon={<Users className="w-5 h-5" />}
bottomMargin
>
<TeamSettings />
</PageSection>
)}

<PageSection
title="Usage"
Expand Down
3 changes: 2 additions & 1 deletion app/(dashboard)/[tenant]/today/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Card } from "@/components/ui/card";
import { toDateStringWithDay } from "@/lib/utils/date";
import { displayMutationError } from "@/lib/utils/error";
import { eventToHumanReadableString } from "@/lib/utils/useEvents";
import { isPersonalTenant } from "@/lib/utils/tenant";
import { useTRPC } from "@/trpc/client";

export default function Today() {
Expand All @@ -52,7 +53,7 @@ export default function Today() {
});

const projects = projectsData?.projects;
const isOrgAdmin = projectsData?.isOrgAdmin ?? tenant === "me";
const isOrgAdmin = projectsData?.isOrgAdmin ?? isPersonalTenant(tenant);

const { dueToday = [], overDue = [], events = [] } = todayData ?? {};

Expand Down
5 changes: 5 additions & 0 deletions lib/utils/tenant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const PERSONAL_TENANT = "me";

export function isPersonalTenant(tenant: string) {
return tenant === PERSONAL_TENANT;
}
3 changes: 2 additions & 1 deletion lib/utils/useOwner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { redirect } from "next/navigation";
import { organization } from "@/drizzle/auth-schema";
import { auth } from "@/lib/auth";
import { database } from "@/lib/utils/useDatabase";
import { PERSONAL_TENANT } from "@/lib/utils/tenant";

type Result = {
userId: string;
Expand All @@ -24,7 +25,7 @@ export async function getOwner(): Promise<Result> {

const activeOrgId = session.session.activeOrganizationId;

let orgSlug = "me";
let orgSlug = PERSONAL_TENANT;
if (activeOrgId) {
const db = database();
const org = await db
Expand Down