Skip to content

Commit 2f05b92

Browse files
hh
1 parent cd9fbae commit 2f05b92

12 files changed

Lines changed: 49 additions & 26 deletions

File tree

components/LoadingSpinner.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @/components/LoadingSpinner.js
2+
"use client";
23
const LoadingSpinner = () => {
34
return (
45
<div className="z-50 w-24 h-24 backdrop-opacity-0 spinner">

components/Navigation/SideNav.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default function SideNav() {
7878
};
7979

8080
checkAuth();
81-
}, [] );
81+
}, [ router ] );
8282

8383
useEffect( () => {
8484
const currentPath = normalizePath( router.asPath ?? router.pathname ?? "" );

components/Notification.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import React, { useState, useEffect } from 'react';
23
import { XMarkIcon } from '@heroicons/react/20/solid';
34

@@ -12,7 +13,7 @@ const Notification = ( { show, setShow, message } ) => {
1213
return (
1314
<div
1415
aria-live="assertive"
15-
className={ `pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:items-start sm:p-6 transition duration-300 ${ show ? 'opacity-100 translate-y-0 sm:translate-x-0' : 'opacity-0 translate-y-2 sm:translate-y-0 sm:translate-x-2' }` }
16+
className={ `pointer-events-none relative inset-0 flex items-end px-4 py-6 sm:items-start sm:p-6 transition duration-300 ${ show ? 'opacity-100 translate-y-0 sm:translate-x-0' : 'opacity-0 translate-y-2 sm:translate-y-0 sm:translate-x-2' }` }
1617
>
1718
<div className="flex w-full flex-col items-center space-y-4 sm:items-center">
1819
<div className="pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg bg-white shadow-lg ring-1 ring-black ring-opacity-5">

components/Yugioh/AlphabeticalIndex.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import Link from 'next/link';
23
import { useRouter } from 'next/router';
34
import { SpeedInsights } from "@vercel/speed-insights/next";

components/Yugioh/Buttons/FiltersButton.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import CardFilter from '@/components/Yugioh/CardFilter.js';
23
import { useState } from 'react';
34

components/Yugioh/Card.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import Image from "next/image";
23
import Link from 'next/link';
34
import { useRouter } from 'next/router';

components/Yugioh/PriceHistoryChart.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer } from "recharts";
23

34
const PriceHistoryChart = ( { selectedVersion, priceHistory } ) => {

components/Yugioh/TableView.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import { useMemo, useState } from 'react';
23
import { useRouter } from 'next/router';
34
import Notification from '@/components/Notification';
@@ -134,8 +135,8 @@ const TableView = ( { aggregatedData, onDeleteCard, onUpdateCard, handleSortChan
134135
return (
135136
<>
136137

137-
<div class="flex flex-col overflow-x-auto glass">
138-
<div class="mx-auto max-w-[90%] bg-none rounded-lg ">
138+
<div className="flex flex-col overflow-x-auto glass">
139+
<div className="mx-auto max-w-[90%] bg-none rounded-lg ">
139140

140141

141142
<table className="responsive-table text-sm text-white">

components/Yugioh/YugiohCardDataTable.js

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ const YugiohCardDataTable = ( {
2828
const [ lastCheckedKey, setLastCheckedKey ] = useState( null );
2929
const [ notification, setNotification ] = useState( { show: false, message: '' } );
3030
const [ internalCollection, setInternalCollection ] = useState( {} );
31+
const [ isAuthenticated, setIsAuthenticated ] = useState( false );
32+
33+
useMemo( () => {
34+
const checkAuth = async () => {
35+
try {
36+
const res = await fetch( "/api/auth/validate", {
37+
method: "GET",
38+
credentials: "include",
39+
} );
40+
setIsAuthenticated( res.ok );
41+
} catch {
42+
setIsAuthenticated( false );
43+
}
44+
};
45+
46+
checkAuth();
47+
}, [ router ] );
3148

3249
const cardIndex = useMemo( () => {
3350
const map = {};
@@ -348,23 +365,18 @@ const YugiohCardDataTable = ( {
348365
], [] );
349366

350367
return (
351-
<div class="mx-auto bg-none rounded-lg">
352-
353-
354-
355-
356-
{ sortedAndPaginatedData.currentItems.length > 0 && (
368+
<div className="mx-auto bg-none rounded-lg">
369+
<Notification
370+
show={ notification.show }
371+
setShow={ ( show ) => setNotification( { ...notification, show } ) }
372+
message={ notification.message }
373+
/>
374+
{ sortedAndPaginatedData.currentItems.length > 0 && isAuthenticated && (
357375
<div className="mx-auto w-full mb-10 min-h-fit">
358376
<div>
359377
<div className="w-full -mt-5">
360-
<div className="w-fit mx-auto">
361-
<YugiohPagination
362-
currentPage={ currentPage }
363-
itemsPerPage={ itemsPerPage }
364-
totalItems={ sortedAndPaginatedData.totalCount }
365-
handlePageClick={ setCurrentPage }
366-
/>
367-
</div>
378+
379+
368380
<div className="max-h-fit w-full mt-4 flex flex-wrap justify-center gap-3">
369381
<button
370382
type="button"
@@ -389,7 +401,6 @@ const YugiohCardDataTable = ( {
389401
</button>
390402
</div>
391403

392-
393404
{ selectedKeys.size > 0 && (
394405
<div className="flex flex-wrap items-center justify-between gap-3 border-b border-white/5 px-4 py-3 text-sm text-indigo-100">
395406
<div>
@@ -401,8 +412,15 @@ const YugiohCardDataTable = ( {
401412
</div>
402413
</div>
403414
) }
404-
405415
<div className="overflow-x-auto">
416+
<div className="w-fit mx-auto">
417+
<YugiohPagination
418+
currentPage={ currentPage }
419+
itemsPerPage={ itemsPerPage }
420+
totalItems={ sortedAndPaginatedData.totalCount }
421+
handlePageClick={ setCurrentPage }
422+
/>
423+
</div>
406424
<table className="glass min-w-full text-sm text-white mt-10">
407425
<thead>
408426
<tr className="bg-white/5 text-xs uppercase tracking-wide text-white/80">
@@ -495,11 +513,7 @@ const YugiohCardDataTable = ( {
495513
</div>
496514
</div>
497515
</div>
498-
<Notification
499-
show={ notification.show }
500-
setShow={ ( show ) => setNotification( { ...notification, show } ) }
501-
message={ notification.message }
502-
/>
516+
503517
</div>
504518
) }
505519
</div>

components/Yugioh/YugiohPagination.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import { useEffect, useState } from 'react';
23

34
const YugiohPagination = ( { currentPage, itemsPerPage, totalItems, handlePageClick } ) => {

0 commit comments

Comments
 (0)