diff --git a/api/_notifications.ts b/api/_notifications.ts new file mode 100644 index 00000000..bae5517a --- /dev/null +++ b/api/_notifications.ts @@ -0,0 +1,39 @@ +import { getAdminClient } from "./_supabase"; + +export async function createNotification( + userId: string, + type: string, + title: string, + message: string, +): Promise { + try { + const admin = getAdminClient(); + await admin.from("notifications").insert({ + user_id: userId, + type, + title, + message, + }); + } catch (error) { + console.warn("Failed to create notification:", error); + // Non-blocking - don't throw + } +} + +export async function notifyAccountLinked(userId: string, provider: string): Promise { + await createNotification( + userId, + "success", + `🔗 Account Linked: ${provider}`, + `Your ${provider} account has been successfully linked.`, + ); +} + +export async function notifyOnboardingComplete(userId: string): Promise { + await createNotification( + userId, + "success", + "🎉 Welcome to AeThex!", + "You've completed your profile setup. Let's get started!", + ); +}