bonuses: templates full-width list, drag-create modal, auto-evaluate, outstanding/completed states

This commit is contained in:
JCEEE
2026-07-30 15:27:03 +01:00
parent c55c090260
commit 8834281b4d
8 changed files with 524 additions and 676 deletions
@@ -95,24 +95,20 @@ export const actions = {
if (!event.locals.session) throw redirect(303, '/login');
const famId = event.locals.session.famId;
const fd = await event.request.formData();
const templateId = fd.get('templateId') as string;
const data: Record<string, unknown> = {
name: fd.get('name'),
description: fd.get('description') || '',
target: fd.get('target'),
type: fd.get('type'),
occurrence: fd.get('occurrence'),
rewardType: fd.get('rewardType'),
rewardValue: fd.get('rewardValue'),
criteriaValue: parseInt(fd.get('criteriaValue') as string, 10) || 0,
period: fd.get('period') || '',
memberId: fd.get('memberId') || '',
phase: 'active',
};
try {
const templates = await hono.admin.bonusConfigs(event, famId);
const tmpl = (Array.isArray(templates) ? templates : []).find((c: any) => c.id === templateId);
if (!tmpl) return fail(400, { error: 'Template not found' });
const data: Record<string, unknown> = {
name: tmpl.name,
description: tmpl.description || '',
target: tmpl.target,
type: tmpl.type,
occurrence: tmpl.occurrence,
rewardType: tmpl.rewardType,
rewardValue: tmpl.rewardValue,
criteriaValue: tmpl.criteriaValue || 0,
period: tmpl.period || '',
memberId: tmpl.memberId || '',
phase: 'ready',
};
const record = await hono.admin.create(event, 'bonus-configs', famId, data);
return { record };
} catch (e) {