1- import { React } from "react" ;
1+ import { React , useContext } from "react" ;
22import { useTranslation } from "react-i18next" ;
33import ColumnHoc from "../util/column-hoc" ;
4+ import ListButton from "../util/list/list-button.jsx" ;
5+ import SelectColumnHoc from "../util/select-column-hoc.jsx" ;
6+ import UserContext from "../../context/user-context.jsx" ;
47
58/**
6- * Columns for themes lists .
9+ * Retrieves the columns for feed sources data based on API call response .
710 *
8- * @returns {object } The columns for the themes lists.
11+ * @param {object } props - The props.
12+ * @param {Function } props.apiCall - The API call function to retrieve feed sources data.
13+ * @param {string } props.infoModalRedirect - The redirect URL for information modal.
14+ * @param {string } props.infoModalTitle - The title for information modal.
15+ * @param {string } props.dataKey - The key for data retrieval.
16+ * @returns {object } Columns - An array of objects representing the columns for
17+ * feed sources data.
918 */
10- function getFeedSourcesColumns ( ) {
19+ function getFeedSourcesColumns ( {
20+ apiCall,
21+ infoModalRedirect,
22+ infoModalTitle,
23+ } ) {
24+ const context = useContext ( UserContext ) ;
1125 const { t } = useTranslation ( "common" , { keyPrefix : "feed-sources-list" } ) ;
1226
1327 const columns = [
@@ -16,9 +30,34 @@ function getFeedSourcesColumns() {
1630 content : ( { feedType } ) => < > { feedType } </ > ,
1731 label : t ( "columns.feed-type" ) ,
1832 } ,
33+ {
34+ key : "slides" ,
35+ label : t ( "number-of-slides" ) ,
36+ render : ( { tenants } ) => {
37+ return (
38+ tenants ?. length === 0 ||
39+ ! tenants . find (
40+ ( tenant ) =>
41+ tenant . tenantKey === context . selectedTenant . get . tenantKey
42+ )
43+ ) ;
44+ } ,
45+ // eslint-disable-next-line react/prop-types
46+ content : ( { id } ) => (
47+ < ListButton
48+ apiCall = { apiCall }
49+ redirectTo = { infoModalRedirect }
50+ displayData = { id }
51+ modalTitle = { infoModalTitle }
52+ />
53+ ) ,
54+ } ,
1955 ] ;
2056
2157 return columns ;
2258}
2359
24- export default ColumnHoc ( getFeedSourcesColumns ) ;
60+ const FeedSourceColumns = ColumnHoc ( getFeedSourcesColumns ) ;
61+ const SelectFeedSourceColumns = SelectColumnHoc ( getFeedSourcesColumns ) ;
62+
63+ export { SelectFeedSourceColumns , FeedSourceColumns } ;
0 commit comments