Skip to content

Commit

Permalink
[PAY-2701] Add favorites (saves) column to TracksTable (#8140)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored Apr 22, 2024
1 parent d71db62 commit 8c3d050
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/web/src/components/tracks-table/TracksTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type TracksTableColumn =
| 'plays'
| 'releaseDate'
| 'reposts'
| 'saves'
| 'savedDate'
| 'spacer'
| 'trackName'
Expand Down Expand Up @@ -290,6 +291,11 @@ export const TracksTable = ({
return moment(track.dateSaved).format('M/D/YY')
}, [])

const renderSavesCell = useCallback((cellInfo: TrackCell) => {
const track = cellInfo.row.original
return formatCount(track.save_count)
}, [])

const renderReleaseDateCell = useCallback((cellInfo: TrackCell) => {
const track = cellInfo.row.original
let suffix = ''
Expand Down Expand Up @@ -572,6 +578,16 @@ export const TracksTable = ({
disableResizing: true,
disableSortBy: true
},
saves: {
id: 'saves',
Header: 'Favorites',
accessor: 'save_count',
Cell: renderSavesCell,
maxWidth: 160,
sortTitle: 'Favorites',
sorter: numericSorter('save_count'),
align: 'right'
},
overflowActions: {
id: 'trackActions',
Cell: renderTrackActions,
Expand Down Expand Up @@ -644,7 +660,8 @@ export const TracksTable = ({
renderReleaseDateCell,
renderRepostsCell,
renderTrackActions,
renderTrackNameCell
renderTrackNameCell,
renderSavesCell
]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const albumTableColumns: TracksTableColumn[] = [
'spacer',
'trackName',
'releaseDate',
'saves',
'reposts',
'overflowMenu'
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const tracksTableColumns: TracksTableColumn[] = [
'releaseDate',
'length',
'plays',
'saves',
'reposts',
'overflowMenu'
]
Expand Down

0 comments on commit 8c3d050

Please sign in to comment.