Fix: Resolve TypeScript errors

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 02:28:57 +00:00
parent f6c409fac4
commit 9e8e8719b4
14 changed files with 48 additions and 30 deletions

View File

@@ -133,7 +133,7 @@ export function useEntityCache() {
const uncachedIds = getUncachedIds(type, ids);
if (uncachedIds.length === 0) {
// All entities are cached, return them
return ids.map(id => getCached(type, id)).filter(Boolean);
return ids.map(id => getCached(type, id)).filter((item): item is EntityTypeMap[T] => item !== undefined);
}
try {

View File

@@ -316,10 +316,12 @@ export function useModerationActions(config: ModerationActionsConfig): Moderatio
});
},
onSuccess: (data) => {
toast({
title: `Content ${data.action}`,
description: `The ${data.item.type} has been ${data.action}`,
});
if (data) {
toast({
title: `Content ${data.action}`,
description: `The ${data.item.type} has been ${data.action}`,
});
}
},
onSettled: () => {
// Always refetch to ensure consistency

View File

@@ -113,12 +113,21 @@ export function useProfileCache() {
// Cache the fetched profiles
if (data) {
data.forEach((profile: CachedProfile) => {
setCached(profile.user_id, profile);
data.forEach((profile) => {
const cachedProfile: CachedProfile = {
...profile,
display_name: profile.display_name || undefined,
avatar_url: profile.avatar_url || undefined
};
setCached(profile.user_id, cachedProfile);
});
}
return data || [];
return (data || []).map(profile => ({
...profile,
display_name: profile.display_name || undefined,
avatar_url: profile.avatar_url || undefined
}));
} catch (error: unknown) {
logger.error('Failed to bulk fetch profiles:', { error: getErrorMessage(error) });
return [];