Skip to content

Commit d4b9ad7

Browse files
committed
refactor(contact): remove SPA behavior, embed in landing page
1 parent c5739c8 commit d4b9ad7

File tree

8 files changed

+167
-187
lines changed

8 files changed

+167
-187
lines changed

src/App.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import NotFound from "./pages/NotFound";
99
import SolarPanels from "./pages/SolarPanels";
1010
import HybridInverters from "./pages/HybridInverters";
1111
import BatteryStorage from "./pages/BatteryStorage";
12-
import ContactUs from "./pages/ContactUs";
1312
import PrivacyPolicy from "./pages/PrivacyPolicy";
1413
import TermsOfService from "./pages/TermsOfService";
1514
import { ThemeProvider } from "./contexts/ThemeContext";
@@ -28,7 +27,6 @@ const App = () => (
2827
<Route path="/solar-panels" element={<SolarPanels />} />
2928
<Route path="/hybrid-inverters" element={<HybridInverters />} />
3029
<Route path="/battery-storage" element={<BatteryStorage />} />
31-
<Route path="/contact" element={<ContactUs />} />
3230
<Route path="/privacy-policy" element={<PrivacyPolicy />} />
3331
<Route path="/terms-of-service" element={<TermsOfService />} />
3432
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}

src/components/ContactSection.tsx

Lines changed: 51 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,59 @@
11

2-
import React from "react";
3-
import { Button } from "@/components/ui/button";
4-
import { Card, CardContent } from "@/components/ui/card";
2+
import React, { useEffect } from "react";
3+
4+
declare global {
5+
interface Window {
6+
Tally?: {
7+
loadEmbeds: () => void;
8+
};
9+
}
10+
}
511

612
const ContactSection = () => {
13+
useEffect(() => {
14+
const scriptUrl = "https://tally.so/widgets/embed.js";
15+
if (!document.querySelector(`script[src="${scriptUrl}"]`)) {
16+
const script = document.createElement("script");
17+
script.src = scriptUrl;
18+
script.onload = () => {
19+
if (typeof window.Tally !== "undefined") {
20+
window.Tally!.loadEmbeds();
21+
} else {
22+
const iframes = document.querySelectorAll("iframe[data-tally-src]:not([src])") as NodeListOf<HTMLIFrameElement>;
23+
iframes.forEach((iframe) => {
24+
iframe.src = iframe.dataset.tallySrc!;
25+
});
26+
}
27+
};
28+
script.onerror = () => {
29+
const iframes = document.querySelectorAll("iframe[data-tally-src]:not([src])") as NodeListOf<HTMLIFrameElement>;
30+
iframes.forEach((iframe) => {
31+
iframe.src = iframe.dataset.tallySrc!;
32+
});
33+
};
34+
document.body.appendChild(script);
35+
} else {
36+
if (typeof window.Tally !== "undefined") {
37+
window.Tally!.loadEmbeds();
38+
} else {
39+
const iframes = document.querySelectorAll("iframe[data-tally-src]:not([src])") as NodeListOf<HTMLIFrameElement>;
40+
iframes.forEach((iframe) => {
41+
iframe.src = iframe.dataset.tallySrc!;
42+
});
43+
}
44+
}
45+
}, []);
46+
747
return (
8-
<section id="contact" className="solar-section bg-solar-blue text-white">
48+
<section id="contact" className="solar-section bg-gray-50 dark:bg-gray-900">
949
<div className="solar-container">
10-
<div className="text-center max-w-3xl mx-auto mb-16">
11-
<h2 className="text-3xl md:text-4xl font-bold mb-6 md:mb-10">Visit Our Store</h2>
12-
<p className="text-lg text-gray-100">
13-
Come see our products in person and speak with our solar experts.
14-
We're here to help you find the perfect solar solution for your needs.
15-
</p>
16-
</div>
17-
18-
<div className="grid md:grid-cols-2 gap-8 items-center">
19-
<Card className="bg-white text-solar-blue overflow-hidden">
20-
<CardContent className="p-0">
21-
<div className="aspect-[16/9]">
22-
{/* Replace with actual map or embedded Google Maps */}
23-
<iframe
24-
src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3022.215976753674!2d-73.9878584!3d40.7484405!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c259a9b3117469%3A0xd134e199a405a163!2sEmpire%20State%20Building!5e0!3m2!1sen!2sus!4v1590619166098!5m2!1sen!2sus"
25-
width="100%"
26-
height="100%"
27-
style={{ border: 0 }}
28-
allowFullScreen
29-
loading="lazy"
30-
title="Store Location"
31-
></iframe>
32-
</div>
33-
</CardContent>
34-
</Card>
35-
36-
<div className="bg-white text-solar-blue rounded-lg p-8">
37-
<h3 className="text-2xl font-bold mb-6">Store Information</h3>
38-
<div className="space-y-4">
39-
{/* <div>
40-
<p className="font-semibold">Address:</p>
41-
<p>123 Solar Street, Greenville, CA 94536</p>
42-
</div>
43-
<div>
44-
<p className="font-semibold">Hours:</p>
45-
<p>Monday - Friday: 9:00 AM - 6:00 PM</p>
46-
<p>Saturday: 10:00 AM - 4:00 PM</p>
47-
<p>Sunday: Closed</p>
48-
</div>
49-
<div>
50-
<p className="font-semibold">Phone:</p>
51-
<p>(555) 123-4567</p>
52-
</div> */}
53-
<div>
54-
<p className="font-semibold">Email:</p>
55-
<p>contact@solveenergy.com</p>
56-
</div>
57-
<div className="pt-4">
58-
<Button className="bg-solar-gold hover:bg-opacity-90 text-solar-blue w-full">
59-
Get Directions
60-
</Button>
61-
</div>
62-
</div>
63-
</div>
64-
</div>
50+
<iframe
51+
data-tally-src="https://tally.so/embed/QKoBLk?alignLeft=1&transparentBackground=1&dynamicHeight=1"
52+
loading="lazy"
53+
width="100%"
54+
height="1643"
55+
title="Contact us"
56+
></iframe>
6557
</div>
6658
</section>
6759
);

src/components/Footer.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
import React from "react";
22
import { Sun } from "lucide-react";
33
import { Link } from "react-router-dom";
4+
import { off } from "process";
45

56
const Footer = () => {
7+
const scrollToSection = (sectionId: string) => {
8+
const section = document.getElementById(sectionId);
9+
if (section) {
10+
const offsetTop = section.offsetTop - 64; // 64px extra padding
11+
window.scrollTo({
12+
top: offsetTop,
13+
behavior: 'smooth'
14+
});
15+
// Update URL hash
16+
window.history.replaceState(null, '', `#${sectionId}`);
17+
}
18+
};
19+
620
return (
721
<footer className="bg-solar-blue text-white py-12">
822
<div className="container mx-auto px-4">
@@ -39,7 +53,18 @@ const Footer = () => {
3953

4054
{/* Contact Info & Social */}
4155
<div className="space-y-4">
42-
<Link to="/contact" className="text-gray-300 hover:text-solar-gold transition-colors">Contact Us</Link>
56+
<Link
57+
to="/#contact"
58+
className="text-gray-300 hover:text-solar-gold transition-colors"
59+
onClick={(e) => {
60+
if (window.location.pathname === '/') {
61+
e.preventDefault();
62+
scrollToSection("contact");
63+
}
64+
}}
65+
>
66+
Contact Us
67+
</Link>
4368
<div className="space-y-3">
4469
<a className="text-gray-300 hover:text-solar-gold transition-colors" href="mailto:contact@solvenergy.in">contact@solvenergy.in</a>
4570
<div className="flex gap-4">

src/components/HeroSection.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ const HeroSection = () => {
1919
const scrollToNextSection = () => {
2020
const nextSection = document.getElementById('calculator');
2121
if (nextSection) {
22-
nextSection.scrollIntoView({ behavior: 'smooth' });
22+
const offsetTop = nextSection.offsetTop - 64; // 64px extra padding
23+
window.scrollTo({
24+
top: offsetTop,
25+
behavior: 'smooth'
26+
});
27+
// Update URL hash
28+
window.history.replaceState(null, '', '#calculator');
2329
}
2430
};
2531

src/components/LoadCalculatorSection.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ const LoadCalculatorSection = () => {
2929
hours: 1
3030
});
3131

32+
const scrollToSection = (sectionId: string) => {
33+
const section = document.getElementById(sectionId);
34+
if (section) {
35+
const offsetTop = section.offsetTop - 64; // 64px extra padding
36+
window.scrollTo({
37+
top: offsetTop,
38+
behavior: 'smooth'
39+
});
40+
// Update URL hash
41+
window.history.replaceState(null, '', `#${sectionId}`);
42+
}
43+
};
44+
3245
const commonAppliances = [
3346
{ name: 'LED Bulb (9W)', wattage: 9 },
3447
{ name: 'CFL Bulb (18W)', wattage: 18 },
@@ -307,7 +320,16 @@ const LoadCalculatorSection = () => {
307320
</CardContent>
308321
</Card>
309322

310-
<Link to="/contact" className="block">
323+
<Link
324+
to="/#contact"
325+
className="block"
326+
onClick={(e) => {
327+
if (window.location.pathname === '/') {
328+
e.preventDefault();
329+
scrollToSection("contact");
330+
}
331+
}}
332+
>
311333
<Button className="w-full bg-solar-gold hover:bg-opacity-90 text-solar-blue font-semibold text-xl py-8 transition-transform hover:scale-105 duration-300">
312334
Contact us for quotations!
313335
</Button>

src/components/Navbar.tsx

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,22 @@ const Navbar = () => {
3333
return () => window.removeEventListener("scroll", handleScroll);
3434
}, []);
3535

36+
const scrollToTop = () => {
37+
window.scrollTo({ top: 0, behavior: 'smooth' });
38+
// Update URL to remove hash
39+
window.history.replaceState(null, '', window.location.pathname);
40+
};
41+
3642
const scrollToSection = (sectionId: string) => {
3743
const section = document.getElementById(sectionId);
3844
if (section) {
39-
section.scrollIntoView({ behavior: 'smooth' });
45+
const offsetTop = section.offsetTop - 64; // 64px extra padding
46+
window.scrollTo({
47+
top: offsetTop,
48+
behavior: 'smooth'
49+
});
50+
// Update URL hash
51+
window.history.replaceState(null, '', `#${sectionId}`);
4052
}
4153
};
4254

@@ -50,7 +62,15 @@ const Navbar = () => {
5062
>
5163
<div className="container mx-auto px-4 flex justify-between items-center">
5264
<div className="flex items-center">
53-
<Link to="/">
65+
<Link
66+
to="/"
67+
onClick={(e) => {
68+
if (window.location.pathname === '/') {
69+
e.preventDefault();
70+
scrollToTop();
71+
}
72+
}}
73+
>
5474
<svg width="192" height="108" viewBox="0 0 1920 1080" version="1.1" id="logo" xmlns="http://www.w3.org/2000/svg">
5575
<g id="g2" transform="translate(-6.0890488)">
5676
<path className="stroke-[#000000] dark:stroke-[#ffffff] dark:fill-[#ffffff]" aria-label="S" d="m 179.83784,471.73318 h 99.49886 v 11.43469 h -99.49886 q -10.58136,0 -18.0907,7.50935 -7.50935,7.50934 -7.50935,18.0907 0,10.58135 7.50935,18.0907 7.50934,7.33868 18.0907,7.33868 h 62.46412 q 15.36003,0 26.11206,10.92269 10.92268,10.75202 10.92268,26.11205 0,15.36003 -10.92268,26.28272 -10.75203,10.75202 -26.11206,10.75202 H 142.8031 V 596.8321 h 99.49886 q 10.58136,0 18.09071,-7.50935 7.50934,-7.50935 7.50934,-18.09071 0,-10.58135 -7.50934,-17.92003 -7.50935,-7.50935 -18.09071,-7.50935 h -62.46412 q -15.36003,0 -26.28272,-10.75202 -10.75202,-10.92269 -10.75202,-26.28272 0,-15.36003 10.75202,-26.11205 10.92269,-10.92269 26.28272,-10.92269 z" />
@@ -154,7 +174,11 @@ const Navbar = () => {
154174
<div className="container mx-auto px-4 flex flex-col space-y-4">
155175
<Link
156176
to="/#calculator"
157-
onClick={() => {
177+
onClick={(e) => {
178+
if (window.location.pathname === '/') {
179+
e.preventDefault();
180+
scrollToSection("calculator");
181+
}
158182
setMobileMenuOpen(false);
159183
}}
160184
className="text-solar-blue dark:text-white font-medium py-2 transition-colors text-left"
@@ -188,9 +212,15 @@ const Navbar = () => {
188212
</Link>
189213
</div>
190214
<Link
191-
to="/contact"
215+
to="/#contact"
216+
onClick={(e) => {
217+
if (window.location.pathname === '/') {
218+
e.preventDefault();
219+
scrollToSection("contact");
220+
}
221+
setMobileMenuOpen(false);
222+
}}
192223
className="text-solar-blue dark:text-white font-medium py-2 transition-colors"
193-
onClick={() => setMobileMenuOpen(false)}
194224
>
195225
Contact Us
196226
</Link>

0 commit comments

Comments
 (0)