This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { charactersApi } from '../apis'; | |
| import { useCharacterList } from './useCharacterList'; | |
| import { useCharacterForm } from './useCharacterForm'; | |
| import { CharacterCreateModal } from '../CharacterCreateModal'; | |
| import { | |
| Button, | |
| Wrapper, | |
| List, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { characterData, delay } from '../fixtures'; | |
| import { CharacterList } from './CharacterList'; | |
| const mockCharactersApi = { | |
| async listSuccess() { | |
| return characterData | |
| }, | |
| async listError() { | |
| throw new Error("Couldn't find a result") | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { charactersApi } from '../apis'; | |
| import { useCharacterList, UseCharacterListDeps } from './useCharacterList'; | |
| import { | |
| Button, | |
| Wrapper, | |
| List, | |
| ListItem, | |
| ListItemInfo, | |
| NameWrapper, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useCallback } from 'react'; | |
| import { useQuery } from 'react-query'; | |
| import type { CharactersApi } from '../apis'; | |
| interface UseCharacterListDeps { | |
| charactersApi: CharactersApi, | |
| } | |
| export function useCharacterList(deps: UseCharacterListDeps) { | |
| const { charactersApi } = deps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { useCharacterList } from './useCharacterList'; | |
| import { | |
| Button, | |
| Wrapper, | |
| List, | |
| ListItem, | |
| ListItemInfo, | |
| NameWrapper, | |
| IsJediWrapper, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useCallback, useEffect } from 'react'; | |
| import { useDispatch, useSelector } from 'react-redux'; | |
| export function useCharacterList() { | |
| const characters = useSelector(characterListSelector); | |
| const loading = useSelector(characterListLoadingSelector); | |
| const dispatch = useDispatch(); | |
| const fetchCharacters = useCallback(() => { | |
| dispatch(actions.fetchCharacters(); |