refactor: remove obsolete member management API module
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { EditMemberForm } from '@kit/member-management/components';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
@@ -22,8 +22,8 @@ export default async function EditMemberPage({ params }: Props) {
|
||||
.single();
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const member = await api.getMember(acct.id, memberId);
|
||||
const { query } = createMemberServices(client);
|
||||
const member = await query.getById(acct.id, memberId);
|
||||
if (!member) return <div>{t('detail.notFound')}</div>;
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { MemberDetailTabs } from '@kit/member-management/components';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
@@ -18,14 +18,14 @@ export default async function MemberDetailPage({ params }: Props) {
|
||||
.single();
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const member = await api.getMember(acct.id, memberId);
|
||||
const { query, organization } = createMemberServices(client);
|
||||
const member = await query.getById(acct.id, memberId);
|
||||
if (!member) return <AccountNotFound />;
|
||||
|
||||
const [roles, honors, mandates] = await Promise.all([
|
||||
api.listMemberRoles(memberId),
|
||||
api.listMemberHonors(memberId),
|
||||
api.listMandates(memberId),
|
||||
organization.listMemberRoles(memberId),
|
||||
organization.listMemberHonors(memberId),
|
||||
organization.listMandates(memberId),
|
||||
]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
KeyRound,
|
||||
LayoutList,
|
||||
Settings,
|
||||
Tag,
|
||||
Users,
|
||||
} from 'lucide-react';
|
||||
|
||||
@@ -160,6 +161,10 @@ function SettingsMenu({ basePath }: { basePath: string }) {
|
||||
<Users className="mr-2 size-4" />
|
||||
Abteilungen
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={navigate(`${basePath}/tags`)}>
|
||||
<Tag className="mr-2 size-4" />
|
||||
Tags verwalten
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={navigate(`${basePath}/cards`)}>
|
||||
<IdCard className="mr-2 size-4" />
|
||||
Mitgliedsausweise
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { ApplicationWorkflow } from '@kit/member-management/components';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
@@ -19,8 +19,8 @@ export default async function ApplicationsPage({ params }: Props) {
|
||||
.single();
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const applications = await api.listApplications(acct.id);
|
||||
const { workflow } = createMemberServices(client);
|
||||
const applications = await workflow.listApplications(acct.id);
|
||||
|
||||
return (
|
||||
<ApplicationWorkflow
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CreditCard } from 'lucide-react';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
@@ -26,8 +26,8 @@ export default async function MemberCardsPage({ params }: Props) {
|
||||
.single();
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const result = await api.listMembers(acct.id, {
|
||||
const { query } = createMemberServices(client);
|
||||
const result = await query.list(acct.id, {
|
||||
status: 'active',
|
||||
pageSize: CARDS_PAGE_SIZE,
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Users } from 'lucide-react';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
@@ -26,8 +26,8 @@ export default async function DepartmentsPage({ params }: Props) {
|
||||
.single();
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const departments = await api.listDepartments(acct.id);
|
||||
const { organization } = createMemberServices(client);
|
||||
const departments = await organization.listDepartments(acct.id);
|
||||
|
||||
return (
|
||||
<CmsPageShell
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { DuesCategoryManager } from '@kit/member-management/components';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
@@ -22,8 +22,8 @@ export default async function DuesPage({ params }: Props) {
|
||||
.single();
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const categories = await api.listDuesCategories(acct.id);
|
||||
const { organization } = createMemberServices(client);
|
||||
const categories = await organization.listDuesCategories(acct.id);
|
||||
|
||||
return (
|
||||
<CmsPageShell
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
@@ -23,8 +23,8 @@ export default async function InvitationsPage({ params }: Props) {
|
||||
.single();
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const invitations = await api.listPortalInvitations(acct.id);
|
||||
const { workflow } = createMemberServices(client);
|
||||
const invitations = await workflow.listPortalInvitations(acct.id);
|
||||
|
||||
// Fetch members for the "send invitation" dialog
|
||||
const { data: members } = await client
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ReactNode } from 'react';
|
||||
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
@@ -25,8 +25,8 @@ export default async function MembersCmsLayout({ children, params }: Props) {
|
||||
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const stats = await api.getMemberQuickStats(acct.id);
|
||||
const { query } = createMemberServices(client);
|
||||
const stats = await query.getQuickStats(acct.id);
|
||||
|
||||
return (
|
||||
<MembersCmsLayoutClient
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { MemberCreateWizard } from '@kit/member-management/components';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
@@ -18,8 +18,8 @@ export default async function NewMemberPage({ params }: Props) {
|
||||
.single();
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const duesCategories = await api.listDuesCategories(acct.id);
|
||||
const { organization } = createMemberServices(client);
|
||||
const duesCategories = await organization.listDuesCategories(acct.id);
|
||||
|
||||
return (
|
||||
<MemberCreateWizard
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { MembersListView } from '@kit/member-management/components';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
@@ -23,7 +23,7 @@ export default async function MembersPage({ params, searchParams }: Props) {
|
||||
.single();
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const { query, organization } = createMemberServices(client);
|
||||
const page = Number(search.page) || 1;
|
||||
|
||||
// Parse multi-status filter
|
||||
@@ -34,7 +34,7 @@ export default async function MembersPage({ params, searchParams }: Props) {
|
||||
: statusParam.split(',')
|
||||
: undefined;
|
||||
|
||||
const result = await api.searchMembers({
|
||||
const result = await query.search({
|
||||
accountId: acct.id,
|
||||
search: search.q as string,
|
||||
status: statusFilter as any,
|
||||
@@ -45,10 +45,41 @@ export default async function MembersPage({ params, searchParams }: Props) {
|
||||
pageSize: PAGE_SIZE,
|
||||
});
|
||||
|
||||
const [duesCategories, departments] = await Promise.all([
|
||||
api.listDuesCategories(acct.id),
|
||||
api.listDepartmentsWithCounts(acct.id),
|
||||
]);
|
||||
// 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),
|
||||
),
|
||||
]);
|
||||
|
||||
// Build memberTags lookup: { memberId: [{ id, name, color }] }
|
||||
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;
|
||||
|
||||
if (!memberTags[memberId]) memberTags[memberId] = [];
|
||||
memberTags[memberId]!.push({
|
||||
id: String(tag.id),
|
||||
name: String(tag.name),
|
||||
color: String(tag.color),
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<MembersListView
|
||||
@@ -69,6 +100,12 @@ 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),
|
||||
}))}
|
||||
memberTags={memberTags}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
|
||||
|
||||
@@ -34,8 +34,8 @@ export default async function MemberStatisticsPage({ params }: PageProps) {
|
||||
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createMemberManagementApi(client);
|
||||
const stats = await api.getMemberStatistics(acct.id);
|
||||
const { query } = createMemberServices(client);
|
||||
const stats = await query.getStatistics(acct.id);
|
||||
|
||||
const statusChartData = [
|
||||
{ name: t('status.active'), value: stats.active ?? 0 },
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
import { TagsManager } from '@kit/member-management/components';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
import { CmsPageShell } from '~/components/cms-page-shell';
|
||||
|
||||
interface Props {
|
||||
params: Promise<{ account: string }>;
|
||||
}
|
||||
|
||||
export default async function TagsPage({ params }: Props) {
|
||||
const { account } = await params;
|
||||
const client = getSupabaseServerClient();
|
||||
const t = await getTranslations('members');
|
||||
|
||||
const { data: acct } = await client
|
||||
.from('accounts')
|
||||
.select('id')
|
||||
.eq('slug', account)
|
||||
.single();
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
// Fetch tags via direct query (table may not be in generated types yet)
|
||||
const { data: tags } = await (client.from as any)('member_tags')
|
||||
.select('*')
|
||||
.eq('account_id', acct.id)
|
||||
.order('sort_order');
|
||||
|
||||
return (
|
||||
<CmsPageShell
|
||||
account={account}
|
||||
title="Tags verwalten"
|
||||
description="Mitglieder-Tags erstellen und verwalten"
|
||||
>
|
||||
<TagsManager tags={tags ?? []} accountId={acct.id} />
|
||||
</CmsPageShell>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user