refactor: remove obsolete member management API module
This commit is contained in:
@@ -82,7 +82,7 @@ export default async function BookingCalendarPage({ params }: PageProps) {
|
||||
const monthStart = `${year}-${String(month + 1).padStart(2, '0')}-01`;
|
||||
const monthEnd = `${year}-${String(month + 1).padStart(2, '0')}-${String(daysInMonth).padStart(2, '0')}`;
|
||||
|
||||
const bookings = await api.listBookings(acct.id, {
|
||||
const bookings = await api.bookings.list(acct.id, {
|
||||
from: monthStart,
|
||||
to: monthEnd,
|
||||
page: 1,
|
||||
|
||||
@@ -34,7 +34,7 @@ export default async function GuestsPage({ params }: PageProps) {
|
||||
}
|
||||
|
||||
const api = createBookingManagementApi(client);
|
||||
const guests = await api.listGuests(acct.id);
|
||||
const guests = await api.guests.list(acct.id);
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title={t('guests.title')}>
|
||||
|
||||
@@ -29,7 +29,7 @@ export default async function NewBookingPage({ params }: Props) {
|
||||
}
|
||||
|
||||
const api = createBookingManagementApi(client);
|
||||
const rooms = await api.listRooms(acct.id);
|
||||
const rooms = await api.rooms.list(acct.id);
|
||||
|
||||
return (
|
||||
<CmsPageShell
|
||||
|
||||
@@ -54,7 +54,7 @@ export default async function BookingsPage({
|
||||
const page = Number(search.page) || 1;
|
||||
|
||||
const api = createBookingManagementApi(client);
|
||||
const rooms = await api.listRooms(acct.id);
|
||||
const rooms = await api.rooms.list(acct.id);
|
||||
|
||||
// Fetch bookings with joined room & guest names (avoids displaying raw UUIDs)
|
||||
const bookingsQuery = client
|
||||
|
||||
@@ -36,7 +36,7 @@ export default async function RoomsPage({ params }: PageProps) {
|
||||
}
|
||||
|
||||
const api = createBookingManagementApi(client);
|
||||
const rooms = await api.listRooms(acct.id);
|
||||
const rooms = await api.rooms.list(acct.id);
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title={t('rooms.title')}>
|
||||
|
||||
@@ -29,9 +29,9 @@ export default async function AttendancePage({
|
||||
const t = await getTranslations('courses');
|
||||
|
||||
const [course, sessions, participants] = await Promise.all([
|
||||
api.getCourse(courseId),
|
||||
api.getSessions(courseId),
|
||||
api.getParticipants(courseId),
|
||||
api.courses.getById(courseId),
|
||||
api.sessions.list(courseId),
|
||||
api.enrollment.listParticipants(courseId),
|
||||
]);
|
||||
|
||||
if (!course) return <AccountNotFound />;
|
||||
@@ -43,7 +43,7 @@ export default async function AttendancePage({
|
||||
: null);
|
||||
|
||||
const attendance = selectedSessionId
|
||||
? await api.getAttendance(selectedSessionId)
|
||||
? await api.attendance.getBySession(selectedSessionId)
|
||||
: [];
|
||||
|
||||
const attendanceMap = new Map(
|
||||
|
||||
@@ -25,7 +25,7 @@ export default async function EditCoursePage({ params }: PageProps) {
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createCourseManagementApi(client);
|
||||
const course = await api.getCourse(courseId);
|
||||
const course = await api.courses.getById(courseId);
|
||||
if (!course) return <AccountNotFound />;
|
||||
|
||||
const c = course as Record<string, unknown>;
|
||||
|
||||
@@ -39,9 +39,9 @@ export default async function CourseDetailPage({ params }: PageProps) {
|
||||
const t = await getTranslations('courses');
|
||||
|
||||
const [course, participants, sessions] = await Promise.all([
|
||||
api.getCourse(courseId),
|
||||
api.getParticipants(courseId),
|
||||
api.getSessions(courseId),
|
||||
api.courses.getById(courseId),
|
||||
api.enrollment.listParticipants(courseId),
|
||||
api.sessions.list(courseId),
|
||||
]);
|
||||
|
||||
if (!course) return <AccountNotFound />;
|
||||
|
||||
@@ -40,8 +40,8 @@ export default async function ParticipantsPage({ params }: PageProps) {
|
||||
const t = await getTranslations('courses');
|
||||
|
||||
const [course, participants] = await Promise.all([
|
||||
api.getCourse(courseId),
|
||||
api.getParticipants(courseId),
|
||||
api.courses.getById(courseId),
|
||||
api.enrollment.listParticipants(courseId),
|
||||
]);
|
||||
|
||||
if (!course) return <AccountNotFound />;
|
||||
|
||||
@@ -45,7 +45,7 @@ export default async function CourseCalendarPage({
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createCourseManagementApi(client);
|
||||
const courses = await api.listCourses(acct.id, { page: 1, pageSize: 100 });
|
||||
const courses = await api.courses.list(acct.id, { page: 1, pageSize: 100 });
|
||||
|
||||
const now = new Date();
|
||||
const monthParam = search.month as string | undefined;
|
||||
|
||||
@@ -29,7 +29,7 @@ export default async function CategoriesPage({ params }: PageProps) {
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createCourseManagementApi(client);
|
||||
const categories = await api.listCategories(acct.id);
|
||||
const categories = await api.referenceData.listCategories(acct.id);
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title={t('pages.categoriesTitle')}>
|
||||
|
||||
@@ -30,7 +30,7 @@ export default async function InstructorsPage({ params }: PageProps) {
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createCourseManagementApi(client);
|
||||
const instructors = await api.listInstructors(acct.id);
|
||||
const instructors = await api.referenceData.listInstructors(acct.id);
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title={t('pages.instructorsTitle')}>
|
||||
|
||||
@@ -29,7 +29,7 @@ export default async function LocationsPage({ params }: PageProps) {
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createCourseManagementApi(client);
|
||||
const locations = await api.listLocations(acct.id);
|
||||
const locations = await api.referenceData.listLocations(acct.id);
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title={t('pages.locationsTitle')}>
|
||||
|
||||
@@ -52,13 +52,13 @@ export default async function CoursesPage({ params, searchParams }: PageProps) {
|
||||
const page = Number(search.page) || 1;
|
||||
|
||||
const [courses, stats] = await Promise.all([
|
||||
api.listCourses(acct.id, {
|
||||
api.courses.list(acct.id, {
|
||||
search: search.q as string,
|
||||
status: search.status as string,
|
||||
page,
|
||||
pageSize: PAGE_SIZE,
|
||||
}),
|
||||
api.getStatistics(acct.id),
|
||||
api.statistics.getQuickStats(acct.id),
|
||||
]);
|
||||
|
||||
const totalPages = Math.ceil(courses.total / PAGE_SIZE);
|
||||
|
||||
@@ -33,7 +33,7 @@ export default async function CourseStatisticsPage({ params }: PageProps) {
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createCourseManagementApi(client);
|
||||
const stats = await api.getStatistics(acct.id);
|
||||
const stats = await api.statistics.getQuickStats(acct.id);
|
||||
|
||||
const statusChartData = [
|
||||
{ name: t('stats.active'), value: stats.openCourses },
|
||||
|
||||
@@ -25,7 +25,7 @@ export default async function EditEventPage({ params }: PageProps) {
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createEventManagementApi(client);
|
||||
const event = await api.getEvent(eventId);
|
||||
const event = await api.events.getById(eventId);
|
||||
if (!event) return <AccountNotFound />;
|
||||
|
||||
const e = event as Record<string, unknown>;
|
||||
|
||||
@@ -36,8 +36,8 @@ export default async function EventDetailPage({ params }: PageProps) {
|
||||
const t = await getTranslations('cms.events');
|
||||
|
||||
const [event, registrations] = await Promise.all([
|
||||
api.getEvent(eventId),
|
||||
api.getRegistrations(eventId),
|
||||
api.events.getById(eventId),
|
||||
api.registrations.list(eventId),
|
||||
]);
|
||||
|
||||
if (!event) return <div>{t('notFound')}</div>;
|
||||
|
||||
@@ -29,7 +29,7 @@ export default async function HolidayPassesPage({ params }: PageProps) {
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createEventManagementApi(client);
|
||||
const passes = await api.listHolidayPasses(acct.id);
|
||||
const passes = await api.holidayPasses.list(acct.id);
|
||||
|
||||
return (
|
||||
<CmsPageShell account={account} title={t('holidayPasses')}>
|
||||
|
||||
@@ -47,13 +47,13 @@ export default async function EventsPage({ params, searchParams }: PageProps) {
|
||||
|
||||
const page = Number(search.page) || 1;
|
||||
const api = createEventManagementApi(client);
|
||||
const events = await api.listEvents(acct.id, { page });
|
||||
const events = await api.events.list(acct.id, { page });
|
||||
|
||||
// Fetch registration counts for all events on this page
|
||||
const eventIds = events.data.map((eventItem: Record<string, unknown>) =>
|
||||
String(eventItem.id),
|
||||
);
|
||||
const registrationCounts = await api.getRegistrationCounts(eventIds);
|
||||
const registrationCounts = await api.events.getRegistrationCounts(eventIds);
|
||||
|
||||
// Pre-compute stats before rendering
|
||||
const uniqueLocationCount = new Set(
|
||||
|
||||
@@ -36,12 +36,12 @@ export default async function EventRegistrationsPage({ params }: PageProps) {
|
||||
if (!acct) return <AccountNotFound />;
|
||||
|
||||
const api = createEventManagementApi(client);
|
||||
const events = await api.listEvents(acct.id, { page: 1 });
|
||||
const events = await api.events.list(acct.id, { page: 1 });
|
||||
|
||||
// Load registrations for each event in parallel
|
||||
const eventsWithRegistrations = await Promise.all(
|
||||
events.data.map(async (event: Record<string, unknown>) => {
|
||||
const registrations = await api.getRegistrations(String(event.id));
|
||||
const registrations = await api.registrations.list(String(event.id));
|
||||
return {
|
||||
id: String(event.id),
|
||||
name: String(event.name),
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import { createBookingManagementApi } from '@kit/booking-management/api';
|
||||
import { createCourseManagementApi } from '@kit/course-management/api';
|
||||
import { createEventManagementApi } from '@kit/event-management/api';
|
||||
import { createFinanceApi } from '@kit/finance/api';
|
||||
import { createMemberManagementApi } from '@kit/member-management/api';
|
||||
import { createMemberServices } from '@kit/member-management/services';
|
||||
import { createNewsletterApi } from '@kit/newsletter/api';
|
||||
import { formatDate } from '@kit/shared/dates';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
@@ -64,18 +64,23 @@ export default async function TeamAccountHomePage({
|
||||
bookingsResult,
|
||||
eventsResult,
|
||||
] = await Promise.allSettled([
|
||||
createMemberManagementApi(client).getMemberStatistics(acct.id),
|
||||
createCourseManagementApi(client).getStatistics(acct.id),
|
||||
createMemberServices(client).query.getStatistics(acct.id),
|
||||
createCourseManagementApi(client).statistics.getQuickStats(acct.id),
|
||||
createFinanceApi(client).listInvoices(acct.id, { status: 'draft' }),
|
||||
createNewsletterApi(client).listNewsletters(acct.id),
|
||||
createBookingManagementApi(client).listBookings(acct.id, { page: 1 }),
|
||||
createEventManagementApi(client).listEvents(acct.id, { page: 1 }),
|
||||
createBookingManagementApi(client).bookings.list(acct.id, { page: 1 }),
|
||||
createEventManagementApi(client).events.list(acct.id, { page: 1 }),
|
||||
]);
|
||||
|
||||
const memberStats =
|
||||
memberStatsResult.status === 'fulfilled'
|
||||
? memberStatsResult.value
|
||||
: { total: 0, active: 0, inactive: 0, pending: 0, resigned: 0 };
|
||||
const memberStatsRaw =
|
||||
memberStatsResult.status === 'fulfilled' ? memberStatsResult.value : {};
|
||||
const memberStats = {
|
||||
total: Object.values(memberStatsRaw).reduce((a, b) => a + b, 0),
|
||||
active: memberStatsRaw.active ?? 0,
|
||||
inactive: memberStatsRaw.inactive ?? 0,
|
||||
pending: memberStatsRaw.pending ?? 0,
|
||||
resigned: memberStatsRaw.resigned ?? 0,
|
||||
};
|
||||
|
||||
const courseStats =
|
||||
courseStatsResult.status === 'fulfilled'
|
||||
|
||||
Reference in New Issue
Block a user