8c41b33313
Features implemented across 6 batches: - Batch A: Fix ColorPicker gradient sync, tenant custom logo, unarchive cards, board backgrounds - Batch B: My Work view, card copy/duplicate, card numbering (BOARD-123) - Batch C: Due date reminders (cron), card watching with notifications - Batch D: Bulk card operations, column sorting, calendar view - Batch E: Invite by link, board import/export (Pounce + Trello JSON) - Batch F: Webhooks with HMAC signing, custom fields, automation rules engine Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
819 B
TypeScript
33 lines
819 B
TypeScript
import { error } from '@sveltejs/kit';
|
|
import type { PageServerLoad } from './$types.js';
|
|
import { prisma } from '$lib/server/db.js';
|
|
|
|
export const load: PageServerLoad = async ({ params, locals }) => {
|
|
const invite = await prisma.tenantInvite.findUnique({
|
|
where: { code: params.code },
|
|
include: {
|
|
tenant: { select: { name: true } }
|
|
}
|
|
});
|
|
|
|
if (!invite) throw error(404, 'Invite not found');
|
|
|
|
if (invite.expiresAt < new Date()) {
|
|
throw error(410, 'This invite has expired');
|
|
}
|
|
|
|
if (invite.maxUses !== null && invite.usedCount >= invite.maxUses) {
|
|
throw error(410, 'This invite has reached its maximum number of uses');
|
|
}
|
|
|
|
return {
|
|
invite: {
|
|
code: invite.code,
|
|
role: invite.role,
|
|
tenantName: invite.tenant.name,
|
|
expiresAt: invite.expiresAt.toISOString()
|
|
},
|
|
user: locals.user
|
|
};
|
|
};
|