mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 12:51:16 -05:00
Fix: Resolve privacy settings type errors
This commit is contained in:
@@ -114,7 +114,7 @@ export function BlockedUsers() {
|
||||
}
|
||||
|
||||
// Log to audit trail
|
||||
await supabase.from('profile_audit_log').insert({
|
||||
await supabase.from('profile_audit_log').insert([{
|
||||
user_id: user.id,
|
||||
changed_by: user.id,
|
||||
action: 'user_unblocked',
|
||||
@@ -122,8 +122,8 @@ export function BlockedUsers() {
|
||||
blocked_user_id: blockedUserId,
|
||||
username,
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
});
|
||||
} as any
|
||||
}]);
|
||||
|
||||
setBlockedUsers(prev => prev.filter(block => block.id !== blockId));
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
@@ -24,8 +25,11 @@ export function PrivacyTab() {
|
||||
const [preferences, setPreferences] = useState<PrivacySettings | null>(null);
|
||||
|
||||
const form = useForm<PrivacyFormData>({
|
||||
resolver: zodResolver(privacyFormSchema),
|
||||
defaultValues: {
|
||||
privacy_level: profile?.privacy_level || 'public',
|
||||
privacy_level: (profile?.privacy_level === 'public' || profile?.privacy_level === 'private')
|
||||
? profile.privacy_level
|
||||
: 'public',
|
||||
show_pronouns: profile?.show_pronouns || false,
|
||||
...DEFAULT_PRIVACY_SETTINGS
|
||||
}
|
||||
@@ -61,7 +65,9 @@ export function PrivacyTab() {
|
||||
setPreferences(validatedSettings);
|
||||
|
||||
form.reset({
|
||||
privacy_level: profile?.privacy_level || 'public',
|
||||
privacy_level: (profile?.privacy_level === 'public' || profile?.privacy_level === 'private')
|
||||
? profile.privacy_level
|
||||
: 'public',
|
||||
show_pronouns: profile?.show_pronouns || false,
|
||||
...validatedSettings
|
||||
});
|
||||
@@ -105,7 +111,9 @@ export function PrivacyTab() {
|
||||
|
||||
setPreferences(DEFAULT_PRIVACY_SETTINGS);
|
||||
form.reset({
|
||||
privacy_level: profile?.privacy_level || 'public',
|
||||
privacy_level: (profile?.privacy_level === 'public' || profile?.privacy_level === 'private')
|
||||
? profile.privacy_level
|
||||
: 'public',
|
||||
show_pronouns: profile?.show_pronouns || false,
|
||||
...DEFAULT_PRIVACY_SETTINGS
|
||||
});
|
||||
@@ -175,7 +183,7 @@ export function PrivacyTab() {
|
||||
}
|
||||
|
||||
// Log to audit trail
|
||||
await supabase.from('profile_audit_log').insert({
|
||||
await supabase.from('profile_audit_log').insert([{
|
||||
user_id: user.id,
|
||||
changed_by: user.id,
|
||||
action: 'privacy_settings_updated',
|
||||
@@ -183,8 +191,8 @@ export function PrivacyTab() {
|
||||
previous: preferences,
|
||||
updated: privacySettings,
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
});
|
||||
} as any
|
||||
}]);
|
||||
|
||||
await refreshProfile();
|
||||
setPreferences(privacySettings);
|
||||
@@ -210,7 +218,7 @@ export function PrivacyTab() {
|
||||
new AppError(
|
||||
'Invalid privacy settings',
|
||||
'VALIDATION_ERROR',
|
||||
error.errors.map(e => e.message).join(', ')
|
||||
error.issues.map(e => e.message).join(', ')
|
||||
),
|
||||
{ action: 'Validate privacy settings', userId: user.id }
|
||||
);
|
||||
|
||||
@@ -20,9 +20,7 @@ import { z } from 'zod';
|
||||
* Schema for privacy settings in user_preferences
|
||||
*/
|
||||
export const privacySettingsSchema = z.object({
|
||||
activity_visibility: z.enum(['public', 'private'], {
|
||||
errorMap: () => ({ message: 'Activity visibility must be public or private' })
|
||||
}),
|
||||
activity_visibility: z.enum(['public', 'private'] as const),
|
||||
search_visibility: z.boolean(),
|
||||
show_location: z.boolean(),
|
||||
show_age: z.boolean(),
|
||||
@@ -36,9 +34,7 @@ export const privacySettingsSchema = z.object({
|
||||
* Schema for profile privacy settings
|
||||
*/
|
||||
export const profilePrivacySchema = z.object({
|
||||
privacy_level: z.enum(['public', 'private'], {
|
||||
errorMap: () => ({ message: 'Privacy level must be public or private' })
|
||||
}),
|
||||
privacy_level: z.enum(['public', 'private'] as const),
|
||||
show_pronouns: z.boolean()
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user