|
1 |
| -import { auth } from "@/auth" |
2 |
| -import { getUser } from "@/data/user" |
3 |
| -import { prisma } from "@/prisma" |
4 |
| -import { MemberTable } from "../components/memberTable" |
5 |
| -import { InviteTable } from "../components/inviteTable" |
6 |
| -import { Separator } from "@/components/ui/separator" |
7 |
| -import { getCurrentUserRole } from "@/actions" |
8 |
| -import { isServiceError } from "@/lib/utils" |
9 |
| - |
10 |
| -interface GeneralSettingsPageProps { |
11 |
| - params: { |
12 |
| - domain: string |
13 |
| - } |
14 |
| -} |
15 |
| - |
16 |
| -export default async function GeneralSettingsPage({ params: { domain } }: GeneralSettingsPageProps) { |
17 |
| - const fetchData = async () => { |
18 |
| - const session = await auth() |
19 |
| - if (!session) { |
20 |
| - return null |
21 |
| - } |
22 |
| - |
23 |
| - const user = await getUser(session.user.id) |
24 |
| - if (!user) { |
25 |
| - return null |
26 |
| - } |
27 |
| - |
28 |
| - const activeOrg = await prisma.org.findUnique({ |
29 |
| - where: { |
30 |
| - domain, |
31 |
| - }, |
32 |
| - }) |
33 |
| - |
34 |
| - if (!activeOrg) { |
35 |
| - return null |
36 |
| - } |
37 |
| - |
38 |
| - const members = await prisma.user.findMany({ |
39 |
| - where: { |
40 |
| - orgs: { |
41 |
| - some: { |
42 |
| - orgId: activeOrg.id, |
43 |
| - }, |
44 |
| - }, |
45 |
| - }, |
46 |
| - include: { |
47 |
| - orgs: { |
48 |
| - where: { |
49 |
| - orgId: activeOrg.id, |
50 |
| - }, |
51 |
| - select: { |
52 |
| - role: true, |
53 |
| - }, |
54 |
| - }, |
55 |
| - }, |
56 |
| - }) |
57 |
| - |
58 |
| - const invites = await prisma.invite.findMany({ |
59 |
| - where: { |
60 |
| - orgId: activeOrg.id, |
61 |
| - }, |
62 |
| - }) |
63 |
| - |
64 |
| - const memberInfo = members.map((member) => ({ |
65 |
| - id: member.id, |
66 |
| - name: member.name!, |
67 |
| - email: member.email!, |
68 |
| - role: member.orgs[0].role, |
69 |
| - })) |
70 |
| - |
71 |
| - const inviteInfo = invites.map((invite) => ({ |
72 |
| - id: invite.id, |
73 |
| - email: invite.recipientEmail, |
74 |
| - createdAt: invite.createdAt, |
75 |
| - })) |
76 |
| - |
77 |
| - const currentUserRole = await getCurrentUserRole(domain) |
78 |
| - if (isServiceError(currentUserRole)) { |
79 |
| - return null |
80 |
| - } |
81 |
| - |
82 |
| - return { |
83 |
| - user, |
84 |
| - memberInfo, |
85 |
| - inviteInfo, |
86 |
| - userRole: currentUserRole, |
87 |
| - } |
88 |
| - } |
89 |
| - |
90 |
| - const data = await fetchData() |
91 |
| - if (!data) { |
92 |
| - return <div>Error: Unable to fetch data</div> |
93 |
| - } |
94 |
| - const { user, memberInfo, inviteInfo, userRole } = data |
95 | 1 |
|
| 2 | +export default async function GeneralSettingsPage() { |
96 | 3 | return (
|
97 |
| - <div className="space-y-6"> |
98 |
| - <div> |
99 |
| - <h3 className="text-lg font-medium">Members</h3> |
100 |
| - <p className="text-sm text-muted-foreground">Invite and manage members of your organization.</p> |
101 |
| - </div> |
102 |
| - <Separator /> |
103 |
| - <div className="space-y-6"> |
104 |
| - <MemberTable currentUserRole={userRole} currentUserId={user.id} initialMembers={memberInfo} /> |
105 |
| - <InviteTable initialInvites={inviteInfo} /> |
106 |
| - </div> |
107 |
| - </div> |
| 4 | + <p>todo</p> |
108 | 5 | )
|
109 | 6 | }
|
110 | 7 |
|
0 commit comments