feat: Implement Novu username and update functionality

This commit is contained in:
gpt-engineer-app[bot]
2025-10-01 14:01:44 +00:00
parent 268fa63ebc
commit 18669a4e6c
6 changed files with 110 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ import { useAuth } from '@/hooks/useAuth';
import { supabase } from '@/integrations/supabase/client';
import { User, Upload, Trash2 } from 'lucide-react';
import { PhotoUpload } from '@/components/upload/PhotoUpload';
import { notificationService } from '@/lib/notificationService';
const profileSchema = z.object({
username: z.string().min(3).max(30).regex(/^[a-zA-Z0-9_-]+$/),
@@ -54,6 +55,8 @@ export function AccountProfileTab() {
setLoading(true);
try {
const usernameChanged = profile?.username !== data.username;
const { error } = await supabase
.from('profiles')
.update({
@@ -69,6 +72,15 @@ export function AccountProfileTab() {
if (error) throw error;
// Update Novu subscriber if username changed
if (usernameChanged && notificationService.isEnabled()) {
await notificationService.updateSubscriber({
subscriberId: user.id,
email: user.email,
firstName: data.username, // Send username as firstName to Novu
});
}
await refreshProfile();
toast({
title: 'Profile updated',