show recent content
This commit is contained in:
@@ -17,15 +17,9 @@ type ContentObject = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function StatModule() {
|
export default function StatModule() {
|
||||||
const [show, setShow] = useState<ContentObject | null>(null);
|
const [data, setData] = useState<ContentObject[] | null>(null);
|
||||||
const [game, setGame] = useState<ContentObject | null>(null);
|
|
||||||
const [book, setBook] = useState<ContentObject | null>(null);
|
|
||||||
|
|
||||||
const [failedFetch, setFailedFetch] = useState({
|
const [failedFetch, setFailedFetch] = useState<boolean>(false);
|
||||||
tv: false,
|
|
||||||
book: false,
|
|
||||||
game: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const ErrorState = () => {
|
const ErrorState = () => {
|
||||||
return (
|
return (
|
||||||
@@ -37,178 +31,52 @@ export default function StatModule() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchTV() {
|
async function fetchData() {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"https://api.alexav.gg/v4/tracker/items?type=TV&sort=desc&limit=1&started=true"
|
"https://api.alexav.gg/v4/tracker/items?sort=desc&limit=3&started=true",
|
||||||
);
|
);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data && data.length <= 0) {
|
if (data && data.length <= 0) {
|
||||||
setFailedFetch((prev) => {
|
setFailedFetch(true);
|
||||||
return {
|
} else setData(data.data as ContentObject[]);
|
||||||
...prev,
|
} else setFailedFetch(true);
|
||||||
tv: true,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
} else setShow(data.data[0] as ContentObject);
|
|
||||||
} else
|
|
||||||
setFailedFetch((prev) => {
|
|
||||||
return {
|
|
||||||
...prev,
|
|
||||||
tv: true,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async function fetchBook() {
|
|
||||||
const response = await fetch(
|
|
||||||
"https://api.alexav.gg/v4/tracker/items?type=BOOK&sort=desc&limit=1&started=true"
|
|
||||||
);
|
|
||||||
if (response.ok) {
|
|
||||||
const data = await response.json();
|
|
||||||
if (data && data.length <= 0) {
|
|
||||||
setFailedFetch((prev) => {
|
|
||||||
return {
|
|
||||||
...prev,
|
|
||||||
book: true,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
} else setBook(data.data[0] as ContentObject);
|
|
||||||
} else
|
|
||||||
setFailedFetch((prev) => {
|
|
||||||
return {
|
|
||||||
...prev,
|
|
||||||
book: true,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async function fetchGame() {
|
|
||||||
const response = await fetch(
|
|
||||||
"https://api.alexav.gg/v4/tracker/items?type=GAME&sort=desc&limit=1&started=true"
|
|
||||||
);
|
|
||||||
if (response.ok) {
|
|
||||||
const data = await response.json();
|
|
||||||
if (data && data.length <= 0) {
|
|
||||||
setFailedFetch((prev) => {
|
|
||||||
return {
|
|
||||||
...prev,
|
|
||||||
game: true,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
} else setGame(data.data[0] as ContentObject);
|
|
||||||
} else
|
|
||||||
setFailedFetch((prev) => {
|
|
||||||
return {
|
|
||||||
...prev,
|
|
||||||
game: true,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchTV();
|
fetchData();
|
||||||
fetchBook();
|
|
||||||
fetchGame();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="border border-white border-solid rounded-lg w-full mb-4">
|
<div className="border border-white border-solid rounded-lg w-full mb-4">
|
||||||
<div className="grid grid-cols-3 gap-2">
|
<div className="grid grid-cols-3 gap-2">
|
||||||
{!failedFetch.tv ? (
|
{data?.map((v, k) => {
|
||||||
<div className="text-center p-2 space-y-2">
|
return (
|
||||||
|
<div key={k} className="text-center p-2 space-y-2">
|
||||||
<img
|
<img
|
||||||
src={show?.image}
|
src={v?.image}
|
||||||
className="object-cover w-full h-[50px] object-top"
|
className="object-cover w-full h-[50px] object-top"
|
||||||
/>
|
/>
|
||||||
<a
|
<a
|
||||||
className="hover:underline"
|
className="hover:underline"
|
||||||
href={`https://tracker.alexav.gg/info/${show?.id}`}
|
href={`https://tracker.alexav.gg/info/${v?.id}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
<h1 className="font-semibold">{show?.title}</h1>
|
<h1 className="font-semibold">{v?.title}</h1>
|
||||||
<p>
|
<p>
|
||||||
{" "}
|
{" "}
|
||||||
{show?.finished
|
{v?.finished
|
||||||
? "finished"
|
? "finished"
|
||||||
: show?.paused
|
: v?.paused
|
||||||
? "paused"
|
? "paused"
|
||||||
: show?.episode}
|
: v.startedOn
|
||||||
|
? "started"
|
||||||
|
: "not started"}
|
||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
);
|
||||||
<ErrorState />
|
})}
|
||||||
)}
|
|
||||||
{!failedFetch.game ? (
|
|
||||||
<div className="text-center p-2 space-y-2">
|
|
||||||
<img
|
|
||||||
src={game?.image}
|
|
||||||
className="object-cover w-full h-[50px] object-top"
|
|
||||||
/>
|
|
||||||
<a
|
|
||||||
className="hover:underline"
|
|
||||||
href={`https://tracker.alexav.gg/info/${game?.id}`}
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<h1 className="font-semibold">{game?.title}</h1>
|
|
||||||
<p>
|
|
||||||
{" "}
|
|
||||||
{game?.finished
|
|
||||||
? "finished"
|
|
||||||
: game?.paused
|
|
||||||
? "paused"
|
|
||||||
: game?.episode}
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<ErrorState />
|
|
||||||
)}
|
|
||||||
{!failedFetch.book ? (
|
|
||||||
<div className="text-center p-2 space-y-2">
|
|
||||||
<img
|
|
||||||
src={book?.image}
|
|
||||||
className="object-cover w-full h-[50px] object-top"
|
|
||||||
/>
|
|
||||||
<a
|
|
||||||
className="hover:underline"
|
|
||||||
href={`https://tracker.alexav.gg/info/${book?.id}`}
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<h1 className="font-semibold">{book?.title}</h1>
|
|
||||||
<p>
|
|
||||||
{" "}
|
|
||||||
{book?.finished
|
|
||||||
? "finished"
|
|
||||||
: book?.paused
|
|
||||||
? "paused"
|
|
||||||
: book?.author}
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<ErrorState />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
// if (show) {
|
|
||||||
// return (
|
|
||||||
// <div className="flex align-middle">
|
|
||||||
// </div>
|
|
||||||
// );
|
|
||||||
// } else {
|
|
||||||
// if (failedFetch) {
|
|
||||||
// return (
|
|
||||||
// <div>
|
|
||||||
// <p>failed to get show :(</p>
|
|
||||||
// </div>
|
|
||||||
// );
|
|
||||||
// } else {
|
|
||||||
// return (
|
|
||||||
// <div>
|
|
||||||
// <p>loading show..</p>
|
|
||||||
// </div>
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -5,7 +5,6 @@ import GameComponent from "../components/info/GameComponent";
|
|||||||
import PictureCarousel from "../components/modules/PictureCarousel";
|
import PictureCarousel from "../components/modules/PictureCarousel";
|
||||||
import InfoModule from "../components/modules/InfoModule";
|
import InfoModule from "../components/modules/InfoModule";
|
||||||
import WelcomeModule from "../components/modules/WelcomeModule";
|
import WelcomeModule from "../components/modules/WelcomeModule";
|
||||||
import FantasyStatus from "../components/FantasyStatus";
|
|
||||||
import ScoreModule from "../components/modules/ScoreModule";
|
import ScoreModule from "../components/modules/ScoreModule";
|
||||||
import StatModule from "../components/modules/StatModule";
|
import StatModule from "../components/modules/StatModule";
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ export default function App() {
|
|||||||
<PictureCarousel onClick={(url) => setSelectedImage(url)} />
|
<PictureCarousel onClick={(url) => setSelectedImage(url)} />
|
||||||
<GameComponent />
|
<GameComponent />
|
||||||
<ScoreModule type={"bills"} />
|
<ScoreModule type={"bills"} />
|
||||||
<FantasyStatus />
|
{/* <FantasyStatus /> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|||||||
Reference in New Issue
Block a user