From 5096118ef5ae00a68cff6c982006663dbd756bc7 Mon Sep 17 00:00:00 2001 From: NeilClack Date: Tue, 18 Aug 2026 13:38:05 -0500 Subject: [PATCH] Remove user proclamations page Users should not be able to view proclamations from the web portal. --- .../(user)/proclamations/+page.server.ts | 56 -------- .../(user)/proclamations/+page.svelte | 118 ----------------- .../(user)/proclamations/[id]/+page.server.ts | 27 ---- .../(user)/proclamations/[id]/+page.svelte | 53 -------- .../proclamations/[id]/page.server.spec.ts | 67 ---------- .../(user)/proclamations/page.server.spec.ts | 122 ------------------ 6 files changed, 443 deletions(-) delete mode 100644 src/routes/(protected)/(user)/proclamations/+page.server.ts delete mode 100644 src/routes/(protected)/(user)/proclamations/+page.svelte delete mode 100644 src/routes/(protected)/(user)/proclamations/[id]/+page.server.ts delete mode 100644 src/routes/(protected)/(user)/proclamations/[id]/+page.svelte delete mode 100644 src/routes/(protected)/(user)/proclamations/[id]/page.server.spec.ts delete mode 100644 src/routes/(protected)/(user)/proclamations/page.server.spec.ts diff --git a/src/routes/(protected)/(user)/proclamations/+page.server.ts b/src/routes/(protected)/(user)/proclamations/+page.server.ts deleted file mode 100644 index d4a5891..0000000 --- a/src/routes/(protected)/(user)/proclamations/+page.server.ts +++ /dev/null @@ -1,56 +0,0 @@ -import type { PageServerLoad } from './$types'; -import { prisma } from '$lib/db'; - -function getCategoryDisplayName(category: Record | null | undefined) { - if (!category) return ''; - const name = String(category.name ?? ''); - const parent = category.parent as Record | undefined; - if (parent?.name) return `${String(parent.name)}/${name}`; - return name; -} - -export const load: PageServerLoad = async ({ url }) => { - const search = url.searchParams.get('search') ?? ''; - const categoryId = url.searchParams.get('category'); - const where: Record = {}; - if (search) { - where.name = { contains: search, mode: 'insensitive' }; - } - if (categoryId) { - where.categoryId = parseInt(categoryId, 10); - } - - const [proclamations, categories] = await Promise.all([ - prisma.proclamation.findMany({ - where, - include: { - solfeggioFrequency: true, - category: { include: { parent: true } }, - subscriptionLevel: true - }, - orderBy: { name: 'asc' } - }), - prisma.proclamationCategory.findMany({ include: { parent: true }, orderBy: { name: 'asc' } }) - ]); - - const normalizedProclamations = proclamations.map((p) => { - if (p.category) { - (p.category as Record).displayName = getCategoryDisplayName( - p.category as Record - ); - } - return p; - }); - - const normalizedCategories = categories.map((c) => ({ - ...c, - displayName: getCategoryDisplayName(c) - })); - - return { - proclamations: normalizedProclamations, - categories: normalizedCategories, - search, - categoryId: categoryId ? parseInt(categoryId, 10) : null - }; -}; diff --git a/src/routes/(protected)/(user)/proclamations/+page.svelte b/src/routes/(protected)/(user)/proclamations/+page.svelte deleted file mode 100644 index 107210e..0000000 --- a/src/routes/(protected)/(user)/proclamations/+page.svelte +++ /dev/null @@ -1,118 +0,0 @@ - - -
-

Proclamations

- - -
-
- - e.key === 'Enter' && applyFilters()} - /> -
-
- - -
- - {#if data.search || data.categoryId} - - {/if} -
- - - {#if data.proclamations.length > 0} - - {:else} -
-

No proclamations found.

-
- {/if} -
diff --git a/src/routes/(protected)/(user)/proclamations/[id]/+page.server.ts b/src/routes/(protected)/(user)/proclamations/[id]/+page.server.ts deleted file mode 100644 index 87b8c3f..0000000 --- a/src/routes/(protected)/(user)/proclamations/[id]/+page.server.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { PageServerLoad } from './$types'; -import { error } from '@sveltejs/kit'; -import { prisma } from '$lib/db'; -import { canAccessAdmin } from '$lib/svelte-admin/roles'; - -export const load: PageServerLoad = async ({ params, parent }) => { - const parentData = typeof parent === 'function' ? await parent() : {}; - const userRoleId = (parentData as { userRoleId?: number }).userRoleId ?? null; - if (userRoleId != null && !canAccessAdmin(userRoleId)) { - throw error(403, 'not authorized'); - } - - const proclamation = await prisma.proclamation.findUnique({ - where: { id: params.id }, - include: { - solfeggioFrequency: true, - category: { include: { parent: true } }, - subscriptionLevel: true - } - }); - - if (!proclamation) { - throw error(404, 'Proclamation not found'); - } - - return { proclamation }; -}; diff --git a/src/routes/(protected)/(user)/proclamations/[id]/+page.svelte b/src/routes/(protected)/(user)/proclamations/[id]/+page.svelte deleted file mode 100644 index 71bdb74..0000000 --- a/src/routes/(protected)/(user)/proclamations/[id]/+page.svelte +++ /dev/null @@ -1,53 +0,0 @@ - - -
- - ← Back to Proclamations - - -
-

- {data.proclamation.name} -

-

{categoryBreadcrumb}

-
- -
-
-

Frequency

-

- {data.proclamation.solfeggioFrequency.value} Hz — - {data.proclamation.solfeggioFrequency.name} -

-
-
-

Level

-

- {data.proclamation.subscriptionLevel?.name ?? 'Standard'} -

-
-
- -
- {@html data.proclamation.content} -
-
diff --git a/src/routes/(protected)/(user)/proclamations/[id]/page.server.spec.ts b/src/routes/(protected)/(user)/proclamations/[id]/page.server.spec.ts deleted file mode 100644 index 5b0c232..0000000 --- a/src/routes/(protected)/(user)/proclamations/[id]/page.server.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { describe, it, expect, vi, beforeEach } from 'vitest'; -import { isHttpError } from '@sveltejs/kit'; -import { mockProclamation } from '$lib/test-utils'; - -vi.mock('$lib/db', () => ({ - prisma: { - proclamation: { findUnique: vi.fn() } - } -})); - -import { prisma } from '$lib/db'; -import { load } from './+page.server'; - -const findUnique = prisma.proclamation.findUnique as ReturnType; - -describe('(protected)/admin/proclamations/[id] page server load', () => { - beforeEach(() => { - findUnique.mockReset(); - }); - - it('throws 404 when proclamation is not found', async () => { - findUnique.mockResolvedValue(null); - - const err = await Promise.resolve(load({ params: { id: 'nonexistent' } } as any)).catch( - (e: unknown) => e - ); - expect(isHttpError(err, 404)).toBe(true); - }); - - it('returns proclamation when found', async () => { - const proclamation = mockProclamation(); - findUnique.mockResolvedValue(proclamation); - - const result = (await load({ params: { id: 'proc-1' } } as any)) as any; - expect(result.proclamation).toEqual(proclamation); - }); - - it('queries by params.id with frequency and category (including parent)', async () => { - findUnique.mockResolvedValue(mockProclamation()); - - await load({ params: { id: 'proc-1' } } as any); - - expect(findUnique).toHaveBeenCalledWith({ - where: { id: 'proc-1' }, - include: { - solfeggioFrequency: true, - category: { include: { parent: true } }, - subscriptionLevel: true - } - }); - }); - - it('returns proclamation with parent category when present', async () => { - const proclamation = mockProclamation({ - category: { - id: 2, - name: 'Inner Healing', - parentId: 1, - parent: { id: 1, name: 'Healing', parentId: null } - } - }); - findUnique.mockResolvedValue(proclamation); - - const result = (await load({ params: { id: 'proc-1' } } as any)) as any; - expect(result.proclamation.category.parent.name).toBe('Healing'); - }); -}); diff --git a/src/routes/(protected)/(user)/proclamations/page.server.spec.ts b/src/routes/(protected)/(user)/proclamations/page.server.spec.ts deleted file mode 100644 index cd17e95..0000000 --- a/src/routes/(protected)/(user)/proclamations/page.server.spec.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { describe, it, expect, vi, beforeEach } from 'vitest'; -import { mockProclamation, mockCategory, createUrl } from '$lib/test-utils'; - -vi.mock('$lib/db', () => ({ - prisma: { - proclamation: { findMany: vi.fn() }, - proclamationCategory: { findMany: vi.fn() } - } -})); - -import { prisma } from '$lib/db'; -import { load } from './+page.server'; - -const proclamationFindMany = prisma.proclamation.findMany as ReturnType; -const categoryFindMany = prisma.proclamationCategory.findMany as ReturnType; - -describe('(protected)/admin/proclamations page server load', () => { - beforeEach(() => { - proclamationFindMany.mockReset(); - categoryFindMany.mockReset(); - }); - - it('returns proclamations and categories with no filters', async () => { - const proclamations = [mockProclamation()]; - const categories = [mockCategory()]; - proclamationFindMany.mockResolvedValue(proclamations); - categoryFindMany.mockResolvedValue(categories); - - const url = createUrl('/admin/proclamations'); - const result = (await load({ url } as any)) as any; - expect(result.proclamations).toEqual(proclamations); - expect(result.categories[0]).toEqual( - expect.objectContaining({ - ...categories[0], - displayName: categories[0].name - }) - ); - expect(result.search).toBe(''); - expect(result.categoryId).toBeNull(); - }); - - it('passes search filter to findMany when search param is present', async () => { - proclamationFindMany.mockResolvedValue([]); - categoryFindMany.mockResolvedValue([]); - - const url = createUrl('/admin/proclamations', { search: 'healing' }); - await load({ url } as any); - - expect(proclamationFindMany).toHaveBeenCalledWith( - expect.objectContaining({ - where: { name: { contains: 'healing', mode: 'insensitive' } } - }) - ); - }); - - it('returns search string from URL params', async () => { - proclamationFindMany.mockResolvedValue([]); - categoryFindMany.mockResolvedValue([]); - - const url = createUrl('/admin/proclamations', { search: 'peace' }); - const result = (await load({ url } as any)) as any; - expect(result.search).toBe('peace'); - }); - - it('passes categoryId filter when category param is present', async () => { - proclamationFindMany.mockResolvedValue([]); - categoryFindMany.mockResolvedValue([]); - - const url = createUrl('/admin/proclamations', { category: '3' }); - await load({ url } as any); - - expect(proclamationFindMany).toHaveBeenCalledWith( - expect.objectContaining({ - where: { categoryId: 3 } - }) - ); - }); - - it('returns parsed categoryId from URL params', async () => { - proclamationFindMany.mockResolvedValue([]); - categoryFindMany.mockResolvedValue([]); - - const url = createUrl('/admin/proclamations', { category: '5' }); - const result = (await load({ url } as any)) as any; - expect(result.categoryId).toBe(5); - }); - - it('combines search and category filters', async () => { - proclamationFindMany.mockResolvedValue([]); - categoryFindMany.mockResolvedValue([]); - - const url = createUrl('/admin/proclamations', { search: 'love', category: '2' }); - await load({ url } as any); - - expect(proclamationFindMany).toHaveBeenCalledWith( - expect.objectContaining({ - where: { - name: { contains: 'love', mode: 'insensitive' }, - categoryId: 2 - } - }) - ); - }); - - it('includes solfeggioFrequency and category relations', async () => { - proclamationFindMany.mockResolvedValue([]); - categoryFindMany.mockResolvedValue([]); - - const url = createUrl('/admin/proclamations'); - await load({ url } as any); - - expect(proclamationFindMany).toHaveBeenCalledWith( - expect.objectContaining({ - include: { - solfeggioFrequency: true, - category: { include: { parent: true } }, - subscriptionLevel: true - } - }) - ); - }); -});