import React, { FC } from 'react'; import { useTranslation } from 'react-i18next'; import { IInAppNotification, PaginateResult } from '~/interfaces/in-app-notification'; import { HasObjectId } from '~/interfaces/has-object-id'; import InAppNotificationElm from './InAppNotificationElm'; type Props = { inAppNotificationData?: PaginateResult; }; const InAppNotificationList: FC = (props: Props) => { const { t } = useTranslation(); const { inAppNotificationData } = props; if (inAppNotificationData == null) { return (
); } const notifications = inAppNotificationData.docs; const renderInAppNotificationList = () => { const inAppNotificationList = notifications.map((notification: IInAppNotification & HasObjectId) => { return (
); }); return inAppNotificationList; }; return ( <> {notifications.length === 0 ? <>{t('in_app_notification.no_notification')} : renderInAppNotificationList()} ); }; export default InAppNotificationList;