@@ -12,7 +12,7 @@ const YugiohPagination = dynamic(
1212 { ssr : false }
1313) ;
1414
15- const YugiohCardDataTable = ( { matchedCardData, setMatchedCardData } ) => {
15+ const YugiohCardDataTable = ( { matchedCardData, setMatchedCardData, isAuthenticated = false } ) => {
1616 const router = useRouter ( ) ;
1717 const itemsPerPage = 15 ;
1818 const [ currentPage , setCurrentPage ] = useState ( 1 ) ;
@@ -146,6 +146,11 @@ const YugiohCardDataTable = ( { matchedCardData, setMatchedCardData } ) => {
146146 ) ;
147147
148148 const addToCollection = useCallback ( async ( ) => {
149+ if ( ! isAuthenticated ) {
150+ triggerNotification ( "Log in to add cards to your collection." ) ;
151+ return ;
152+ }
153+
149154 if ( selectedKeys . size === 0 ) {
150155 triggerNotification ( "No cards were selected to add to the collection!" ) ;
151156 return ;
@@ -181,7 +186,7 @@ const YugiohCardDataTable = ( { matchedCardData, setMatchedCardData } ) => {
181186 } catch {
182187 triggerNotification ( "Card(s) failed to save!" ) ;
183188 }
184- } , [ selectedKeys , matchedCardData , itemUniqueIds , triggerNotification ] ) ;
189+ } , [ isAuthenticated , selectedKeys , matchedCardData , itemUniqueIds , triggerNotification ] ) ;
185190
186191
187192 const downloadCSV = useCallback ( ( ) => {
@@ -215,8 +220,13 @@ const YugiohCardDataTable = ( { matchedCardData, setMatchedCardData } ) => {
215220 } , [ selectedKeys , matchedCardData , setMatchedCardData , itemUniqueIds , triggerNotification ] ) ;
216221
217222 const handleGoToCollectionPage = useCallback ( ( ) => {
223+ if ( ! isAuthenticated ) {
224+ triggerNotification ( "Log in to view your collection." ) ;
225+ return ;
226+ }
227+
218228 router . push ( '/yugioh/my-collection' ) ;
219- } , [ router ] ) ;
229+ } , [ isAuthenticated , router , triggerNotification ] ) ;
220230
221231 // Format helper for prices
222232 const formatPrice = ( val ) => {
@@ -252,20 +262,24 @@ const YugiohCardDataTable = ( { matchedCardData, setMatchedCardData } ) => {
252262 >
253263 Download CSV
254264 </ button >
255- < button
256- type = "button"
257- className = "border border-white rounded-lg px-2 py-2 text-sm text-white font-bold hover:text-black hover:bg-white"
258- onClick = { addToCollection }
259- >
260- Add card(s) to collection
261- </ button >
262- < button
263- type = "button"
264- className = "border border-white rounded-lg px-2 py-2 text-sm text-white font-bold hover:text-black hover:bg-white"
265- onClick = { handleGoToCollectionPage }
266- >
267- View Collection
268- </ button >
265+ { isAuthenticated && (
266+ < >
267+ < button
268+ type = "button"
269+ className = "border border-white rounded-lg px-2 py-2 text-sm text-white font-bold hover:text-black hover:bg-white"
270+ onClick = { addToCollection }
271+ >
272+ Add card(s) to collection
273+ </ button >
274+ < button
275+ type = "button"
276+ className = "border border-white rounded-lg px-2 py-2 text-sm text-white font-bold hover:text-black hover:bg-white"
277+ onClick = { handleGoToCollectionPage }
278+ >
279+ View Collection
280+ </ button >
281+ </ >
282+ ) }
269283 </ div >
270284 { /* Table */ }
271285 < div className = "w-full mx-auto overflow-x-auto" >
@@ -336,7 +350,7 @@ const YugiohCardDataTable = ( { matchedCardData, setMatchedCardData } ) => {
336350 onChange = { ( e ) => toggleCheckbox ( e , uniqueId ) }
337351 />
338352 </ td >
339- < td className = "p-2 text-center border-t border-gray-100 text-xs lg :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
353+ < td className = "p-2 text-center text-nowrap border-t border-gray-100 text-xs md :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
340354 { ( ( ) => {
341355 const detailParams = item . detailParams || { } ;
342356 const rawLetter = router . query ?. letter ;
@@ -379,22 +393,22 @@ const YugiohCardDataTable = ( { matchedCardData, setMatchedCardData } ) => {
379393 ) ;
380394 } ) ( ) }
381395 </ td >
382- < td className = "p-2 text-center border-t border-gray-100 text-xs lg :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
396+ < td className = "text-nowrap p-2 text-center border-t border-gray-100 text-xs md :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
383397 { card ?. setName || 'N/A' }
384398 </ td >
385- < td className = "p-2 text-center border-t border-gray-100 text-xs lg :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
399+ < td className = "text-nowrap p-2 text-center border-t border-gray-100 text-xs md :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
386400 { card ?. number || 'N/A' }
387401 </ td >
388- < td className = "p-2 text-center border-t border-gray-100 text-xs lg :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
402+ < td className = "text-nowrap p-2 text-center border-t border-gray-100 text-xs md :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
389403 { card ?. printing || 'N/A' }
390404 </ td >
391- < td className = "p-2 text-center border-t border-gray-100 text-xs lg :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
405+ < td className = "text-nowrap p-2 text-center border-t border-gray-100 text-xs md :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
392406 { card ?. rarity || 'N/A' }
393407 </ td >
394- < td className = "p-2 text-center border-t border-gray-100 text-xs lg :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
408+ < td className = "text-nowrap p-2 text-center border-t border-gray-100 text-xs md :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
395409 { card ?. condition || card ?. condition + " " + card ?. printing }
396410 </ td >
397- < td className = "p-2 text-center border-t border-gray-100 text-xs lg :text-sm sm:text-left text-white hover:bg-black hover:text-white" >
411+ < td className = "text-nowrap p-2 text-center border-t border-gray-100 text-xs md :text-sm sm:text-center font-bold text-white hover:bg-black hover:text-white" >
398412 { formatPrice ( data ?. marketPrice ) }
399413 </ td >
400414 </ tr >
0 commit comments