@@ -22,6 +22,9 @@ type CartItem = {
2222 quantity : number ;
2323} ;
2424
25+ const GCASH_BUCKET = "gcash-receipts" ;
26+ const MAX_RECEIPT_SIZE = 5 * 1024 * 1024 ;
27+
2528export default function Home ( ) {
2629 const [ merchItems , setMerchItems ] = useState < MerchItem [ ] > ( [ ] ) ;
2730 const [ merchLoading , setMerchLoading ] = useState ( true ) ;
@@ -196,19 +199,71 @@ export default function Home() {
196199 const email = String ( formData . get ( "email" ) ?? "" ) . trim ( ) ;
197200 const phone = String ( formData . get ( "contactNumber" ) ?? "" ) . trim ( ) ;
198201 const address = String ( formData . get ( "address" ) ?? "" ) . trim ( ) ;
202+ const paymentMethod = String ( formData . get ( "paymentMethod" ) ?? "gcash" ) ;
203+ const gcashReference = String (
204+ formData . get ( "gcashReference" ) ?? ""
205+ ) . trim ( ) ;
206+ const receiptFile = formData . get ( "gcashReceipt" ) ;
199207
200208 if ( ! fullName || ! email || ! phone || ! address ) {
201209 setSubmitError ( "Please complete all contact fields." ) ;
202210 return ;
203211 }
204212
213+ if ( paymentMethod !== "gcash" ) {
214+ setSubmitError ( "Select GCash as your payment method." ) ;
215+ return ;
216+ }
217+
218+ if ( ! gcashReference ) {
219+ setSubmitError ( "Enter your GCash reference number." ) ;
220+ return ;
221+ }
222+
223+ if ( ! ( receiptFile instanceof File ) || receiptFile . size === 0 ) {
224+ setSubmitError ( "Upload your GCash receipt screenshot." ) ;
225+ return ;
226+ }
227+
228+ if ( ! receiptFile . type . startsWith ( "image/" ) ) {
229+ setSubmitError ( "Receipt screenshot must be an image file." ) ;
230+ return ;
231+ }
232+
233+ if ( receiptFile . size > MAX_RECEIPT_SIZE ) {
234+ setSubmitError ( "Receipt image must be 5MB or smaller." ) ;
235+ return ;
236+ }
237+
205238 setSubmitting ( true ) ;
206239
240+ const fileExtension =
241+ receiptFile . name . split ( "." ) . pop ( ) ?. toLowerCase ( ) || "jpg" ;
242+ const uploadPath = `gcash/${ crypto . randomUUID ( ) } .${ fileExtension } ` ;
243+ const { error : uploadError } = await supabase . storage
244+ . from ( GCASH_BUCKET )
245+ . upload ( uploadPath , receiptFile , {
246+ contentType : receiptFile . type ,
247+ } ) ;
248+
249+ if ( uploadError ) {
250+ setSubmitError ( "Unable to upload receipt. Please try again." ) ;
251+ setSubmitting ( false ) ;
252+ return ;
253+ }
254+
255+ const receiptUrl = supabase . storage
256+ . from ( GCASH_BUCKET )
257+ . getPublicUrl ( uploadPath ) . data . publicUrl ;
258+
207259 const orderRows = cartItems . map ( ( item ) => ( {
208260 full_name : fullName ,
209261 email,
210262 phone,
211263 address,
264+ payment_method : "gcash" ,
265+ gcash_reference : gcashReference ,
266+ gcash_receipt_url : receiptUrl ,
212267 item_id : item . itemId ,
213268 item_name : item . name ,
214269 size : item . size ,
@@ -229,7 +284,7 @@ export default function Home() {
229284 setCartItems ( [ ] ) ;
230285 setQuantities ( ( prev ) => prev . map ( ( ) => 0 ) ) ;
231286 form . reset ( ) ;
232- setSubmitSuccess ( "Order received! We'll email you with next steps ." ) ;
287+ setSubmitSuccess ( "Order received! We'll verify your GCash receipt ." ) ;
233288 setSubmitting ( false ) ;
234289 } ;
235290 return (
@@ -538,8 +593,8 @@ export default function Home() {
538593 Place Your Order
539594 </ h2 >
540595 < p className = "mt-3 text-sm leading-6 text-white/70" >
541- Fill up the form below to reserve your merch. We will follow up
542- with payment details and size confirmation .
596+ Fill up the form below and attach your GCash receipt to confirm
597+ your merch order .
543598 </ p >
544599 < div className = "mt-6 grid gap-4 text-xs uppercase tracking-[0.25em] text-white/60" >
545600 < div className = "flex items-center gap-3" >
@@ -594,6 +649,47 @@ export default function Home() {
594649 />
595650 </ label >
596651
652+ < div className = "rounded-2xl border border-white/10 bg-white/5 p-4" >
653+ < p className = "text-xs uppercase tracking-[0.2em] text-white/60" >
654+ Payment Method
655+ </ p >
656+ < label className = "mt-3 flex items-center gap-3 text-sm text-white/80" >
657+ < input
658+ type = "radio"
659+ name = "paymentMethod"
660+ value = "gcash"
661+ defaultChecked
662+ className = "h-4 w-4 border-white/30 bg-white/10 text-emerald-300 focus:ring-emerald-300/40"
663+ />
664+ GCash
665+ </ label >
666+ < p className = "mt-2 text-xs text-white/60" >
667+ Upload your GCash receipt before confirming the order.
668+ </ p >
669+ </ div >
670+
671+ < label className = "text-sm text-white/80" >
672+ GCash Reference No.
673+ < input
674+ type = "text"
675+ name = "gcashReference"
676+ placeholder = "0000000000"
677+ required
678+ className = "mt-2 w-full rounded-xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white placeholder-white/40 focus:border-emerald-300/70 focus:outline-none focus:ring-2 focus:ring-emerald-300/30"
679+ />
680+ </ label >
681+
682+ < label className = "text-sm text-white/80" >
683+ GCash Receipt Screenshot
684+ < input
685+ type = "file"
686+ name = "gcashReceipt"
687+ accept = "image/*"
688+ required
689+ className = "mt-2 w-full rounded-xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white file:mr-3 file:rounded-full file:border-0 file:bg-white/10 file:px-3 file:py-2 file:text-xs file:uppercase file:tracking-[0.2em] file:text-white/80"
690+ />
691+ </ label >
692+
597693 { submitError ? (
598694 < p className = "text-xs uppercase tracking-[0.2em] text-amber-300" >
599695 { submitError }
0 commit comments