Skip to content

Commit 9f76c1d

Browse files
committed
added form
1 parent 4b682f8 commit 9f76c1d

File tree

2 files changed

+63
-4
lines changed

2 files changed

+63
-4
lines changed

src/pages/landing-c/top.tsx

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
import { Link } from "@remix-run/react";
1+
import { useNavigate } from "@remix-run/react";
2+
import { Modal } from "components/modal";
23
import { Video, videos } from "components/video/video";
4+
import { useState } from "react";
5+
import { useHubspotForm } from "./use-hubspot-form";
36

47
export function Top({ classes = "" }) {
8+
const navigate = useNavigate();
9+
const { state } = useHubspotForm();
10+
const [open, setOpen] = useState(false);
11+
512
return (
613
<section
714
className={`${classes} grid grid-cols-1 lg:grid-cols-2 gap-12 p-4 @container`}
@@ -31,6 +38,21 @@ export function Top({ classes = "" }) {
3138
investing, and no platform fees — all set up in just minutes.
3239
</p>
3340

41+
{open && (
42+
<Modal
43+
classes="fixed-center z-10 grid text-gray-d4 bg-white sm:w-full w-[90vw] sm:max-w-lg rounded-sm overflow-hidden"
44+
open={open}
45+
onClose={() => setOpen(false)}
46+
>
47+
<div
48+
className="hs-form-frame"
49+
data-region="eu1"
50+
data-form-id="17bb2a2b-322c-4a8c-b8d6-50bb1a59881c"
51+
data-portal-id="24900163"
52+
/>
53+
</Modal>
54+
)}
55+
3456
<div className="grid @md:grid-cols-2 gap-6 mb-6">
3557
<p className="max-lg:border-t-1 max-lg:pt-2 lg:border-r-4 max-lg:text-center text-right border-blue pr-4">
3658
80% of donors cover fees* — keep more of every gift
@@ -46,12 +68,18 @@ export function Top({ classes = "" }) {
4668
</p>
4769
</div>
4870

49-
<Link
50-
to="/donation-calculator"
71+
<button
72+
onClick={() => {
73+
if (state !== "loaded") {
74+
return navigate("/donation-calculator");
75+
}
76+
setOpen(true);
77+
}}
78+
type="button"
5179
className="mt-4 btn btn-blue text-center lg:text-right lg:justify-self-end normal-case rounded-lg py-4 px-8 w-full md:w-auto"
5280
>
5381
See Your Savings - Launch the Calculator
54-
</Link>
82+
</button>
5583

5684
<p className="max-lg:text-center text-right text-sm text-gray mt-2">
5785
"It takes less than a minute — find out how much you're leaving on the
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { useEffect, useState } from "react";
2+
3+
type State = "loading" | "loaded" | "error";
4+
5+
export function useHubspotForm() {
6+
const [state, setState] = useState<State | undefined>();
7+
8+
//biome-ignore lint: no deps
9+
useEffect(() => {
10+
function load() {
11+
if (state === "loading" || state === "loaded") return;
12+
setState("loading");
13+
const script = document.createElement("script");
14+
script.src = "https://js-eu1.hsforms.net/forms/embed/24900163.js";
15+
script.defer = true;
16+
17+
script.onload = () => {
18+
setState("loaded");
19+
};
20+
21+
script.onerror = () => {
22+
setState("error");
23+
};
24+
25+
document.body.appendChild(script);
26+
}
27+
load();
28+
}, []);
29+
30+
return { state };
31+
}

0 commit comments

Comments
 (0)