import { useEffect, useState } from 'react'; import { IApplication } from '../../models/application'; import { react2angular } from 'react2angular'; import { Loader } from '../base/loader'; import { EditorialBlock } from '../editorial-block/editorial-block'; import SettingAPI from '../../api/setting'; import SettingLib from '../../lib/setting'; import { SettingValue, eventsSettings } from '../../models/setting'; declare const Application: IApplication; interface EventsEditorialBlockProps { onError: (message: string) => void } /** * This component displays to Users (public view) the editorial block (= banner) associated to events. */ export const EventsEditorialBlock: React.FC = ({ onError }) => { // Stores banner retrieved from API const [banner, setBanner] = useState>({}); // Retrieve the settings related to the Events Banner from the API useEffect(() => { SettingAPI.query(eventsSettings) .then(settings => { setBanner({ ...SettingLib.bulkMapToObject(settings) }); }) .catch(onError); }, []); return ( <> {banner.events_banner_active && } ); }; const EventsEditorialBlockWrapper: React.FC = (props) => { return ( ); }; Application.Components.component('eventsEditorialBlock', react2angular(EventsEditorialBlockWrapper, ['onError']));