[FE-COMP-015] fix: Correct TypeScript errors in FollowButton

This commit is contained in:
senke 2025-12-25 12:01:57 +01:00
parent 6a65f3007a
commit 18be728c8d

View file

@ -16,7 +16,7 @@ interface FollowButtonProps {
initialFollowerCount?: number;
onFollowChange?: (isFollowing: boolean) => void;
className?: string;
size?: 'sm' | 'md' | 'lg';
size?: 'default' | 'sm' | 'lg' | 'icon';
variant?: 'default' | 'outline' | 'ghost';
}
@ -26,14 +26,13 @@ export function FollowButton({
initialFollowerCount = 0,
onFollowChange,
className,
size = 'md',
size = 'default',
variant,
}: FollowButtonProps) {
const { user } = useAuthStore();
const { success: showSuccess, error: showError } = useToast();
const queryClient = useQueryClient();
const [following, setFollowing] = useState(initialFollowing);
const [followerCount, setFollowerCount] = useState(initialFollowerCount);
const [isUpdating, setIsUpdating] = useState(false);
// Fetch profile to get current follow status
@ -53,15 +52,6 @@ export function FollowButton({
}
}, [profile, initialFollowing]);
// Update follower count from profile
useEffect(() => {
if (profile?.followers_count !== undefined) {
setFollowerCount(profile.followers_count);
} else if (initialFollowerCount !== undefined) {
setFollowerCount(initialFollowerCount);
}
}, [profile?.followers_count, initialFollowerCount]);
// Don't show follow button if viewing own profile
if (user?.id === userId) {
return null;
@ -82,7 +72,6 @@ export function FollowButton({
showSuccess('Vous ne suivez plus cet utilisateur');
}
setFollowing(newFollowing);
setFollowerCount((prev) => (newFollowing ? prev + 1 : prev - 1));
onFollowChange?.(newFollowing);
// Invalidate profile queries to refresh data
queryClient.invalidateQueries({ queryKey: ['userProfile', userId] });