Issue #314: Added BirthDate field to Profile builder and Castform template

This commit is contained in:
gianantoniopini
2020-11-04 13:38:43 +01:00
parent 5bf9d5ae9e
commit 59f0ff9228
6 changed files with 36 additions and 4 deletions

View File

@ -38,6 +38,13 @@ const Profile = ({ id }) => {
path="profile.subtitle" path="profile.subtitle"
/> />
<Input
type="date"
name="birthDate"
label={t('builder.profile.birthDate')}
path="profile.birthDate"
/>
<hr /> <hr />
<Input <Input

View File

@ -190,6 +190,7 @@
"line2": "Brindavan Layout, Subramanyapura,", "line2": "Brindavan Layout, Subramanyapura,",
"pincode": "560061" "pincode": "560061"
}, },
"birthDate": "",
"email": "hello@amruthpillai.com", "email": "hello@amruthpillai.com",
"firstName": "Amruth", "firstName": "Amruth",
"heading": "Profile", "heading": "Profile",

View File

@ -5,6 +5,7 @@
"firstName": "", "firstName": "",
"lastName": "", "lastName": "",
"subtitle": "", "subtitle": "",
"birthDate": "",
"address": { "address": {
"line1": "", "line1": "",
"line2": "", "line2": "",

View File

@ -96,6 +96,7 @@
"photograph": "Photograph", "photograph": "Photograph",
"firstName": "First Name", "firstName": "First Name",
"lastName": "Last Name", "lastName": "Last Name",
"birthDate": "Date of Birth",
"address": { "address": {
"line1": "Address Line 1", "line1": "Address Line 1",
"line2": "Address Line 2", "line2": "Address Line 2",

View File

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { useTranslation } from 'react-i18next';
import PageContext from '../contexts/PageContext'; import PageContext from '../contexts/PageContext';
import AwardsA from './blocks/Awards/AwardsA'; import AwardsA from './blocks/Awards/AwardsA';
import CertificationsA from './blocks/Certifications/CertificationsA'; import CertificationsA from './blocks/Certifications/CertificationsA';
@ -12,6 +13,7 @@ import ProjectsA from './blocks/Projects/ProjectsA';
import ReferencesA from './blocks/References/ReferencesA'; import ReferencesA from './blocks/References/ReferencesA';
import SkillsA from './blocks/Skills/SkillsA'; import SkillsA from './blocks/Skills/SkillsA';
import WorkA from './blocks/Work/WorkA'; import WorkA from './blocks/Work/WorkA';
import { formatDate } from '../utils';
const Blocks = { const Blocks = {
objective: ObjectiveA, objective: ObjectiveA,
@ -26,7 +28,8 @@ const Blocks = {
references: ReferencesA, references: ReferencesA,
}; };
const Castform = ({ data }) => { const Castform = ({ data, language }) => {
const { t } = useTranslation();
const layout = data.metadata.layout.castform; const layout = data.metadata.layout.castform;
const Photo = () => const Photo = () =>
@ -51,6 +54,19 @@ const Castform = ({ data }) => {
</div> </div>
); );
const BirthDate = () => (
data.profile.birthDate && (
<div className="text-xs">
<h6 className="capitalize font-semibold">
{t('builder.profile.birthDate')}
</h6>
<div>
<span>{formatDate({ date: data.profile.birthDate, language, includeDay: true })}</span>
</div>
</div>
)
);
return ( return (
<PageContext.Provider value={{ data, heading: HeadingD }}> <PageContext.Provider value={{ data, heading: HeadingD }}>
<div <div
@ -76,8 +92,11 @@ const Castform = ({ data }) => {
<div> <div>
<HeadingD>{data.profile.heading}</HeadingD> <HeadingD>{data.profile.heading}</HeadingD>
<div className="grid gap-4">
<BirthDate />
<ContactC /> <ContactC />
</div> </div>
</div>
{layout[0] && {layout[0] &&
layout[0].map((x) => { layout[0].map((x) => {

View File

@ -20,8 +20,11 @@ export const isFileImage = (file) => {
return file && acceptedImageTypes.includes(file.type); return file && acceptedImageTypes.includes(file.type);
}; };
export const formatDate = ({ date, language = 'en' }) => { export const formatDate = ({ date, language = 'en', includeDay = false }) => {
return dayjs(date).locale(language.substr(0, 2)).format('MMMM YYYY'); 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) => { export const formatDateRange = ({ startDate, endDate, language = 'en' }, t) => {