import { DateTime } from 'luxon' ; import { PropsWithChildren } from 'react' ; import { IProject } from './IProject' ; import { CommonRows } from '../common/CommonRow' ; import { IRow } from '../common/IRow' ; import Util from '../common/Util' ; import { EmptyRowCol } from '../common' ; export default function ProjectRow ( { payload } ) { return ( < EmptyRowCol > { payload . list . map ( ( item , index ) => { return < CommonRows key = { index . toString ( ) } payload = { serialize ( item ) } index = { index } / > ; } ) } < /EmptyRowCol>); } function serialize ( payload ) { const DATE_FORMAT = Util . LUXON_DATE_FORMAT ; const startedAt = DateTime . fromFormat ( payload . startedAt , DATE_FORMAT . YYYY_LL ) . toFormat ( DATE_FORMAT . YYYY_DOT_LL ) ; const title = ( ( ) => { if ( payload . endedAt ) { const endedAt = DateTime . fromFormat ( payload . endedAt , DATE_FORMAT . YYYY_LL ) . toFormat ( DATE_FORMAT . YYYY_DOT_LL ) ; return `${ startedAt } ~ ${ endedAt }` ; } return `${ startedAt } ~` ; } ) ( ) ; return { left : { title , } , right : { title : payload . title , subTitle : payload . where , descriptions : payload . descriptions , } , } ; }