Merge pull request '🔥 Remove code' (#8) from part6 into master

Reviewed-on: #8
master
Antoine PEREDERII 1 year ago
commit 5bd99267bd

@ -4,12 +4,9 @@ import {CustomJoke} from "../../model/CustomJoke";
import {setCustomJokeById} from "../actions/CustomJoke";
export const getItem = <TItem>(uri:string, constructor : (json:any) => TItem, setItem: (item: TItem) => any) => {
//In order to use await your callback must be asynchronous using async keyword.
return async dispatch => {
//Then perform your asynchronous operations.
try {
const promise = await fetch(uri);
//Then use the json method to get json data from api/
const Json = await promise.json();
const Item: TItem = constructor(Json);
dispatch(setItem(Item));

@ -6,12 +6,9 @@ import {CustomJoke} from "../../model/CustomJoke";
import {setCustomJokesList} from "../actions/CustomJoke";
export const getList = <TList>(uri:string, constructor : (json:any) => TList, setList: (list: TList[]) => any) => {
//In order to use await your callback must be asynchronous using async keyword.
return async dispatch => {
//Then perform your asynchronous operations.
try {
const promise = await fetch(uri);
//Then use the json method to get json data from api/
const listJson = await promise.json();
const List: TList[] = listJson.map(elt => constructor(elt));
dispatch(setList(List));

@ -11,7 +11,6 @@ import {postCustomJoke} from "../redux/thunk/PostThunk";
export default function AddScreen() {
// @ts-ignore
const allJokes = useSelector(state => state.customReducer.jokes);
const dispatch = useDispatch();
const MAX_LENGTH = 10;
const [joke, onChangeJoke] = React.useState('');
@ -29,44 +28,6 @@ export default function AddScreen() {
clearFields();
};
// const [joke, setJoke] = useState("");
// const [jokeFall, setJokeFall] = useState("");
// const [category, setCategory] = useState("");
// const [categoryExceeded, setCategoryExceeded] = useState(false);
// const [buttonDisabled, setButtonDisabled] = useState(true);
// const MAX_CATEGORY_LENGTH = 10;
// const dispatch = useDispatch();
// useEffect(() => {
// if (joke !== "" && jokeFall !== "" && category !== "") {
// setButtonDisabled(false);
// } else {
// setButtonDisabled(true);
// }
// }, [joke, jokeFall, category]);
// const postjoke = async () => {
// // @ts-ignore
// await dispatch(postJoke(joke, jokeFall, category));
// clearFields();
// };
//
// const clearFields = () => {
// setJoke("");
// setJokeFall("");
// setCategory("");
// setCategoryExceeded(false);
// setButtonDisabled(true);
// };
// const handleCategoryChange = (text) => {
// if (text.length > MAX_CATEGORY_LENGTH) {
// setCategoryExceeded(true);
// } else {
// setCategoryExceeded(false);
// setCategory(text);
// }
// };
return (
<View style={styles.container}>
<Text style={styles.text}>Blague</Text>

@ -5,7 +5,6 @@ import {useDispatch, useSelector} from "react-redux";
import React, {useEffect, useState} from "react";
import {getCustomJokeById, getJokeById} from "../redux/thunk/GetByThunk";
import JokeDetail from "../components/JokeDetail";
import {CustomJoke} from "../model/CustomJoke";
export default function JokeDetailsScreen({route}) {
const idJokeDetail = route.params.idJoke;
@ -32,47 +31,7 @@ export default function JokeDetailsScreen({route}) {
};
loadCustomJoke();
}
// const loadJoke = async () => {
// // @ts-ignore
// await dispatch(getJokeById(idJokeDetail));
// };
// const loadCustomJoke = async () => {
// // @ts-ignore
// await dispatch(getCustomJokeById(idJokeDetail));
// };
// loadCustomJoke();
// loadJoke();
}, [dispatch]);
// const loadCustomJoke = async () => {
// // @ts-ignore
// await dispatch(getCustomJokeById(idJokeDetail));
// };
// // @ts-ignore
// const sampleJokes = useSelector(state => state.sampleReducer.jokes);
// // @ts-ignore
// const customJokes = useSelector(state => state.customReducer.customJoke);
// const dispatch = useDispatch();
//
// useEffect(() => {
// const loadSamplesJokes = async () => {
// // @ts-ignore
// await dispatch(getSampleJokesList());
// };
// loadSamplesJokes();
// }, [dispatch]);
//
// const loadCustomJokes = async () => {
// // @ts-ignore
// await dispatch(getCustomJokeById());
// };
//
// const [showCustomJoke, setCustomJoke] = useState(false); // état local pour contrôler la visibilité de la description
// const toggleDescription = () => {
// setCustomJoke(!showCustomJoke);
// loadCustomJokes();
// };
return (
<View style={styles.container}>
<JokeDetail joke={isCustomJoke ? joke : customJoke}/>

Loading…
Cancel
Save