Skip to content

Commit 5a07dd2

Browse files
feat: add "All" tab to Cards component (#76)
* feat: add "All" tab to Cards component and update layout * use all pack & gruop by expansion instead of pack --------- Co-authored-by: marcel panse <marcel.panse@gmail.com>
1 parent 320324b commit 5a07dd2

File tree

1 file changed

+10
-6
lines changed
  • frontend/src/pages/collection/components

1 file changed

+10
-6
lines changed

frontend/src/pages/collection/components/Cards.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs.tsx'
22
import { COLLECTION_ID, DATABASE_ID, getDatabase } from '@/lib/Auth.ts'
3-
import { a1Cards, a1aCards, a2Cards, paCards } from '@/lib/CardsDB.ts'
3+
import { a1Cards, a1aCards, a2Cards, allCards, paCards } from '@/lib/CardsDB.ts'
44
import type { Card, CollectionRow } from '@/types'
55
import { type Row, createColumnHelper, getCoreRowModel, getGroupedRowModel, useReactTable } from '@tanstack/react-table'
66
import { useVirtualizer } from '@tanstack/react-virtual'
@@ -133,8 +133,8 @@ export const Cards: FC<Props> = ({ user, ownedCards, setOwnedCards }) => {
133133
columnHelper.accessor('name', {
134134
id: 'name',
135135
}),
136-
columnHelper.accessor('pack', {
137-
id: 'pack',
136+
columnHelper.accessor('set_details', {
137+
id: 'set_details',
138138
}),
139139
]
140140
}, [])
@@ -147,7 +147,7 @@ export const Cards: FC<Props> = ({ user, ownedCards, setOwnedCards }) => {
147147
getCoreRowModel: getCoreRowModel(),
148148
getGroupedRowModel: getGroupedRowModel(),
149149
initialState: {
150-
grouping: ['pack'],
150+
grouping: ['set_details'],
151151
},
152152
})
153153
const groupedRows = table.getRowModel().rows
@@ -200,7 +200,7 @@ export const Cards: FC<Props> = ({ user, ownedCards, setOwnedCards }) => {
200200
}}
201201
>
202202
{row.type === 'header' ? (
203-
<PackHeader title={(row.data as { type: string; row: Row<Card> }).row.getValue('pack')} />
203+
<PackHeader title={(row.data as { type: string; row: Row<Card> }).row.getValue('set_details')} />
204204
) : (
205205
<div className="flex justify-center gap-5">
206206
{(row.data as { type: string; row: Row<Card> }[]).map(({ row: subRow }) => (
@@ -218,13 +218,17 @@ export const Cards: FC<Props> = ({ user, ownedCards, setOwnedCards }) => {
218218

219219
return (
220220
<div className="flex flex-col gap-y-4 max-w-[900px] mx-auto">
221-
<Tabs defaultValue="a1">
221+
<Tabs defaultValue="all">
222222
<TabsList className="m-auto mt-4 mb-8">
223+
<TabsTrigger value="all">All</TabsTrigger>
223224
<TabsTrigger value="a1">A1 - Genetic Apex</TabsTrigger>
224225
<TabsTrigger value="a1a">A1A - Mythical Island</TabsTrigger>
225226
<TabsTrigger value="a2">A2 - Space Time Smackdown</TabsTrigger>
226227
<TabsTrigger value="pa">PA - Promo A</TabsTrigger>
227228
</TabsList>
229+
<TabsContent value="all">
230+
<Pack cards={allCards} />
231+
</TabsContent>
228232
<TabsContent value="a1">
229233
<Pack cards={a1Cards} />
230234
</TabsContent>

0 commit comments

Comments
 (0)