From 59f0ff9228cd39776d7fa08296442d0abf045693 Mon Sep 17 00:00:00 2001 From: gianantoniopini <63844628+gianantoniopini@users.noreply.github.com> Date: Wed, 4 Nov 2020 13:38:43 +0100 Subject: [PATCH] Issue #314: Added BirthDate field to Profile builder and Castform template --- .../builder/left/sections/Profile.js | 7 ++++++ src/data/demoState.json | 1 + src/data/initialState.json | 1 + src/i18n/locales/en.json | 1 + src/templates/Castform.js | 23 +++++++++++++++++-- src/utils/index.js | 7 ++++-- 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/components/builder/left/sections/Profile.js b/src/components/builder/left/sections/Profile.js index 45be2af4..2c4c9422 100644 --- a/src/components/builder/left/sections/Profile.js +++ b/src/components/builder/left/sections/Profile.js @@ -38,6 +38,13 @@ const Profile = ({ id }) => { path="profile.subtitle" /> + +
{ +const Castform = ({ data, language }) => { + const { t } = useTranslation(); const layout = data.metadata.layout.castform; const Photo = () => @@ -51,6 +54,19 @@ const Castform = ({ data }) => { ); + const BirthDate = () => ( + data.profile.birthDate && ( +
+
+ {t('builder.profile.birthDate')} +
+
+ {formatDate({ date: data.profile.birthDate, language, includeDay: true })} +
+
+ ) + ); + return (
{
{data.profile.heading} - +
+ + +
{layout[0] && diff --git a/src/utils/index.js b/src/utils/index.js index 87e0daa9..273c53d3 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -20,8 +20,11 @@ export const isFileImage = (file) => { return file && acceptedImageTypes.includes(file.type); }; -export const formatDate = ({ date, language = 'en' }) => { - return dayjs(date).locale(language.substr(0, 2)).format('MMMM YYYY'); +export const formatDate = ({ date, language = 'en', includeDay = false }) => { + const monthYearTemplate = 'MMMM YYYY'; + const template = includeDay ? 'DD ' + monthYearTemplate : monthYearTemplate; + + return dayjs(date).locale(language.substr(0, 2)).format(template); }; export const formatDateRange = ({ startDate, endDate, language = 'en' }, t) => {