mirror of
https://github.com/ivabus/www
synced 2024-11-26 05:55:05 +03:00
package-bottle.jsx edit to inlude loading
This commit is contained in:
parent
2be6f65817
commit
5de6a86c16
1 changed files with 7 additions and 1 deletions
|
@ -1,13 +1,19 @@
|
||||||
function PackageBottles() {
|
function PackageBottles() {
|
||||||
const [bottles, setBottles] = React.useState();
|
const [bottles, setBottles] = React.useState();
|
||||||
|
const [isLoading, setIsLoading] = React.useState(true);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const url = window.location.pathname.replace('/+', 'https://app.tea.xyz/api/bottles/');
|
const url = window.location.pathname.replace('/+', 'https://app.tea.xyz/api/bottles/');
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((res) => setBottles(res));
|
.then((res) => {
|
||||||
|
setBottles(res);
|
||||||
|
setIsLoading(false);
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
if (isLoading) return <div>Loading...</div>;
|
||||||
|
|
||||||
if (!bottles) return null;
|
if (!bottles) return null;
|
||||||
|
|
||||||
const names = [...new Set(bottles.map((b) => b.name))];
|
const names = [...new Set(bottles.map((b) => b.name))];
|
||||||
|
|
Loading…
Reference in a new issue