mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:11:11 -05:00
feat: Implement Novu username and update functionality
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user