/* eslint-disable no-nested-ternary */
import React, { useContext, useState, useEffect } from 'react';
import Fuse from 'fuse.js';
import { FirebaseContext } from '../context/firebase';
import { SelectProfileContainer } from './profiles';
import { Card, Header, Loading } from '../components';
import * as ROUTES from '../constants/routes';
import logo from '../logo.svg';
import { FooterContainer } from './footer';
import Player from '../components/player';
export function BrowseContainer({ slides }) {
const [category, setCategory] = useState('series');
const [searchTerm, setSearchTerm] = useState('');
const [profile, setProfile] = useState({});
const [loading, setLoading] = useState(true);
const [slideRows, setSlideRows] = useState([]);
const { firebase } = useContext(FirebaseContext);
const user = firebase.auth().currentUser || {};
useEffect(() => {
setTimeout(() => {
setLoading(false);
}, 3000);
}, [profile.displayName]);
useEffect(() => {
setSlideRows(slides[category]);
}, [slides, category]);
useEffect(() => {
const fuse = new Fuse(slideRows,
{ keys: ['data.description', 'data,title', 'data.genre'], });
const results = fuse.search(searchTerm).map(({ item }) => item);
if(slideRows.length > 0 && searchTerm.length > 3
&& results.length > 0 ) {
setSlideRows(results);
} else {
setSlideRows(slides[category]);
}
}, [searchTerm]);
return profile.displayName ? (
<>
{loading ?
: }
{user.displayName}
firebase.auth().signOut()}>Sign out
{/*
setCategory('series')}>Series
setCategory('films')}>Films
{user.displayName}
firebase.auth().signOut()}>Sign out
Watch Joker Now
Forever alone in a crowd, failed comedian Arthur Fleck seeks connection as he walks the streets of Gotham
City. Arthur wears two masks -- the one he paints for his day job as a clown, and the guise he projects in a
futile attempt to feel like he's part of the world around him.
Play
*/}
{/*
{slideRows.map((slideItem) => (
{slideItem.title}
{slideItem.data.map((item) => (
{item.title}
{item.description}
))}
))}
*/}
{/* */}
>
) : (
);
}
//new timestamp 7:53:08, need to work on Player test and overall performance