mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 12:11:12 -05:00
feat: Implement final type safety fixes
This commit is contained in:
@@ -6,6 +6,11 @@
|
||||
|
||||
import type { ModerationItem, EntityFilter, StatusFilter } from '@/types/moderation';
|
||||
|
||||
interface SubmissionContent {
|
||||
name?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a submission matches the entity filter
|
||||
*/
|
||||
@@ -167,7 +172,7 @@ export function buildModerationItem(
|
||||
display_name: profile.display_name,
|
||||
avatar_url: profile.avatar_url,
|
||||
} : undefined,
|
||||
entity_name: entityName || (submission.content as any)?.name || 'Unknown',
|
||||
entity_name: entityName || (submission.content as SubmissionContent)?.name || 'Unknown',
|
||||
park_name: parkName,
|
||||
reviewed_at: submission.reviewed_at || undefined,
|
||||
reviewer_notes: submission.reviewer_notes || undefined,
|
||||
|
||||
@@ -609,8 +609,16 @@ async function createCompany(
|
||||
// Extract image assignments
|
||||
const imageData = extractImageAssignments(resolvedData.images);
|
||||
|
||||
// Type guard for company type
|
||||
type ValidCompanyType = 'manufacturer' | 'designer' | 'operator' | 'property_owner';
|
||||
const validCompanyTypes: ValidCompanyType[] = ['manufacturer', 'designer', 'operator', 'property_owner'];
|
||||
|
||||
if (!validCompanyTypes.includes(companyType as ValidCompanyType)) {
|
||||
throw new Error(`Invalid company type: ${companyType}`);
|
||||
}
|
||||
|
||||
// Transform to database format
|
||||
const companyData = { ...transformCompanyData(resolvedData, companyType as any), ...imageData };
|
||||
const companyData = { ...transformCompanyData(resolvedData, companyType as ValidCompanyType), ...imageData };
|
||||
|
||||
const { data: company, error } = await supabase
|
||||
.from('companies')
|
||||
@@ -1062,12 +1070,18 @@ export async function editSubmissionItem(
|
||||
}
|
||||
}
|
||||
|
||||
// Type guard for submission with user_id
|
||||
interface SubmissionWithUser {
|
||||
user_id: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// Log admin action
|
||||
await supabase
|
||||
.from('admin_audit_log')
|
||||
.insert({
|
||||
admin_user_id: userId,
|
||||
target_user_id: (currentItem.submission as any).user_id,
|
||||
target_user_id: (currentItem.submission as SubmissionWithUser).user_id,
|
||||
action: 'edit_submission_item',
|
||||
details: {
|
||||
item_id: itemId,
|
||||
|
||||
Reference in New Issue
Block a user