Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions src/Form/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export const Form = () => {
twitter: { label: 'Twitter' },
qualifications: { label: 'Qualifications' },
addGPTW: { label: 'Add GPTW', type: 'checkbox' },
holidayTheme: {
label: 'Holiday Theme',
type: 'select',
options: 'holidayThemes',
},
};

let formInputs = {
Expand All @@ -35,6 +40,7 @@ export const Form = () => {
email: { text: '', order: 7 },
twitter: { text: '', order: 8 },
addGPTW: { text: '', order: 9 },
holidayTheme: { text: '', order: 10 },
};

var profile = useSelector((state) => {
Expand All @@ -45,7 +51,13 @@ export const Form = () => {
dispatch(updateProfile({ name, value }));
};

const inputHtml = (inputName, inputVal, placeholder, type = 'text') => {
const inputHtml = (
inputName,
inputVal,
placeholder,
type = 'text',
options = null
) => {
if (type === 'checkbox') {
return (
<input
Expand All @@ -57,6 +69,25 @@ export const Form = () => {
/>
);
}
if (type === 'select' && options) {
const optionsData = constants[options];
return (
<div className="select">
<select
id={`input-${inputName}`}
value={inputVal || 'none'}
onChange={(e) => handleChange(inputName, e.target.value)}
style={{ width: '300px' }}
>
{Object.entries(optionsData).map(([key, theme]) => (
<option key={key} value={key}>
{theme.label}
</option>
))}
</select>
</div>
);
}
return (
<input
id={`input-${inputName}`}
Expand All @@ -76,7 +107,12 @@ export const Form = () => {
.map((obj) => ({ key: obj[0], ...omit(obj[1], 'order') }))
.map((inputObj) => {
const inputName = inputObj.key;
const { label, type = 'text', required = false } = labels[inputName];
const {
label,
type = 'text',
required = false,
options,
} = labels[inputName];
return (
<div className="field is-horizontal" key={inputName}>
<div className="field-label is-normal">
Expand All @@ -98,7 +134,8 @@ export const Form = () => {
inputName,
values[inputName],
placeholders[inputName],
type
type,
options
)}
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/RepliesAndForwards/RepliesAndForwards.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import constants from '../constants';
import { parseMobile } from '../util';
const brandInfo = constants.brandInfo;
const holidayThemes = constants.holidayThemes;

const RepliesAndForwards = (props) => {
const {
Expand All @@ -15,7 +16,10 @@ const RepliesAndForwards = (props) => {
brandName,
brandLink,
brandLinkName,
holidayTheme,
} = props;

const theme = holidayThemes[holidayTheme] || holidayThemes.none;
const styleObj = {
color: 'black',
fontFamily: 'Helvetica, Arial, sans-serif',
Expand All @@ -29,8 +33,10 @@ const RepliesAndForwards = (props) => {
<br />
<br />
<b>
{theme.prefix}
{name}&nbsp;{pronounOptional}|&nbsp;{brandName}
{titleOptional}
{theme.suffix}
</b>
<br />
<b>M</b>&nbsp;
Expand Down
6 changes: 6 additions & 0 deletions src/Signature/Signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import constants from '../constants';
import { parseMobile } from '../util';

const brandInfo = constants.brandInfo;
const holidayThemes = constants.holidayThemes;

const Signature = (props) => {
const {
Expand All @@ -17,8 +18,11 @@ const Signature = (props) => {
brandLink,
brandLinkName,
addGPTW,
holidayTheme,
} = props;

const theme = holidayThemes[holidayTheme] || holidayThemes.none;

const titleElement = title ? (
<>
<br />
Expand Down Expand Up @@ -60,8 +64,10 @@ const Signature = (props) => {
<div style={{ height: '15px', lineHeight: '15px' }}>&nbsp;</div>
<p>
<b>
{theme.prefix}
{name}
{pronounOptional}
{theme.suffix}
</b>
{titleElement}
{qualificationsElemenent}
Expand Down
2 changes: 2 additions & 0 deletions src/SignatureContainer/SignatureContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const SignatureContainer = (props) => {
brandLinkName,
brandAnimatedLogo,
addGPTW,
holidayTheme,
} = profile;

const placeholders = constants.placeholders;
Expand All @@ -64,6 +65,7 @@ const SignatureContainer = (props) => {
),
addGPTW,
brandGPTWLogo,
holidayTheme: holidayTheme || 'none',
...assignPlaceholders(
{ brandLogo, brandName, brandLink, brandLinkName, brandAnimatedLogo },
brandInfo
Expand Down
9 changes: 9 additions & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ const constants = {
default: {
countryCode: '+61',
},

holidayThemes: {
none: { label: 'None', prefix: '', suffix: '' },
christmas: { label: 'Christmas', prefix: '🎄 ', suffix: ' ❄️' },
halloween: { label: 'Halloween', prefix: '🎃 ', suffix: ' 👻' },
easter: { label: 'Easter', prefix: '🐰 ', suffix: ' 🥚' },
valentines: { label: "Valentine's Day", prefix: '❤️ ', suffix: ' 💕' },
newYear: { label: 'New Year', prefix: '🎉 ', suffix: ' ✨' },
},
};

export default constants;
9 changes: 7 additions & 2 deletions src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from 'react-phone-number-input';

const brandInfo = constants.brandInfo;
const holidayThemes = constants.holidayThemes;

const multiSplice = (toAddIndexes, val, array) =>
toAddIndexes.forEach((index) => array.splice(index, 0, val));
Expand Down Expand Up @@ -73,14 +74,16 @@ export const copySignatureText = (props) => {
isSupport,
supportHotline,
supportEmail,
holidayTheme,
} = props;
const theme = holidayThemes[holidayTheme] || holidayThemes.none;
const pronounOptional = pronoun ? ` (${pronoun})` : '';
const mobileText = parseMobile(mobile).replace(/&nbsp;/g, ' ');

const textArr = [
'--',
'',
`${name ? name : null}${pronounOptional}`,
`${theme.prefix}${name ? name : null}${pronounOptional}${theme.suffix}`,
brandInfo.brandName,
title ? title : null,
qualifications ? `${qualifications}` : null,
Expand Down Expand Up @@ -114,14 +117,16 @@ export const copyRepliesAndForwardsText = (props) => {
isSupport,
supportHotline,
supportEmail,
holidayTheme,
} = props;
const theme = holidayThemes[holidayTheme] || holidayThemes.none;
const mobileText = parseMobile(mobile).replace(/&nbsp;/g, ' ');

const titleOptional = title ? ` | ${title}` : '';
const pronounOptional = pronoun ? ` (${pronoun})` : '';
const textArr = [
'--',
`${name}${pronounOptional} | ${brandInfo.brandName}${titleOptional}`,
`${theme.prefix}${name}${pronounOptional} | ${brandInfo.brandName}${titleOptional}${theme.suffix}`,
`M ${mobileText} | E ${email}${twitter ? ` | T ${twitter}` : ''} | W ${
brandInfo.brandLinkName
}`,
Expand Down
Loading