3
3
import { useEffect , useState } from "react" ;
4
4
import axios from "axios" ;
5
5
import { type IUpcomingPaper } from "@/interface" ;
6
- import Loader from "./ui/loader" ;
7
6
import UpcomingPaper from "./UpcomingPaper" ;
8
7
import {
9
8
Carousel ,
@@ -14,6 +13,7 @@ import {
14
13
} from "@/components/ui/carousel" ;
15
14
import Autoplay from "embla-carousel-autoplay" ;
16
15
import { chunkArray } from "@/util/utils" ;
16
+ import { Skeleton } from "@/components/ui/skeleton" ;
17
17
18
18
function PapersCarousel ( {
19
19
carouselType,
@@ -41,7 +41,7 @@ function PapersCarousel({
41
41
"Design and Analysis of Algorithms [MCSE502L]" ,
42
42
"Complex Variables and Linear Algebra [BMAT201L]" ,
43
43
"Differential Equations and Transforms [BMAT102L]" ,
44
- ] ) ,
44
+ ] )
45
45
) ;
46
46
47
47
handleResize ( ) ;
@@ -62,11 +62,14 @@ function PapersCarousel({
62
62
const storedSubjects = JSON . parse (
63
63
localStorage . getItem ( "userSubjects" ) ?? "[]"
64
64
) as string [ ] ;
65
- const response = await axios . post < IUpcomingPaper [ ] > ( "/api/user-papers" , storedSubjects ) ;
65
+ const response = await axios . post < IUpcomingPaper [ ] > (
66
+ "/api/user-papers" ,
67
+ storedSubjects
68
+ ) ;
66
69
setDisplayPapers ( response . data ) ;
67
70
} else {
68
71
const response = await axios . get < IUpcomingPaper [ ] > (
69
- "/api/upcoming-papers" ,
72
+ "/api/upcoming-papers"
70
73
) ;
71
74
setDisplayPapers ( response . data ) ;
72
75
}
@@ -81,7 +84,23 @@ function PapersCarousel({
81
84
} , [ ] ) ;
82
85
83
86
if ( isLoading ) {
84
- return < Loader prop = "m-10" /> ;
87
+ return (
88
+ < div className = "px-4" >
89
+ < p className = "my-8 text-center font-play text-lg font-semibold" >
90
+ { carouselType === "users" ? "Your Papers" : "Upcoming Papers" }
91
+ </ p >
92
+
93
+ < div className = "grid grid-cols-2 grid-rows-2 gap-4 md:grid-cols-4 lg:auto-rows-fr" >
94
+ { Array . from ( { length : 8 } ) . map ( ( _ , index ) => (
95
+ < div key = { index } className = "space-y-4 p-2" >
96
+ < Skeleton className = "h-4 w-[70%]" />
97
+ < Skeleton className = "h-4 w-[50%]" />
98
+ < Skeleton className = "h-20 w-full rounded-lg" />
99
+ </ div >
100
+ ) ) }
101
+ </ div >
102
+ </ div >
103
+ ) ;
85
104
}
86
105
87
106
const plugins = [ Autoplay ( { delay : 8000 , stopOnInteraction : true } ) ] ;
0 commit comments