Add account hierarchy framework with migrations, RLS policies, and UI components
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
'use server';
|
||||
|
||||
import { z } from 'zod';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
import { authActionClient } from '@kit/next/safe-action';
|
||||
import { todayISO } from '@kit/shared/dates';
|
||||
import { getLogger } from '@kit/shared/logger';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
@@ -18,7 +21,6 @@ import {
|
||||
CreateClubNoteSchema,
|
||||
CreateAssociationHistorySchema,
|
||||
} from '../../schema/verband.schema';
|
||||
|
||||
import { createVerbandApi } from '../api';
|
||||
|
||||
const REVALIDATE_PATH = '/home/[account]/verband';
|
||||
@@ -195,7 +197,10 @@ export const createAssociationType = authActionClient
|
||||
const logger = await getLogger();
|
||||
const api = createVerbandApi(client);
|
||||
|
||||
logger.info({ name: 'verband.type.create' }, 'Creating association type...');
|
||||
logger.info(
|
||||
{ name: 'verband.type.create' },
|
||||
'Creating association type...',
|
||||
);
|
||||
const result = await api.createType(input);
|
||||
logger.info({ name: 'verband.type.create' }, 'Association type created');
|
||||
revalidatePath(REVALIDATE_PATH, 'page');
|
||||
@@ -217,7 +222,10 @@ export const updateAssociationType = authActionClient
|
||||
const api = createVerbandApi(client);
|
||||
|
||||
const { typeId, ...updates } = input;
|
||||
logger.info({ name: 'verband.type.update' }, 'Updating association type...');
|
||||
logger.info(
|
||||
{ name: 'verband.type.update' },
|
||||
'Updating association type...',
|
||||
);
|
||||
const result = await api.updateType(typeId, updates);
|
||||
logger.info({ name: 'verband.type.update' }, 'Association type updated');
|
||||
revalidatePath(REVALIDATE_PATH, 'page');
|
||||
@@ -235,7 +243,10 @@ export const deleteAssociationType = authActionClient
|
||||
const logger = await getLogger();
|
||||
const api = createVerbandApi(client);
|
||||
|
||||
logger.info({ name: 'verband.type.delete' }, 'Deleting association type...');
|
||||
logger.info(
|
||||
{ name: 'verband.type.delete' },
|
||||
'Deleting association type...',
|
||||
);
|
||||
await api.deleteType(input.typeId);
|
||||
logger.info({ name: 'verband.type.delete' }, 'Association type deleted');
|
||||
revalidatePath(REVALIDATE_PATH, 'page');
|
||||
@@ -369,11 +380,19 @@ export const markBillingPaid = authActionClient
|
||||
const logger = await getLogger();
|
||||
const api = createVerbandApi(client);
|
||||
|
||||
logger.info({ name: 'verband.billing.markPaid' }, 'Marking billing as paid...');
|
||||
logger.info(
|
||||
{ name: 'verband.billing.markPaid' },
|
||||
'Marking billing as paid...',
|
||||
);
|
||||
const result = await api.updateFeeBilling(input.billingId, {
|
||||
status: 'bezahlt',
|
||||
paidDate: input.paidDate ?? new Date().toISOString().split('T')[0],
|
||||
paymentMethod: input.paymentMethod as 'bar' | 'lastschrift' | 'ueberweisung' | 'paypal' | undefined,
|
||||
paidDate: input.paidDate ?? todayISO(),
|
||||
paymentMethod: input.paymentMethod as
|
||||
| 'bar'
|
||||
| 'lastschrift'
|
||||
| 'ueberweisung'
|
||||
| 'paypal'
|
||||
| undefined,
|
||||
});
|
||||
logger.info({ name: 'verband.billing.markPaid' }, 'Billing marked as paid');
|
||||
revalidatePath(REVALIDATE_PATH, 'page');
|
||||
@@ -464,9 +483,15 @@ export const upsertAssociationHistory = authActionClient
|
||||
const logger = await getLogger();
|
||||
const api = createVerbandApi(client);
|
||||
|
||||
logger.info({ name: 'verband.history.upsert' }, 'Upserting association history...');
|
||||
logger.info(
|
||||
{ name: 'verband.history.upsert' },
|
||||
'Upserting association history...',
|
||||
);
|
||||
const result = await api.upsertHistory(input);
|
||||
logger.info({ name: 'verband.history.upsert' }, 'Association history upserted');
|
||||
logger.info(
|
||||
{ name: 'verband.history.upsert' },
|
||||
'Association history upserted',
|
||||
);
|
||||
revalidatePath(REVALIDATE_PATH, 'page');
|
||||
return { success: true, data: result };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user