Skip to content

Commit d9aa8ad

Browse files
committed
Fix settings for personal workspace
1 parent 83aab4e commit d9aa8ad

File tree

4 files changed

+38
-18
lines changed

4 files changed

+38
-18
lines changed

app/(dashboard)/[tenant]/projects/[projectId]/settings/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PageLoading } from "@/components/core/loaders";
77
import PermissionsManagement from "@/components/core/permissions-management";
88
import PageSection from "@/components/core/section";
99
import PageTitle from "@/components/layout/page-title";
10+
import { isPersonalTenant } from "@/lib/utils/useOwner";
1011
import { useTRPC } from "@/trpc/client";
1112

1213
export default function ProjectSettings() {
@@ -21,7 +22,7 @@ export default function ProjectSettings() {
2122
}),
2223
);
2324

24-
const isOrgAdmin = tenant === "me";
25+
const isOrgAdmin = isPersonalTenant(tenant);
2526

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

app/(dashboard)/[tenant]/settings/page.tsx

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ import { ProfileSettings } from "@/components/settings/profile-settings";
55
import { TeamSettings } from "@/components/settings/team-settings";
66
import { WorkspaceSettings } from "@/components/settings/workspace-settings";
77
import { bytesToMegabytes } from "@/lib/blobStore";
8+
import { isPersonalTenant } from "@/lib/utils/useOwner";
89
import { caller } from "@/trpc/server";
910

10-
export default async function Settings() {
11+
export default async function Settings({
12+
params,
13+
}: {
14+
params: Promise<{ tenant: string }>;
15+
}) {
16+
const { tenant } = await params;
17+
const isPersonal = isPersonalTenant(tenant);
18+
1119
const [storage, timezone, projectsData] = await Promise.all([
1220
caller.settings.getStorageUsage(),
1321
caller.settings.getTimezone(),
@@ -20,21 +28,25 @@ export default async function Settings() {
2028
<>
2129
<PageTitle title="Settings" />
2230

23-
<PageSection
24-
title="Workspace"
25-
titleIcon={<Building2 className="w-5 h-5" />}
26-
bottomMargin
27-
>
28-
<WorkspaceSettings />
29-
</PageSection>
31+
{!isPersonal && (
32+
<PageSection
33+
title="Workspace"
34+
titleIcon={<Building2 className="w-5 h-5" />}
35+
bottomMargin
36+
>
37+
<WorkspaceSettings />
38+
</PageSection>
39+
)}
3040

31-
<PageSection
32-
title="Team"
33-
titleIcon={<Users className="w-5 h-5" />}
34-
bottomMargin
35-
>
36-
<TeamSettings />
37-
</PageSection>
41+
{!isPersonal && (
42+
<PageSection
43+
title="Team"
44+
titleIcon={<Users className="w-5 h-5" />}
45+
bottomMargin
46+
>
47+
<TeamSettings />
48+
</PageSection>
49+
)}
3850

3951
<PageSection
4052
title="Usage"

app/(dashboard)/[tenant]/today/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { Card } from "@/components/ui/card";
2727
import { toDateStringWithDay } from "@/lib/utils/date";
2828
import { displayMutationError } from "@/lib/utils/error";
2929
import { eventToHumanReadableString } from "@/lib/utils/useEvents";
30+
import { isPersonalTenant } from "@/lib/utils/useOwner";
3031
import { useTRPC } from "@/trpc/client";
3132

3233
export default function Today() {
@@ -52,7 +53,7 @@ export default function Today() {
5253
});
5354

5455
const projects = projectsData?.projects;
55-
const isOrgAdmin = projectsData?.isOrgAdmin ?? tenant === "me";
56+
const isOrgAdmin = projectsData?.isOrgAdmin ?? isPersonalTenant(tenant);
5657

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

lib/utils/useOwner.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export async function getOwner(): Promise<Result> {
2424

2525
const activeOrgId = session.session.activeOrganizationId;
2626

27-
let orgSlug = "me";
27+
let orgSlug = PERSONAL_TENANT;
2828
if (activeOrgId) {
2929
const db = database();
3030
const org = await db
@@ -45,6 +45,12 @@ export async function getOwner(): Promise<Result> {
4545
};
4646
}
4747

48+
export const PERSONAL_TENANT = "me";
49+
50+
export function isPersonalTenant(tenant: string) {
51+
return tenant === PERSONAL_TENANT;
52+
}
53+
4854
export async function getTimezone() {
4955
const cookieStore = await cookies();
5056
return (

0 commit comments

Comments
 (0)