import React, { useState, useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { fetchLinkedInAccounts, initiateLinkedInAuth, clearLinkedInError } from '../../store/reducers/linkedinAccountsSlice'; import LinkedInAccountCard from './LinkedInAccountCard'; const LinkedInAccountsManager = () => { const dispatch = useDispatch(); const { linkedinAccounts, loading, error, oauthLoading, oauthError } = useSelector(state => { console.log('🔍 [DEBUG] LinkedInAccountsManager - Redux state:', state); console.log('🔍 [DEBUG] LinkedInAccountsManager - linkedinAccounts state:', state.linkedinAccounts); return state.linkedinAccounts; }); const [showSuccess, setShowSuccess] = useState(false); useEffect(() => { console.log('🔍 [DEBUG] LinkedInAccountsManager - useEffect triggered'); console.log('🔍 [DEBUG] LinkedInAccountsManager - Current state:', { linkedinAccounts, loading, error }); dispatch(fetchLinkedInAccounts()); }, [dispatch]); useEffect(() => { if (showSuccess) { const timer = setTimeout(() => { setShowSuccess(false); }, 3000); return () => clearTimeout(timer); } }, [showSuccess]); const handleAddAccount = () => { dispatch(clearLinkedInError()); dispatch(initiateLinkedInAuth()); }; const handleRefreshAccounts = () => { dispatch(fetchLinkedInAccounts()); }; const handleAccountLinked = () => { setShowSuccess(true); handleRefreshAccounts(); }; return (
Manage your LinkedIn accounts for seamless content distribution
LinkedIn account linked successfully!
Failed to connect LinkedIn: {oauthError}
Error loading accounts: {error}
Loading LinkedIn accounts...
Connect your LinkedIn account to start posting content and managing your social media presence
Want to add another LinkedIn account?