Skip to content

Commit 11a55d6

Browse files
authored
Merge pull request #63 from UoaWDCC/chris-fixes
chore: white background for sponsor logo
2 parents 146e2dd + dbbc0ea commit 11a55d6

File tree

5 files changed

+88
-99
lines changed

5 files changed

+88
-99
lines changed

src/app/(frontend)/sponsors/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default async function SponsorsPage() {
2323
alt="Bear"
2424
width={450}
2525
height={450}
26+
quality={50}
2627
className="object-contain"
2728
/>
2829
</div>

src/app/api/users/route.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { NextRequest, NextResponse } from 'next/server'
2+
3+
import { createClient } from '@/utils/supabase/server'
4+
5+
export async function POST(req: NextRequest) {
6+
try {
7+
const {
8+
email,
9+
firstName,
10+
lastName,
11+
phoneNumber,
12+
gender,
13+
ethnicity,
14+
universityId,
15+
upi,
16+
areaOfStudy,
17+
yearLevel,
18+
} = await req.json()
19+
const supabase = await createClient()
20+
21+
const { data, error } = await supabase.from('users').insert([
22+
{
23+
email,
24+
first_name: firstName,
25+
last_name: lastName,
26+
phone_number: phoneNumber,
27+
gender,
28+
ethnicity,
29+
university_id: universityId,
30+
upi,
31+
area_of_study: areaOfStudy,
32+
year_level: yearLevel,
33+
},
34+
])
35+
36+
if (error) throw error
37+
38+
return NextResponse.json({ success: true, user: data[0] })
39+
} catch (err) {
40+
console.error('Error creating user:', err)
41+
return NextResponse.json({ success: false, error: 'Failed to create user' }, { status: 500 })
42+
}
43+
}

src/components/EventsCarousel.tsx

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -149,92 +149,6 @@ const EventsCarousel: React.FC<EventsCarouselProps> = ({
149149
)}
150150
</div>
151151
)
152-
153-
return (
154-
<div className={`relative w-full ${className}`}>
155-
{/* Main Image Container */}
156-
<div className="relative h-96 overflow-hidden rounded-lg bg-gray-100">
157-
{images.map((image, index) => (
158-
<div
159-
key={image.id}
160-
className={`absolute inset-0 transition-transform duration-500 ease-in-out ${
161-
index === currentIndex
162-
? 'translate-x-0'
163-
: index < currentIndex
164-
? '-translate-x-full'
165-
: 'translate-x-full'
166-
}`}
167-
>
168-
<Image
169-
src={image.src}
170-
alt={image.alt}
171-
fill
172-
className="object-cover"
173-
priority={index === 0}
174-
/>
175-
176-
{/* Image Overlay with Title and Description */}
177-
{(image.title || image.description) && (
178-
<div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-6">
179-
{image.title && (
180-
<h3 className="text-white text-xl font-bold mb-2">{image.title}</h3>
181-
)}
182-
{image.description && <p className="text-white/90 text-sm">{image.description}</p>}
183-
</div>
184-
)}
185-
</div>
186-
))}
187-
188-
{/* Navigation Arrows */}
189-
{images.length > 1 && (
190-
<>
191-
<Button
192-
variant="ghost"
193-
size="icon"
194-
className="absolute left-4 top-1/2 -translate-y-1/2 bg-black/20 hover:bg-black/40 text-white border-0 rounded-full h-12 w-12"
195-
onClick={goToPrevious}
196-
aria-label="Previous image"
197-
>
198-
<ChevronLeft className="h-6 w-6" />
199-
</Button>
200-
201-
<Button
202-
variant="ghost"
203-
size="icon"
204-
className="absolute right-4 top-1/2 -translate-y-1/2 bg-black/20 hover:bg-black/40 text-white border-0 rounded-full h-12 w-12"
205-
onClick={goToNext}
206-
aria-label="Next image"
207-
>
208-
<ChevronRight className="h-6 w-6" />
209-
</Button>
210-
</>
211-
)}
212-
</div>
213-
214-
{/* Progress Dots */}
215-
{images.length > 1 && (
216-
<div className="flex justify-center space-x-2 mt-4">
217-
{images.map((_, index) => (
218-
<button
219-
key={index}
220-
className={`w-3 h-3 rounded-full transition-all duration-300 ${
221-
index === currentIndex ? 'bg-tansa-blue scale-110' : 'bg-gray-300 hover:bg-gray-400'
222-
}`}
223-
onClick={() => goToSlide(index)}
224-
aria-label={`Go to slide ${index + 1}`}
225-
/>
226-
))}
227-
</div>
228-
)}
229-
230-
{/* Image Counter */}
231-
{images.length > 1 && (
232-
<div className="absolute top-4 right-4 bg-black/50 text-white px-3 py-1 rounded-full text-sm">
233-
{currentIndex + 1} / {images.length}
234-
</div>
235-
)}
236-
</div>
237-
)
238152
}
239153

240154
export default EventsCarousel

src/components/SponsorsList.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,25 @@ export default function SponsorsList({ sponsors }: SponsorsListProps) {
4040
const imageAlt = name || 'Sponsor Logo'
4141

4242
const imageElement = (
43-
<div className="relative group w-full flex justify-center items-center select-none">
44-
<Image src={imageSrc} alt={imageAlt} width={200} height={200} className="rounded" />
45-
43+
<div className="relative group bg-white rounded-lg shadow-sm flex items-center justify-center w-[100px] h-[100px]">
44+
<Image
45+
src={imageSrc}
46+
alt={imageAlt}
47+
width={100}
48+
height={100}
49+
className="object-contain max-w-[80px] max-h-[80px]"
50+
/>
51+
4652
{/* Hover popup */}
4753
{sponsorshipDetails && (
4854
<div className="absolute left-1/2 -translate-x-1/2 bottom-full mb-3 w-60 bg-white text-black p-3 rounded shadow-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 text-center text-sm z-10 select-none pointer-events-none group-hover:pointer-events-auto">
4955
<h3 className="font-bold mb-1">{name}</h3>
5056
<p>{sponsorshipDetails}</p>
5157
</div>
5258
)}
53-
54-
{/* Optional semi-transparent overlay on hover */}
5559
</div>
5660
)
61+
5762

5863
return (
5964
<div key={id} className="flex flex-col items-center justify-center w-full max-w-25">

src/components/registration-form/RegistrationForm.tsx

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,12 @@ function CheckoutForm({ clientSecret }: { clientSecret: string }) {
177177
const handleSubmit = async (event: React.FormEvent) => {
178178
event.preventDefault()
179179

180-
if (!stripe || !elements) {
181-
return
182-
}
180+
if (!stripe || !elements) return
183181

184182
setIsLoading(true)
185183
setMessage('')
186184

187-
const { error } = await stripe.confirmPayment({
185+
const { error, paymentIntent } = await stripe.confirmPayment({
188186
elements,
189187
confirmParams: {
190188
return_url: `${window.location.origin}/success`,
@@ -193,10 +191,38 @@ function CheckoutForm({ clientSecret }: { clientSecret: string }) {
193191
})
194192

195193
if (error) {
196-
if (error.type === 'card_error' || error.type === 'validation_error') {
197-
setMessage(error.message || 'An error occurred')
198-
} else {
199-
setMessage('An unexpected error occurred.')
194+
setMessage(error.message || 'An unexpected error occurred.')
195+
setIsLoading(false)
196+
return
197+
}
198+
199+
if (paymentIntent?.status === 'succeeded') {
200+
// Payment successful — create user
201+
try {
202+
const res = await fetch('/api/users', {
203+
method: 'POST',
204+
headers: { 'Content-Type': 'application/json' },
205+
body: JSON.stringify({
206+
email,
207+
firstName,
208+
lastName,
209+
phoneNumber,
210+
gender,
211+
ethnicity,
212+
universityId,
213+
upi,
214+
areaOfStudy,
215+
yearLevel,
216+
}),
217+
})
218+
const data = await res.json()
219+
if (!data.success) {
220+
console.error('User creation failed:', data.error)
221+
} else {
222+
console.log('User created successfully:', data.user)
223+
}
224+
} catch (err) {
225+
console.error('Error creating user:', err)
200226
}
201227
}
202228

0 commit comments

Comments
 (0)