feat: add delete functionality for leases, catch books, and permits; implement newsletter update feature
Some checks failed
Workflow / ʦ TypeScript (push) Failing after 4m52s
Workflow / ⚫️ Test (push) Has been skipped

This commit is contained in:
T. Zehetbauer
2026-04-01 17:53:39 +02:00
parent c6b2824da8
commit 080ec1cb47
22 changed files with 798 additions and 210 deletions

View File

@@ -2,7 +2,10 @@ import type { SupabaseClient } from '@supabase/supabase-js';
import type { Database } from '@kit/supabase/database';
import type { CreateNewsletterInput } from '../schema/newsletter.schema';
import type {
CreateNewsletterInput,
UpdateNewsletterInput,
} from '../schema/newsletter.schema';
/* eslint-disable @typescript-eslint/no-explicit-any */
@@ -140,6 +143,26 @@ export function createNewsletterApi(client: SupabaseClient<Database>) {
return data;
},
async updateNewsletter(input: UpdateNewsletterInput) {
const update: Record<string, unknown> = {};
if (input.subject !== undefined) update.subject = input.subject;
if (input.bodyHtml !== undefined) update.body_html = input.bodyHtml;
if (input.bodyText !== undefined) update.body_text = input.bodyText;
if (input.templateId !== undefined)
update.template_id = input.templateId || null;
if (input.scheduledAt !== undefined)
update.scheduled_at = input.scheduledAt || null;
const { data, error } = await client
.from('newsletters')
.update(update)
.eq('id', input.newsletterId)
.select()
.single();
if (error) throw error;
return data;
},
async getNewsletter(newsletterId: string) {
const { data, error } = await client
.from('newsletters')