Skip to content

Commit

Permalink
Added airing schedule and made some changes in airing schedule loadin…
Browse files Browse the repository at this point in the history
…g animation
  • Loading branch information
ShivaBhattacharjee committed Aug 11, 2023
1 parent df8f1a4 commit 4a73a46
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
11 changes: 6 additions & 5 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ export default async function page() {
<Cards props={Trending} />
</div>
</div>
{/* <Suspense fallback={<AiringScheduleLoading/>}>
<AiringSchedule />
</Suspense> */}


<Suspense fallback={<div className='flex justify-center items-center gap-5 mt-12'>
<SpinLoading/>
<SpinLoading />
</div>}>
<UpcomingSeason />
</Suspense>

<Suspense fallback={<AiringScheduleLoading />}>
<AiringSchedule />
</Suspense>
</div>
)
}
35 changes: 21 additions & 14 deletions src/components/AiringSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,37 @@ const getAiringSchedule = async () => {
try {
const response = await fetch(`https://api.anify.tv/schedule?apikey=${process.env.NEXT_PUBLIC_ANIFY_KEY}`,{
cache : "no-cache"
})
return response.json()
});
return response.json();
} catch (error) {
console.error("Error getting airing list: ", error)
console.error("Error getting airing list: ", error);
return [];
}
}

export default async function AiringSchedule() {
const Airing = await getAiringSchedule()
const Airing = await getAiringSchedule();

const daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const currentDayIndex = new Date().getDay();
const currentDay = daysOfWeek[currentDayIndex];

return (
<div className='flex flex-col mt-9'>
<h1 className='text-3xl lg:text-5xl font-bold'>Airing</h1>
<div className='flex gap-2'>
<div className="bg-white/10 h-52 w-full p-4 rounded-lg mt-5 lg:h-96 overflow-y-auto">
<div className="flex flex-col gap-3">
<h1>Coming Up Next!</h1>
{Object.keys(Airing).map((day) => (
<h1>{day.split("Schedule")}</h1>
))}
<div className='flex flex-col mt-9'>
<h1 className='text-3xl lg:text-5xl font-bold'>Airing</h1>
<div className='flex gap-2'>
<div className="bg-white/10 h-auto max-h-[400px] w-full p-4 rounded-lg mt-5 lg:h-96 overflow-y-auto">
<div className="flex flex-col gap-3">
<h1>Coming Up Next!</h1>

<div className="flex justify-between">
<span>Previous</span>
<span className='text-center'>{currentDay}</span>
<span>Next</span>
</div>
</div>
</div>
</div>
</div>
);
};

3 changes: 1 addition & 2 deletions src/components/ScrollToTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ const ScrollToTop = () => {
<>
<div className={`fixed flex items-center duration-200 ${isVisible? "scale-100" :
"scale-0 "}
bg-white/30 backdrop-blur-lg z-10 right-5 md:bottom-10 bottom-32
rounded-full p-5 shadow-black shadow-lg`}>
bg-white/30 backdrop-blur-lg z-10 right-5 md:bottom-10 bottom-32 rounded-full p-5 shadow-black shadow-lg`}>
<ChevronUp onClick={goToBtn} className='cursor-pointer' />
</div>
</>
Expand Down
4 changes: 3 additions & 1 deletion src/loading/AiringScheduleLoading.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react'
import SpinLoading from './SpinLoading'

const AiringScheduleLoading = () => {
return (
<div className='flex flex-col mt-9'>
<h1 className='text-3xl lg:text-5xl font-bold'>Airing</h1>
<div className='flex gap-2'>
<div className="bg-white/60 animate-pulse h-52 w-full p-4 rounded-lg mt-5 lg:h-96 overflow-y-auto">
<div className="bg-white/10 flex justify-center items-center animate-pulse h-52 w-full p-4 rounded-lg mt-5 lg:h-96 overflow-y-auto">
<SpinLoading/>
</div>
</div>
</div>
Expand Down

0 comments on commit 4a73a46

Please sign in to comment.