Files
suwayomi-material-you-webui/webUI/react/src/screens/Sources.tsx

25 lines
872 B
TypeScript
Raw Normal View History

2021-01-26 23:32:12 +03:30
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
2021-01-22 17:00:33 +03:30
import React, { useContext, useEffect, useState } from 'react';
2021-01-19 14:47:07 +03:30
import SourceCard from '../components/SourceCard';
2021-01-22 17:00:33 +03:30
import NavBarTitle from '../context/NavbarTitle';
2021-01-19 14:47:07 +03:30
export default function Sources() {
2021-01-22 17:00:33 +03:30
const { setTitle } = useContext(NavBarTitle);
setTitle('Sources');
2021-01-19 14:47:07 +03:30
const [sources, setSources] = useState<ISource[]>([]);
useEffect(() => {
fetch('http://127.0.0.1:4567/api/v1/source/list')
.then((response) => response.json())
.then((data) => setSources(data));
}, []);
if (sources.length === 0) {
2021-01-23 01:33:12 +03:30
return (<h3>wait</h3>);
2021-01-19 14:47:07 +03:30
}
2021-01-23 01:33:12 +03:30
return <>{sources.map((it) => <SourceCard source={it} />)}</>;
2021-01-19 14:47:07 +03:30
}