import React from 'react'; import {useNode, Node, JahiaCtx} from '@jahia/nextjs-sdk'; import {SubContent} from './SubContent'; import {Col, Container, Row} from 'react-bootstrap'; import {contentRetrievalProperties} from '../properties'; import {ContentRetrievalPropsType, SubContentQueryProps} from '../types'; import classnames from 'classnames'; export const ContentRetrieval = ({id, referenceComponent, className}: ContentRetrievalPropsType) => { const {locale} = React.useContext(JahiaCtx); const {data, loading, error} = useNode(id, [...contentRetrievalProperties]); if (loading) { return
loading
; } if (error) { console.error(error); return
Error when loading ${JSON.stringify(error)}
; } if (!data || !data.properties) { return
No data returned by ContentRetrieval
; } const properties = data.properties; const queryProps : SubContentQueryProps = { nodeType: properties['j:type'] as string, startNode: properties['j:startNode'] as Node, filter: properties['j:filter'] as Node[], maxItems: properties.maxItems as string, sortCriteria: properties['j:criteria'] as string, sortDirection: properties['j:sortDirection'] as string, locale: locale as string }; return (

{properties['jcr:title'] as string}

); };