feat: add delete functionality for leases, catch books, and permits; implement newsletter update feature
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user