Skip to content

Commit

Permalink
template replacement fix inside text
Browse files Browse the repository at this point in the history
  • Loading branch information
armintalaie committed Jan 10, 2025
1 parent 5804315 commit 213ce0d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/app/portal/admin/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export async function getAllFormDetails(
formId: bigint,
): Promise<{ rawForm: any; formFields: FormFields; submissions: any[] }> {
try {
console.log("retrieving form details");
const form = await db.forms.findFirst({
where: { id: formId },
});
Expand Down
7 changes: 2 additions & 5 deletions src/components/forms/applications/offerPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function OfferPage({ form, app }: { form: Form; app: any }) {
const lpData = useContext(lpContext);
const cleanedText = replaceTemplateValues(text, {
general: lpData,
app: { ...rest, ...details },
app: { ...rest.applications, ...details },
});

async function handleDecision(decision: "accepted" | "declined") {
Expand Down Expand Up @@ -126,13 +126,10 @@ function replaceTemplateValues(
matches.forEach((match) => {
const key = match.replace("{{", "").replace("}}", "");
const multiKey = key.split(":");

if (multiKey.length > 1) {
const [firstKey, secondKey] = multiKey;
if (Object.keys(app).includes(secondKey)) {
if (app[secondKey] === undefined) {
newText = "";
} else {
if (app[secondKey] !== undefined) {
if (multiKey.length > 2) {
const thirdKey = multiKey[2];
newText = newText.replace(
Expand Down

0 comments on commit 213ce0d

Please sign in to comment.