feat: add shared notification, communication, and export services for bookings, courses, and events; introduce btree_gist extension and new booking atomic function
This commit is contained in:
@@ -45,40 +45,54 @@ export default async function MembersPage({ params, searchParams }: Props) {
|
||||
pageSize: PAGE_SIZE,
|
||||
});
|
||||
|
||||
// Fetch categories, departments, and tags in parallel
|
||||
const [duesCategories, departments, tagsResult, tagAssignmentsResult] =
|
||||
await Promise.all([
|
||||
organization.listDuesCategories(acct.id),
|
||||
organization.listDepartmentsWithCounts(acct.id),
|
||||
(client.from as any)('member_tags')
|
||||
.select('id, name, color')
|
||||
.eq('account_id', acct.id)
|
||||
.order('sort_order'),
|
||||
(client.from as any)('member_tag_assignments')
|
||||
.select('member_id, tag_id, member_tags(id, name, color)')
|
||||
.in(
|
||||
'member_id',
|
||||
result.data.map((m: any) => m.id),
|
||||
),
|
||||
]);
|
||||
// Fetch categories and departments (always available)
|
||||
const [duesCategories, departments] = await Promise.all([
|
||||
organization.listDuesCategories(acct.id),
|
||||
organization.listDepartmentsWithCounts(acct.id),
|
||||
]);
|
||||
|
||||
// Build memberTags lookup: { memberId: [{ id, name, color }] }
|
||||
// Fetch tags gracefully (tables may not exist if migration hasn't run)
|
||||
let accountTags: Array<{ id: string; name: string; color: string }> = [];
|
||||
const memberTags: Record<
|
||||
string,
|
||||
Array<{ id: string; name: string; color: string }>
|
||||
> = {};
|
||||
|
||||
for (const a of tagAssignmentsResult.data ?? []) {
|
||||
const memberId = String(a.member_id);
|
||||
const tag = a.member_tags;
|
||||
if (!tag) continue;
|
||||
try {
|
||||
const memberIds = result.data.map((m: any) => m.id);
|
||||
|
||||
if (!memberTags[memberId]) memberTags[memberId] = [];
|
||||
memberTags[memberId]!.push({
|
||||
id: String(tag.id),
|
||||
name: String(tag.name),
|
||||
color: String(tag.color),
|
||||
});
|
||||
const [tagsResult, tagAssignmentsResult] = await Promise.all([
|
||||
(client.from as any)('member_tags')
|
||||
.select('id, name, color')
|
||||
.eq('account_id', acct.id)
|
||||
.order('sort_order'),
|
||||
memberIds.length > 0
|
||||
? (client.from as any)('member_tag_assignments')
|
||||
.select('member_id, tag_id, member_tags(id, name, color)')
|
||||
.in('member_id', memberIds)
|
||||
: { data: [] },
|
||||
]);
|
||||
|
||||
accountTags = (tagsResult.data ?? []).map((t: any) => ({
|
||||
id: String(t.id),
|
||||
name: String(t.name),
|
||||
color: String(t.color),
|
||||
}));
|
||||
|
||||
for (const a of tagAssignmentsResult.data ?? []) {
|
||||
const memberId = String(a.member_id);
|
||||
const tag = a.member_tags;
|
||||
if (!tag) continue;
|
||||
|
||||
if (!memberTags[memberId]) memberTags[memberId] = [];
|
||||
memberTags[memberId]!.push({
|
||||
id: String(tag.id),
|
||||
name: String(tag.name),
|
||||
color: String(tag.color),
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
// Tags tables may not exist yet — gracefully degrade
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -100,11 +114,7 @@ export default async function MembersPage({ params, searchParams }: Props) {
|
||||
name: String(d.name),
|
||||
memberCount: d.memberCount,
|
||||
}))}
|
||||
tags={(tagsResult.data ?? []).map((t: any) => ({
|
||||
id: String(t.id),
|
||||
name: String(t.name),
|
||||
color: String(t.color),
|
||||
}))}
|
||||
tags={accountTags}
|
||||
memberTags={memberTags}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user