()
| 14 | } |
| 15 | |
| 16 | function App() { |
| 17 | const dispatch = useDispatch<AppDispatch>(); |
| 18 | const { reduxToDos } = useSelector((state: RootState) => state.reduxToDos); |
| 19 | |
| 20 | console.log(reduxToDos); |
| 21 | |
| 22 | const [toDo, setToDo] = useState(''); |
| 23 | |
| 24 | const maybeAddToDo = () => { |
| 25 | if (toDo.length > 0) { |
| 26 | dispatch(reduxAddToDo(toDo)); |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | // NOTE: Check how app is done with hooks |
| 31 | // return <AppWithReactHooks></AppWithReactHooks>; |
| 32 | return ( |
| 33 | <div className="App "> |
| 34 | <header className="App-header"> |
| 35 | <div className="text-6xl flex flex-col place-items-center space-y-4"> |
| 36 | <div className="w-80 flex flex-col"> |
| 37 | {/* Display ToDos */} |
| 38 | {reduxToDos.map((toDo) => { |
| 39 | return ( |
| 40 | <div key={toDo.id}> |
| 41 | <div className="flex space-x-8 items-end justify-between"> |
| 42 | <div |
| 43 | className={ |
| 44 | toDo.completed ? 'line-through text-gray-400' : '' |
| 45 | } |
| 46 | > |
| 47 | {toDo.text} |
| 48 | </div> |
| 49 | |
| 50 | {toDo.completed ? ( |
| 51 | <div |
| 52 | className="border mb-2 p-4 bg-green-500 rounded" |
| 53 | onClick={() => dispatch(reduxToggleToDo(toDo))} |
| 54 | ></div> |
| 55 | ) : ( |
| 56 | <div |
| 57 | className="border mb-2 p-4 bg-white rounded" |
| 58 | onClick={() => dispatch(reduxToggleToDo(toDo))} |
| 59 | ></div> |
| 60 | )} |
| 61 | </div> |
| 62 | </div> |
| 63 | ); |
| 64 | })} |
| 65 | {/* Add ToDos */} |
| 66 | <div className="w-full mt-4 flex place-items-center justify-between"> |
| 67 | <input |
| 68 | type="text" |
| 69 | value={toDo} |
| 70 | onChange={(e) => setToDo(e.target.value)} |
| 71 | className="w-60 h-20 rounded-lg text-black p-2" |
| 72 | /> |
| 73 | <div className="text-4xl" onClick={maybeAddToDo}> |
nothing calls this directly
no outgoing calls
no test coverage detected