import { useIonRouter } from '@ionic/react';
import { useEffect } from 'react';
import { LoadingScreen } from '../../../components/LoadingScreen';
import { useMyIonFavorite } from '../../../contexts/MyIonFavorite';

const FavVocabularyPage: React.FC = () => {
  let router = useIonRouter();
  let { myIonStoreLoadFavoriteVocabulary } = useMyIonFavorite();

  useEffect(() => {
    (async () => {
      let fav_list = await myIonStoreLoadFavoriteVocabulary();
      let fav_link = fav_list.length > 0 ? fav_list[0] : '';
      router.push(fav_link);
    })();
  }, []);

  return <LoadingScreen />;
};

export default FavVocabularyPage;
