import moment, { Moment } from 'moment';
import React from 'react';
import * as Text from 'app/shared/components/text/text';
import Parser from 'html-react-parser';
import { Resource } from 'app/shared/components/Resource/Resource';
const mapCollectionToList = (collection: string[]) => {
return collection
.map((item, index) =>
{item});
};
const getDate = (date: Moment) => {
const dayWithSuffix = date.format('Do');
const suffix = dayWithSuffix.replace(/^\d+/, '');
const day = dayWithSuffix.replace(/[a-z]+/, '');
const month = date.format('MMMM');
const year = date.format('YYYY');
return
Update: {day} {suffix} of {month}, {year}
;
};
const getJustReleased = (changelog: string[]) => {
if (changelog.length === 0) {
return null;
}
return <>
Just released
{mapCollectionToList(changelog)}
>;
};
const getIncomingFeatures = (incomingFeatures: string[]) => {
if (incomingFeatures.length === 0) {
return null;
}
return <>
Incoming features
{mapCollectionToList(incomingFeatures)}
>;
};
export interface Props {
releaseDate: string;
title: string;
description: string;
changelog: string[];
incomingFeatures: string[];
footer: string;
openVideo: () => void;
videoLink?: string;
imageUrl?: string;
}
export const WelcomePopupContent = ({
releaseDate,
title,
description,
changelog,
incomingFeatures,
footer,
videoLink,
imageUrl,
openVideo,
} : Props) => {
const getMedia = (imageUrl?: string, videoLink?: string) => {
if (!imageUrl && !videoLink) {
return null;
}
return
{videoLink
?
:

}
;
};
return
{getDate(moment(releaseDate))}
{title}
{Parser(description)}
{getJustReleased(changelog)}
{getIncomingFeatures(incomingFeatures)}
{getMedia(imageUrl, videoLink)}
{footer}
Get Started!
;
};