@@ -4,15 +4,15 @@ import dynamic from "next/dynamic";
44import { useRouter } from "next/router" ;
55import { SpeedInsights } from "@vercel/speed-insights/next" ;
66import { Grid , List , Loader2 , TrendingUp , Trash2 , Search } from "lucide-react" ;
7-
7+ import Notification from '@/components/Notification' ;
88import DownloadYugiohCSVButton from "@/components/Yugioh/Buttons/DownloadYugiohCSVButton" ;
99import CardFilter from "@/components/Yugioh/CardFilter" ;
1010import YugiohPagination from "@/components/Yugioh/YugiohPagination" ;
1111
1212const TableView = dynamic ( ( ) => import ( "@/components/Yugioh/TableView" ) , {
1313 ssr : false ,
1414 loading : ( ) => (
15- < div className = "py-12 text-center text-lg font-semibold text-white/80" >
15+ < div className = "mx-auto justify-center items-center py-12 text-center text-lg font-semibold text-white/80" >
1616 Loading table...
1717 </ div >
1818 ) ,
@@ -21,19 +21,19 @@ const TableView = dynamic( () => import( "@/components/Yugioh/TableView" ), {
2121const GridView = dynamic ( ( ) => import ( "@/components/Yugioh/GridView" ) , {
2222 ssr : false ,
2323 loading : ( ) => (
24- < div className = "py-12 text-center text-lg font-semibold text-white/80" >
24+ < div className = "mx-auto justify-center items-center py-12 text-center text-lg font-semibold text-white/80" >
2525 Loading cards...
2626 </ div >
2727 ) ,
2828} ) ;
2929
30- const ITEMS_PER_PAGE = 20 ;
30+ const ITEMS_PER_PAGE = 12 ;
3131const DEFAULT_FILTERS = { rarity : [ ] , condition : [ ] , printing : [ ] } ;
3232const DEFAULT_SORT = { key : "number" , direction : "ascending" } ;
3333
3434const MyCollection = ( ) => {
3535 const router = useRouter ( ) ;
36-
36+ const [ notification , setNotification ] = useState ( { show : false , message : '' } ) ;
3737 const [ cards , setCards ] = useState ( [ ] ) ;
3838 const [ viewMode , setViewMode ] = useState ( "grid" ) ;
3939 const [ isAuthenticated , setIsAuthenticated ] = useState ( false ) ;
@@ -347,14 +347,15 @@ const MyCollection = () => {
347347 }
348348
349349 if ( ! response . ok ) {
350+ setNotification ( { show : true , message : 'Card deleted successfully!' } ) ;
350351 throw new Error ( "Failed to update card prices." ) ;
351352 }
352353
353354 await refreshCollection ( ) ;
354355 window . alert ( "Prices updated successfully." ) ;
355356 } catch ( error ) {
356357 console . error ( "Error updating card prices:" , error ) ;
357- window . alert ( "An error occurred while updating prices. Please try again later." ) ;
358+ setNotification ( { show : true , message : 'Failed to update card prices! Please try again!' } ) ;
358359 } finally {
359360 setIsUpdatingPrices ( false ) ;
360361 }
@@ -407,7 +408,7 @@ const MyCollection = () => {
407408 }
408409
409410 if ( ! response . ok ) {
410- throw new Error ( " Failed to delete card" ) ;
411+ setNotification ( { show : true , message : ' Failed to delete card!' } ) ;
411412 }
412413
413414 setCards ( ( current ) => current . filter ( ( card ) => card ?. _id !== cardId ) ) ;
@@ -501,7 +502,7 @@ const MyCollection = () => {
501502 ) ;
502503 } else {
503504 content = (
504- < div className = "space-y-10 mx-auto min-h-screen yugioh-bg bg-fixed bg-center bg-no-repeat" >
505+ < div className = "space-y-10 mx-auto h-full max-h-fit overflow-hidden yugioh-bg bg-fixed bg-center bg-no-repeat" >
505506 < header className = "space-y-6 rounded-3xl border border-white/10 bg-black/30 p-8 backdrop" >
506507 < div className = "space-y-2" >
507508 < h1 className = "text-3xl font-bold text-shadow md:text-4xl" > My Yu-Gi-Oh! Collection</ h1 >
@@ -582,7 +583,7 @@ const MyCollection = () => {
582583 </ div >
583584 </ section >
584585
585- < section className = "rounded-3xl bg-fixed " >
586+ < section className = "sticky " >
586587 { hasCards ? (
587588 < >
588589 < div className = "flex max-h-24 h-fit items-center gap-3" >
@@ -660,12 +661,20 @@ const MyCollection = () => {
660661 return (
661662 < >
662663 < Head >
663- < title > My Collection | Yu-Gi-Oh! Tracker</ title >
664+ < title >
665+ My Collection | Yu-Gi-Oh! Tracker
666+ </ title >
664667 </ Head >
665668
666- < div className = "w-full max-h-max" >
667- < div className = "mx-auto" > { content } </ div >
669+
670+ < div className = "mx-auto h-auto w-full" >
671+ { content }
668672 </ div >
673+ < Notification
674+ show = { notification . show }
675+ setShow = { ( show ) => setNotification ( ( prev ) => ( { ...prev , show } ) ) }
676+ message = { notification . message }
677+ />
669678 < SpeedInsights />
670679 </ >
671680 ) ;
0 commit comments