diff --git a/web/src/components/App/index.jsx b/web/src/components/App/index.jsx index 83dbd7d..52ef5ac 100644 --- a/web/src/components/App/index.jsx +++ b/web/src/components/App/index.jsx @@ -7,6 +7,8 @@ import { Brightness4 as Brightness4Icon, Brightness5 as Brightness5Icon, BrightnessAuto as BrightnessAutoIcon, + Sort as SortIcon, + SortByAlpha as SortByAlphaIcon, } from '@material-ui/icons' import { echoHost } from 'utils/Hosts' import Div100vh from 'react-div-100vh' @@ -47,6 +49,9 @@ export default function App() { onError: () => setIsOffline(true), onSuccess: () => setIsOffline(false), }) + const [sortABC, setSortABC] = useState(false) + const handleClickSortABC = () => setSortABC(true) + const handleClickSortDate = () => setSortABC(false) useEffect(() => { axios.get(echoHost()).then(({ data }) => setTorrServerVersion(data)) @@ -76,8 +81,12 @@ export default function App() {
+ (sortABC === true ? handleClickSortDate() : handleClickSortABC())}> + {sortABC === true ? : } + + { if (currentThemeMode === THEME_MODES.LIGHT) updateThemeMode(THEME_MODES.DARK) @@ -115,7 +124,7 @@ export default function App() { setIsDonationDialogOpen={setIsDonationDialogOpen} /> - + @@ -20,7 +20,15 @@ export default function TorrentList({ isOffline, isLoading, torrents }) { ) } - return ( + return sortABC ? ( + + {torrents + .sort((a, b) => a.title > b.title) + .map(torrent => ( + + ))} + + ) : ( {torrents.map(torrent => (