Skip to content

Commit 4bb14fa

Browse files
authored
Merge pull request #80 from 4site-interactive-studios/bridger
Bridger
2 parents 6f6fb04 + 200a71f commit 4bb14fa

6 files changed

Lines changed: 165 additions & 9 deletions

File tree

dist/engrid.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*
2020
* ENGRID PAGE TEMPLATE ASSETS
2121
*
22-
* Date: Thursday, November 13, 2025 @ 00:28:58 ET
23-
* By: fernando
22+
* Date: Thursday, November 13, 2025 @ 08:00:35 ET
23+
* By: michael
2424
* ENGrid styles: v0.23.0
2525
* ENGrid scripts: v0.23.2
2626
*

dist/engrid.js

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*
1818
* ENGRID PAGE TEMPLATE ASSETS
1919
*
20-
* Date: Thursday, November 13, 2025 @ 00:28:58 ET
21-
* By: fernando
20+
* Date: Thursday, November 13, 2025 @ 08:00:35 ET
21+
* By: michael
2222
* ENGrid styles: v0.23.0
2323
* ENGrid scripts: v0.23.2
2424
*
@@ -26967,6 +26967,71 @@ class AddDAF {
2696726967
});
2696826968
}
2696926969

26970+
}
26971+
;// CONCATENATED MODULE: ./src/scripts/Bridger.ts
26972+
26973+
class Bridger {
26974+
constructor() {
26975+
_defineProperty(this, "endpoint", "https://wwfusprdenbridgercheckeus1.azurewebsites.net/api/createsearch");
26976+
26977+
_defineProperty(this, "key", "-CDxXc3SdzG6a_LLJGKA_p3qJMnZnnsH3DLDGeK97nwXAzFuFmfh5g==");
26978+
26979+
_defineProperty(this, "bridgerAmountThreshold", window.BridgerAmountThreshold || 500);
26980+
26981+
if (!this.shouldRun()) return;
26982+
this.createBridgerSearchRecord();
26983+
}
26984+
26985+
shouldRun() {
26986+
return window.pageJson.giftProcess && window.pageJson.amount >= this.bridgerAmountThreshold && window.pageJson.currency === "USD";
26987+
}
26988+
26989+
createBridgerSearchRecord() {
26990+
this.sendApiRequest().then(data => {//console.log(data);
26991+
});
26992+
}
26993+
26994+
async sendApiRequest() {
26995+
let data = null;
26996+
26997+
try {
26998+
const body = JSON.stringify({
26999+
firstName: this.getUserData("firstName"),
27000+
lastName: this.getUserData("lastName"),
27001+
address1: `${this.getUserData("address1")} ${this.getUserData("address2")}`,
27002+
city: this.getUserData("city"),
27003+
country: this.getUserData("country"),
27004+
postalCode: this.getUserData("zipCode")
27005+
});
27006+
const response = await fetch(this.endpoint, {
27007+
method: "POST",
27008+
headers: {
27009+
"Content-Type": "application/json",
27010+
"x-functions-key": this.key
27011+
},
27012+
body: body
27013+
});
27014+
27015+
if (response.ok) {
27016+
data = await response.json();
27017+
} else {
27018+
console.log("API request failed");
27019+
}
27020+
} catch (error) {
27021+
console.log("API request failed");
27022+
}
27023+
27024+
return data;
27025+
}
27026+
27027+
getUserData(property) {
27028+
if (!window.userData || !window.userData[property] || window.userData[property].startsWith("{")) {
27029+
return "";
27030+
}
27031+
27032+
return window.userData[property];
27033+
}
27034+
2697027035
}
2697127036
;// CONCATENATED MODULE: ./src/index.ts
2697227037
// Uses ENGrid via NPM
@@ -26987,6 +27052,7 @@ class AddDAF {
2698727052

2698827053

2698927054

27055+
2699027056
const options = {
2699127057
AutoYear: true,
2699227058
applePay: false,
@@ -27155,6 +27221,8 @@ const options = {
2715527221

2715627222
unsubscribeAllRadio.closest(".en__field")?.classList.add("hide");
2715727223
}
27224+
27225+
new Bridger();
2715827226
},
2715927227
onResize: () => console.log("Starter Theme Window Resized"),
2716027228
onSubmit: () => {

dist/engrid.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/engrid.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { AnnualLimit } from "./scripts/annual-limit";
2222
import { OnLoadModal } from "./scripts/on-load-modal";
2323
import MultistepForm from "./scripts/multistep-form";
2424
import { AddDAF } from "./scripts/add-daf";
25+
import { Bridger } from "./scripts/Bridger";
2526

2627
const options: Options = {
2728
AutoYear: true,
@@ -217,6 +218,7 @@ const options: Options = {
217218
// Hide the unsubscribe all radio button
218219
unsubscribeAllRadio.closest(".en__field")?.classList.add("hide");
219220
}
221+
new Bridger();
220222
},
221223
onResize: () => console.log("Starter Theme Window Resized"),
222224

src/scripts/Bridger.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
declare global {
2+
interface Window {
3+
userData: Record<string, string>;
4+
pageJson: {
5+
giftProcess: boolean;
6+
amount: number;
7+
currency: string;
8+
};
9+
BridgerAmountThreshold: number;
10+
}
11+
}
12+
13+
export class Bridger {
14+
private endpoint: string =
15+
"https://wwfusprdenbridgercheckeus1.azurewebsites.net/api/createsearch";
16+
private key: string =
17+
"-CDxXc3SdzG6a_LLJGKA_p3qJMnZnnsH3DLDGeK97nwXAzFuFmfh5g==";
18+
private bridgerAmountThreshold: number = window.BridgerAmountThreshold || 500;
19+
20+
constructor() {
21+
if (!this.shouldRun()) return;
22+
this.createBridgerSearchRecord();
23+
}
24+
25+
private shouldRun(): boolean {
26+
return (
27+
window.pageJson.giftProcess &&
28+
window.pageJson.amount >= this.bridgerAmountThreshold &&
29+
window.pageJson.currency === "USD"
30+
);
31+
}
32+
33+
private createBridgerSearchRecord() {
34+
this.sendApiRequest().then((data) => {
35+
//console.log(data);
36+
});
37+
}
38+
39+
private async sendApiRequest() {
40+
let data = null;
41+
42+
try {
43+
const body = JSON.stringify({
44+
firstName: this.getUserData("firstName"),
45+
lastName: this.getUserData("lastName"),
46+
address1: `${this.getUserData("address1")} ${this.getUserData(
47+
"address2"
48+
)}`,
49+
city: this.getUserData("city"),
50+
country: this.getUserData("country"),
51+
postalCode: this.getUserData("zipCode"),
52+
});
53+
54+
const response = await fetch(this.endpoint, {
55+
method: "POST",
56+
headers: {
57+
"Content-Type": "application/json",
58+
"x-functions-key": this.key,
59+
},
60+
body: body,
61+
});
62+
63+
if (response.ok) {
64+
data = await response.json();
65+
} else {
66+
console.log("API request failed");
67+
}
68+
} catch (error) {
69+
console.log("API request failed");
70+
}
71+
72+
return data;
73+
}
74+
75+
private getUserData(property: string) {
76+
if (
77+
!window.userData ||
78+
!window.userData[property] ||
79+
window.userData[property].startsWith("{")
80+
) {
81+
return "";
82+
}
83+
84+
return window.userData[property];
85+
}
86+
}

0 commit comments

Comments
 (0)