import { customJokeStub } from '../data/stub/CustomJokeStub';
import { sampleJokeStub } from '../data/stub/SampleJokeStub';
import JokeItems from "../components/JokeItems";
import '../types/extension';
import {StyleSheet, View} from "react-native";
import {purpleColor} from "../assets/Theme";
import {useDispatch, useSelector} from "react-redux";
import {useEffect} from "react";
import { getSampleJokesList } from "../redux/thunk/RecentsJokesThunk";

export default function Catalogue() {
    // @ts-ignore
    const allJokes = useSelector(state => state.appReducer.jokes);
    const dispatch = useDispatch();

    useEffect(() => {
        const loadJokes = async () => {
            // @ts-ignore
            await dispatch(getSampleJokesList());
        };
        loadJokes();
    }, [dispatch]);
    return (
        <View style={styles.container}>
            <JokeItems jokes={allJokes}/>
        </View>
    )
};

const styles = StyleSheet.create({
    container: {
        backgroundColor: purpleColor
    }
});