| 100 | } |
| 101 | |
| 102 | export async function getMembers(organizationId: string) { |
| 103 | const [members, access] = await Promise.all([ |
| 104 | db.member.findMany({ |
| 105 | where: { |
| 106 | organizationId, |
| 107 | userId: { |
| 108 | not: null, |
| 109 | }, |
| 110 | }, |
| 111 | include: { |
| 112 | user: true, |
| 113 | }, |
| 114 | }), |
| 115 | db.projectAccess.findMany({ |
| 116 | where: { |
| 117 | organizationId, |
| 118 | }, |
| 119 | }), |
| 120 | ]); |
| 121 | |
| 122 | return members.map((member) => ({ |
| 123 | ...member, |
| 124 | access: access.filter((a) => a.userId === member.userId), |
| 125 | })); |
| 126 | } |
| 127 | |
| 128 | export async function getMember(organizationId: string, userId: string) { |
| 129 | return db.member.findFirst({ |