2021-04-30 15:43:03 +00:00
|
|
|
import { Panel } from '../Panels';
|
2022-02-24 21:29:47 +00:00
|
|
|
import periodicFetch from '../../lib/fetchers/periodicFetch';
|
2021-04-01 15:14:46 +00:00
|
|
|
import SelectedAnvil from './SelectedAnvil';
|
|
|
|
import AnvilList from './AnvilList';
|
2021-03-09 16:34:44 +00:00
|
|
|
|
2021-04-28 22:52:16 +00:00
|
|
|
import sortAnvils from './sortAnvils';
|
2023-06-20 00:03:07 +00:00
|
|
|
import API_BASE_URL from '../../lib/consts/API_BASE_URL';
|
2021-04-28 15:57:19 +00:00
|
|
|
|
2021-03-15 23:01:48 +00:00
|
|
|
const Anvils = ({ list }: { list: AnvilList | undefined }): JSX.Element => {
|
2021-03-25 20:19:14 +00:00
|
|
|
const anvils: AnvilListItem[] = [];
|
2021-03-15 23:01:48 +00:00
|
|
|
|
2021-03-25 20:19:14 +00:00
|
|
|
list?.anvils.forEach((anvil: AnvilListItem) => {
|
2023-06-20 00:03:07 +00:00
|
|
|
const { anvil_uuid } = anvil;
|
|
|
|
|
2022-02-24 21:29:47 +00:00
|
|
|
const { data } = periodicFetch<AnvilStatus>(
|
2023-06-20 00:03:07 +00:00
|
|
|
`${API_BASE_URL}/anvil/${anvil_uuid}`,
|
2021-03-25 14:59:23 +00:00
|
|
|
);
|
2021-03-25 20:19:14 +00:00
|
|
|
anvils.push({
|
|
|
|
...anvil,
|
2021-05-26 20:51:23 +00:00
|
|
|
...data,
|
2021-03-25 20:19:14 +00:00
|
|
|
});
|
2021-03-25 14:59:23 +00:00
|
|
|
});
|
2021-03-09 16:34:44 +00:00
|
|
|
return (
|
|
|
|
<Panel>
|
2021-04-28 22:52:16 +00:00
|
|
|
<SelectedAnvil list={anvils} />
|
|
|
|
<AnvilList list={sortAnvils(anvils)} />
|
2021-03-09 16:34:44 +00:00
|
|
|
</Panel>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Anvils;
|