const replacePlaceholders = (obj: any, parent: any = null, keyInParent: any = null, actionData: any = null) => {
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const value = obj[key];
if (key === 'fillMethod' || key === 'multiIntentData') continue;
if (key === 'items') {
for(let i=0; i<value.length;i++)
{
//Extract intent from placeholder and get actionDataArray
const intent = extractIntent(value[i]);
const actionDataArray = getActionData(intent, intentName);
// Check the fillMethod of the parent object
const fillMethod = obj.fillMethod || 'latest';
if (fillMethod === 'all') {
parent[keyInParent] = actionDataArray.map((actionData) => {
let newItem = JSON.parse(JSON.stringify(value[i]));
replacePlaceholders(newItem, null, null, actionData);
return newItem;
});
} else {
const latestActionData = getLatestActionData(intent, intentName);
const newItem = JSON.parse(JSON.stringify(value[i]));
replacePlaceholders(newItem, null, null, latestActionData);
parent[keyInParent] = [newItem];
}
}
continue;
}
if (typeof value === 'string' && value.startsWith('$')) {
const [intent, field] = value.substr(1).split('.');
if(actionData && actionData['IntentName'] === intent)
{
const fieldValue = actionData[field];
obj[key] = (fieldValue!== undefined && fieldValue!==null) ? fieldValue : null;
} else {
const latestActionData = getLatestActionData(intent, intentName);
const fieldValue = latestActionData[field];
obj[key] = (fieldValue!== undefined && fieldValue!==null) ? fieldValue : null;
}
} else if (Array.isArray(value) || typeof value === 'object') {
replacePlaceholders(value, obj, key, actionData);
}
if(obj.enableStartEndDate === 'true'){
Object.assign(obj.data,this.getStartEndDate(intentConfig.numberOfDays))
delete obj.enableStartEndDate;
}
}
}
};Right Clinic for Skin Whitening Injection in Fort Lauderdale
Skin treatments have evolved significantly in recent years, offering individuals more options to enhance their complexion and overall skin health. Among these, Skin Whitening Injection…