aboutsummaryrefslogtreecommitdiff
path: root/pages/en/schedule
diff options
context:
space:
mode:
Diffstat (limited to 'pages/en/schedule')
-rw-r--r--pages/en/schedule/index.tsx (renamed from pages/en/schedule/index.js)35
1 files changed, 17 insertions, 18 deletions
diff --git a/pages/en/schedule/index.js b/pages/en/schedule/index.tsx
index f1e6730..aa30259 100644
--- a/pages/en/schedule/index.js
+++ b/pages/en/schedule/index.tsx
@@ -18,7 +18,7 @@ import MobileNav from "@/components/shared/MobileNav";
import { useSession } from "next-auth/react";
import { redis } from "@/lib/redis";
import Head from "next/head";
-import { NewNavbar } from "@/components/shared/NavBar";
+import { Navbar } from "@/components/shared/NavBar";
const day = [
"Sunday",
@@ -30,7 +30,8 @@ const day = [
"Saturday",
];
-const isAired = (timestamp) => {
+const isAired = (timestamp: number | null) => {
+ if (!timestamp) return false;
const currentTime = new Date().getTime() / 1000;
return timestamp <= currentTime;
};
@@ -51,7 +52,7 @@ export async function getServerSideProps() {
0
);
const timeUntilMidnightJapan = Math.round(
- (midnightTomorrowJapan - nowJapan) / 1000
+ (midnightTomorrowJapan.getTime() - nowJapan.getTime()) / 1000
);
let cachedData;
@@ -109,12 +110,13 @@ export async function getServerSideProps() {
page++;
}
- const timestampToDay = (timestamp) => {
- const options = { weekday: "long" };
- return new Date(timestamp * 1000).toLocaleDateString(undefined, options);
+ const timestampToDay = (timestamp: number) => {
+ return new Date(timestamp * 1000).toLocaleDateString(undefined, {
+ weekday: "long",
+ });
};
- const scheduleByDay = {};
+ const scheduleByDay: { [key: string]: any } = {};
airingSchedules.forEach((schedule) => {
const day = timestampToDay(schedule.airingAt);
if (!scheduleByDay[day]) {
@@ -142,10 +144,7 @@ export async function getServerSideProps() {
// setSchedule(scheduleByDay);
}
-export default function Schedule({ schedule }) {
- const { data: session } = useSession();
-
- // const [schedule, setSchedule] = useState({});
+export default function Schedule({ schedule }: any) {
const [filterDay, setFilterDay] = useState("All");
const [loading, setLoading] = useState(true);
@@ -178,7 +177,7 @@ export default function Schedule({ schedule }) {
let nextAiring = null;
let currentlyAiring = null;
- for (const [, schedules] of Object.entries(sortedSchedule)) {
+ for (const [, schedules] of Object.entries(sortedSchedule as object)) {
for (const s of schedules) {
if (s.airingAt > now) {
if (!nextAiring) {
@@ -196,16 +195,16 @@ export default function Schedule({ schedule }) {
setCurrentlyAiringAnime(currentlyAiring);
}, [sortedSchedule]);
- const scrollContainerRef = useRef(null);
+ const scrollContainerRef = useRef<HTMLUListElement>(null);
useEffect(() => {
// Scroll to center the active button when it changes
if (scrollContainerRef.current) {
const activeButton =
- scrollContainerRef.current.querySelector(".text-action");
+ scrollContainerRef.current?.querySelector(".text-action");
if (activeButton) {
const containerWidth = scrollContainerRef.current.clientWidth;
- const buttonLeft = activeButton.offsetLeft;
+ const buttonLeft = (activeButton as HTMLElement).offsetLeft;
const buttonWidth = activeButton.clientWidth;
const scrollLeft = buttonLeft - containerWidth / 2 + buttonWidth / 2;
scrollContainerRef.current.scrollLeft = scrollLeft;
@@ -264,8 +263,8 @@ export default function Schedule({ schedule }) {
content="Moopa is a website where you can find all the information about your favorite anime and manga."
/>
</Head>
- <MobileNav sessions={session} hideProfile={true} />
- <NewNavbar scrollP={10} toTop={true} />
+ <MobileNav hideProfile={true} />
+ <Navbar scrollP={10} toTop={true} />
<div className="w-screen">
<span className="absolute z-20 top-0 left-0 w-screen h-[190px] lg:h-[250px] bg-secondary overflow-hidden">
<div className="absolute top-40 lg:top-36 w-full h-full bg-primary rounded-t-3xl xl:rounded-t-[50px]" />
@@ -340,7 +339,7 @@ export default function Schedule({ schedule }) {
>
<div className="ml-4 flex items-center gap-2">
<h3 className="text-lg text-gray-200 font-semibold">
- {timeStamptoAMPM(time)}
+ {time && timeStamptoAMPM(time)}
</h3>
{/* {!isAired(time) && <p>Airing Next</p>} */}
<p