Skip to content

Commit 048e96e

Browse files
committed
feat(OUT-2228): implement placeholder replacing
1 parent b8178f7 commit 048e96e

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/app/components/Footer.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { When } from '@/components/hoc/When'
44
import { useAppState } from '@/hooks/useAppState'
55
import { calculateFileSize } from '@/utils/calculateFileSize'
66
import { defaultBannerImagePath } from '@/utils/constants'
7+
import { replaceCustomLabelsWithPlaceholders } from '@/utils/customLabels'
78
import { getFont } from '@/utils/font'
89
import { handleBannerImageUpload } from '@/utils/handleBannerImageUpload'
910
import { ImagePickerUtils } from '@/utils/imagePickerUtils'
@@ -40,8 +41,10 @@ export const Footer = () => {
4041
const handleSave = async () => {
4142
setSaving(true)
4243
//get editor content
43-
const content = appState?.appState.editor?.getHTML() || ''
44-
44+
const content = replaceCustomLabelsWithPlaceholders(
45+
appState?.appState.editor?.getHTML() || '',
46+
appState?.appState.customLabels,
47+
)
4548
let payload = {}
4649
const bgColor = appState?.appState.editorColor || '#ffffff'
4750

@@ -67,7 +70,7 @@ export const Footer = () => {
6770
)
6871
payload = {
6972
backgroundColor: bgColor,
70-
content: content,
73+
content,
7174
bannerImageId: data?.id,
7275
token: appState?.appState.token,
7376
displayTasks: appState?.appState.displayTasks,
@@ -80,7 +83,7 @@ export const Footer = () => {
8083
if (!appState?.appState.bannerImgUrl) {
8184
payload = {
8285
backgroundColor: bgColor,
83-
content: content,
86+
content,
8487
token: appState?.appState.token,
8588
bannerImageId: null,
8689
displayTasks: appState?.appState.displayTasks,

src/utils/customLabels.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,19 @@ export const prepareCustomLabel = (
5555

5656
return result
5757
}
58+
59+
export const replaceCustomLabelsWithPlaceholders = (
60+
content: string,
61+
customLables?: CustomLabels,
62+
) => {
63+
if (!customLables) return content
64+
console.log('xxx content', content)
65+
console.log('xxxcustom', customLables.individualTerm)
66+
67+
// NOTE: Only hardcoded for client as per Client Home requirements. It's highly unlikely we will
68+
// get other patterns since these are customFields
69+
return content.replaceAll(
70+
`{{${customLables.individualTerm}.`,
71+
`{{__client__.`,
72+
)
73+
}

0 commit comments

Comments
 (0)