From a199eeab921a79bcfe0e0b694982dddd6961ac24 Mon Sep 17 00:00:00 2001 From: dekzter Date: Sat, 19 Apr 2025 18:04:48 -0400 Subject: [PATCH] bug fixes, display 'no data' on empty streams table --- .../components/tables/ChannelTableStreams.jsx | 60 +++++++++++++++---- .../src/components/tables/ChannelsTable.jsx | 11 +++- 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/tables/ChannelTableStreams.jsx b/frontend/src/components/tables/ChannelTableStreams.jsx index ca7d23b6..c682705a 100644 --- a/frontend/src/components/tables/ChannelTableStreams.jsx +++ b/frontend/src/components/tables/ChannelTableStreams.jsx @@ -43,9 +43,16 @@ const RowDragHandleCell = ({ rowId }) => { }); return ( // Alternatively, you could set these attributes on the rows themselves - - - +
+ + + +
); }; @@ -108,19 +115,18 @@ const ChannelStreams = ({ channel, isExpanded }) => { (state) => state.getChannelStreams(channel.id), shallow ); + const playlists = usePlaylistsStore((s) => s.playlists); + + const [data, setData] = useState(channelStreams || []); useEffect(() => { setData(channelStreams); }, [channelStreams]); - const [data, setData] = useState(channelStreams || []); - const dataIds = data?.map(({ id }) => id); - const playlists = usePlaylistsStore((s) => s.playlists); - const removeStream = async (stream) => { - const newStreamList = channelStreams.filter((s) => s.id !== stream.id); + const newStreamList = data.filter((s) => s.id !== stream.id); await API.updateChannel({ ...channel, stream_ids: newStreamList.map((s) => s.id), @@ -164,9 +170,9 @@ const ChannelStreams = ({ channel, isExpanded }) => { ), }, ], - [playlists] + [data, playlists] ), - data: data, + data, state: { data, }, @@ -216,6 +222,8 @@ const ChannelStreams = ({ channel, isExpanded }) => { return <>; } + const rows = table.getRowModel().rows; + return ( { items={dataIds} strategy={verticalListSortingStrategy} > - {table.getRowModel().rows.map((row) => ( - - ))} + {rows.length === 0 && ( + + + + No Data + + + + )} + {rows.length > 0 && + table + .getRowModel() + .rows.map((row) => )} diff --git a/frontend/src/components/tables/ChannelsTable.jsx b/frontend/src/components/tables/ChannelsTable.jsx index f9396022..f32f6a8b 100644 --- a/frontend/src/components/tables/ChannelsTable.jsx +++ b/frontend/src/components/tables/ChannelsTable.jsx @@ -385,6 +385,10 @@ const ChannelsTable = ({}) => { ...prev, [name]: value, })); + setPagination({ + pageIndex: 0, + pageSize: pagination.pageSize, + }); }, []); const handleGroupChange = (value) => { @@ -392,6 +396,10 @@ const ChannelsTable = ({}) => { ...prev, channel_group: value ? value : '', })); + setPagination({ + pageIndex: 0, + pageSize: pagination.pageSize, + }); }; const hdhrUrlRef = useRef(null); @@ -729,7 +737,8 @@ const ChannelsTable = ({}) => { }, }, { - accessorFn: (row) => row.channel_group?.name || '', + accessorFn: (row) => + row.channel_group_id ? channelGroups[row.channel_group_id].name : '', id: 'channel_group', cell: ({ getValue }) => (