Skip to content

Commit 80762a7

Browse files
committed
fix: minor fixes
1 parent b2e0fdf commit 80762a7

6 files changed

Lines changed: 84 additions & 19 deletions

File tree

app/(landing)/about/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const AboutPage = () => {
2424
<Timeline />
2525
<OurTeam />
2626
<Partners />
27-
<TestimonialsSection testimonials={testimonials} />
2827
</div>
28+
<TestimonialsSection testimonials={testimonials} />
2929
</section>
3030
);
3131
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { NextRequest, NextResponse } from 'next/server';
2+
3+
export async function POST(request: NextRequest) {
4+
try {
5+
const body = await request.json();
6+
7+
const backendUrl =
8+
process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api';
9+
10+
const response = await fetch(`${backendUrl}/waitlist/subscribe`, {
11+
method: 'POST',
12+
headers: {
13+
'Content-Type': 'application/json',
14+
15+
...(request.headers.get('user-agent') && {
16+
'User-Agent': request.headers.get('user-agent')!,
17+
}),
18+
},
19+
body: JSON.stringify(body),
20+
});
21+
22+
if (!response.ok) {
23+
const errorData = await response.json().catch(() => ({}));
24+
return NextResponse.json(
25+
{
26+
message: errorData.message || 'Failed to subscribe to waitlist',
27+
status: response.status,
28+
},
29+
{ status: response.status }
30+
);
31+
}
32+
33+
const data = await response.json();
34+
return NextResponse.json(data, { status: 200 });
35+
} catch {
36+
return NextResponse.json(
37+
{
38+
message: 'Internal server error',
39+
status: 500,
40+
},
41+
{ status: 500 }
42+
);
43+
}
44+
}

app/api/waitlist/subscribe/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export async function POST(request: NextRequest) {
77
const backendUrl =
88
process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api';
99

10-
const response = await fetch(`${backendUrl}/waitlist/subscribe`, {
10+
const response = await fetch(`${backendUrl}/newsletter/subscribe`, {
1111
method: 'POST',
1212
headers: {
1313
'Content-Type': 'application/json',

components/overview/Newsletter.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { BoundlessButton } from '../buttons';
2525
import { Input } from '../ui/input';
2626
import gsap from 'gsap';
2727
import { useGSAP } from '@gsap/react';
28-
import { addToWaitlist } from '@/lib/api/waitlist';
28+
import { newsletterSubscribe } from '@/lib/api/waitlist';
2929
import { Button } from '../ui/button';
3030

3131
const formSchema = z.object({
@@ -84,18 +84,9 @@ const Newsletter = ({
8484
setIsSubmitting(true);
8585

8686
try {
87-
// Split name into firstName and lastName, handling edge cases
88-
const nameParts = values.name
89-
.trim()
90-
.split(' ')
91-
.filter(part => part.length > 0);
92-
const firstName = nameParts[0] || '';
93-
const lastName = nameParts.slice(1).join(' ') || '';
94-
95-
await addToWaitlist({
87+
await newsletterSubscribe({
9688
email: values.email,
97-
firstName,
98-
lastName,
89+
name: values.name,
9990
});
10091
} catch {
10192
setError('Failed to submit form. Please try again.');

components/testimonials/TestimonialsSection.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { BoundlessButton } from '../buttons';
77
import { gsap } from 'gsap';
88
import TestimonialCard from './TestimonialCard';
99
import Image from 'next/image';
10+
import Newsletter from '../overview/Newsletter';
1011

1112
type TestimonialsWallProps = {
1213
testimonials: Testimonial[];
@@ -19,7 +20,7 @@ export default function TestimonialsSection({
1920
const columnRefs = useRef<HTMLDivElement[]>([]);
2021
const animations = useRef<gsap.core.Tween[]>([]);
2122
const [numColumns, setNumColumns] = useState<number>(4);
22-
23+
const [open, setOpen] = useState(false);
2324
useEffect(() => {
2425
animations.current.forEach(anim => anim.kill());
2526
animations.current = [];
@@ -48,10 +49,16 @@ export default function TestimonialsSection({
4849
});
4950
wrapper.appendChild(cloneContainer);
5051

51-
gsap.set(wrapper, { y: 0, force3D: true, willChange: 'transform' });
52+
const isEvenColumn = index % 2 === 0;
53+
const initialY = isEvenColumn ? 0 : -totalHeight;
54+
gsap.set(wrapper, {
55+
y: initialY,
56+
force3D: true,
57+
willChange: 'transform',
58+
});
5259

5360
const anim = gsap.to(wrapper, {
54-
y: -totalHeight,
61+
y: isEvenColumn ? -totalHeight : 0,
5562
duration: 60,
5663
ease: 'none',
5764
repeat: -1,
@@ -205,7 +212,7 @@ export default function TestimonialsSection({
205212
</div>
206213
</div>
207214

208-
<div className='absolute lg:bottom-[60px] bottom-14 lg:mt-0 mt-20 left-1/2 -translate-x-1/2 md:max-h-[212px] w-[90%] max-w-6xl bg-primary rounded-xl shadow-lg p-8 md:p-12 text-black z-40'>
215+
<div className='absolute lg:bottom-[60px] bottom-14 lg:mt-0 mt-20 left-1/2 -translate-x-1/2 md:max-h-[212px] w-full max-w-[90vw] bg-primary rounded-xl shadow-lg p-8 md:p-12 text-black z-40'>
209216
<div className='flex flex-col md:flex-row items-center md:justify-between gap-6'>
210217
<div>
211218
<h2 className='text-3xl lg:text-5xl font-medium tracking-[-1.92px] leading-[100%] md:text-left text-center mb-2'>
@@ -233,6 +240,7 @@ export default function TestimonialsSection({
233240
fullWidth
234241
className='bg-transparent border border-black'
235242
aria-label='Subscribe for updates'
243+
onClick={() => setOpen(true)}
236244
>
237245
Subscribe for Updates
238246
</BoundlessButton>
@@ -242,6 +250,7 @@ export default function TestimonialsSection({
242250
</div>
243251
</div>
244252
</div>
253+
<Newsletter open={open} onOpenChange={setOpen} />
245254
</section>
246255
);
247256
}

lib/api/waitlist.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ type AddToWaitlistRequest = {
77
tags?: string[];
88
};
99

10+
type NewsletterSubscribeRequest = {
11+
email: string;
12+
name: string;
13+
};
14+
1015
export const addToWaitlist = async (data: AddToWaitlistRequest) => {
11-
// Use the local Next.js API route instead of external backend
1216
const res = await fetch('/api/waitlist/subscribe', {
1317
method: 'POST',
1418
headers: {
@@ -24,3 +28,20 @@ export const addToWaitlist = async (data: AddToWaitlistRequest) => {
2428

2529
return res.json();
2630
};
31+
32+
export const newsletterSubscribe = async (data: NewsletterSubscribeRequest) => {
33+
const res = await fetch('/api/newsletter/subscribe', {
34+
method: 'POST',
35+
headers: {
36+
'Content-Type': 'application/json',
37+
},
38+
body: JSON.stringify(data),
39+
});
40+
41+
if (!res.ok) {
42+
const errorData = await res.json().catch(() => ({}));
43+
throw new Error(errorData.message || 'Failed to subscribe to newsletter');
44+
}
45+
46+
return res.json();
47+
};

0 commit comments

Comments
 (0)