mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 17:31:13 -05:00
Fix: Type safety and unit validation
This commit is contained in:
@@ -356,7 +356,12 @@ export async function performModerationAction(
|
||||
|
||||
// Use type-safe table queries based on item type
|
||||
if (item.type === 'review') {
|
||||
const reviewUpdate = {
|
||||
const reviewUpdate: {
|
||||
moderation_status: 'approved' | 'rejected' | 'pending';
|
||||
moderated_at: string;
|
||||
moderated_by: string;
|
||||
reviewer_notes?: string;
|
||||
} = {
|
||||
moderation_status: action,
|
||||
moderated_at: new Date().toISOString(),
|
||||
moderated_by: moderatorId,
|
||||
@@ -364,13 +369,18 @@ export async function performModerationAction(
|
||||
};
|
||||
|
||||
const result = await createTableQuery('reviews')
|
||||
.update(reviewUpdate as any) // Type assertion needed for dynamic update
|
||||
.update(reviewUpdate)
|
||||
.eq('id', item.id)
|
||||
.select();
|
||||
error = result.error;
|
||||
data = result.data;
|
||||
} else {
|
||||
const submissionUpdate = {
|
||||
const submissionUpdate: {
|
||||
status: 'approved' | 'rejected' | 'pending';
|
||||
reviewed_at: string;
|
||||
reviewer_id: string;
|
||||
reviewer_notes?: string;
|
||||
} = {
|
||||
status: action,
|
||||
reviewed_at: new Date().toISOString(),
|
||||
reviewer_id: moderatorId,
|
||||
@@ -378,7 +388,7 @@ export async function performModerationAction(
|
||||
};
|
||||
|
||||
const result = await createTableQuery('content_submissions')
|
||||
.update(submissionUpdate as any) // Type assertion needed for dynamic update
|
||||
.update(submissionUpdate)
|
||||
.eq('id', item.id)
|
||||
.select();
|
||||
error = result.error;
|
||||
|
||||
@@ -249,7 +249,7 @@ class NotificationService {
|
||||
previous: previousPrefs || null,
|
||||
updated: validated,
|
||||
timestamp: new Date().toISOString()
|
||||
} as any
|
||||
}
|
||||
}]);
|
||||
|
||||
logger.info('Notification preferences updated', {
|
||||
|
||||
@@ -107,8 +107,8 @@ interface RequestMetadata {
|
||||
}
|
||||
|
||||
async function logRequestMetadata(metadata: RequestMetadata): Promise<void> {
|
||||
// Type assertion needed until Supabase types regenerate after migration
|
||||
const { error } = await supabase.rpc('log_request_metadata' as any, {
|
||||
// Safe cast - RPC function exists in database
|
||||
const { error } = await supabase.rpc('log_request_metadata' as 'log_request_metadata', {
|
||||
p_request_id: metadata.requestId,
|
||||
p_user_id: metadata.userId || null,
|
||||
p_endpoint: metadata.endpoint,
|
||||
|
||||
@@ -556,8 +556,8 @@ export function extractChangedFields<T extends Record<string, any>>(
|
||||
// ═══ SPECIAL HANDLING: LOCATION OBJECTS ═══
|
||||
// Location can be an object (from form) vs location_id (from DB)
|
||||
if (key === 'location' && newValue && typeof newValue === 'object') {
|
||||
const oldLoc = originalData.location as any;
|
||||
if (!oldLoc || !isEqual(oldLoc, newValue)) {
|
||||
const oldLoc = originalData.location;
|
||||
if (!oldLoc || typeof oldLoc !== 'object' || !isEqual(oldLoc, newValue)) {
|
||||
changes[key as keyof T] = newValue;
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user