22
33import { useTicketStore } from "@/store/ticketStore" ;
44import { useEffect , useState } from "react" ;
5- import { useRouter } from "next/navigation" ;
65import { PaymentWidget } from "./payment-widget/payment-widget" ;
6+ import { Input } from "./ui/input" ;
7+ import { Label } from "./ui/label" ;
8+ import { EASY_INVOICE_URL } from "@/lib/constants" ;
79
810export function PaymentStep ( ) {
911 const { tickets, clearTickets } = useTicketStore ( ) ;
1012 const [ total , setTotal ] = useState ( 0 ) ;
11- const router = useRouter ( ) ;
13+ const [ customClientId , setCustomClientId ] = useState ( "" ) ;
1214
1315 useEffect ( ( ) => {
1416 const newTotal = Object . values ( tickets ) . reduce (
@@ -33,9 +35,9 @@ export function PaymentStep() {
3335 total : total . toString ( ) ,
3436 totalUSD : total . toString ( ) ,
3537 } ;
36- console . log ( "ma kaj mona" , total , invoiceTotals )
3738
38- const clientId = process . env . NEXT_PUBLIC_RN_API_CLIENT_ID ;
39+ const defaultClientId = process . env . NEXT_PUBLIC_RN_API_CLIENT_ID ;
40+ const clientId = customClientId || defaultClientId ;
3941
4042 return (
4143 < div className = "grid grid-cols-1 lg:grid-cols-2 gap-8" >
@@ -72,9 +74,31 @@ export function PaymentStep() {
7274 </ div >
7375 </ div >
7476
75- { /* Payment Widget */ }
7677 < div role = "region" aria-label = "Payment Widget" >
7778 < h2 className = "text-2xl font-semibold mb-6" > Payment</ h2 >
79+ < div className = "mb-6 space-y-2" >
80+ < Label htmlFor = "custom-client-id" > Custom Client ID</ Label >
81+ < Input
82+ id = "custom-client-id"
83+ type = "text"
84+ placeholder = "Enter your custom client ID"
85+ value = { customClientId }
86+ onChange = { ( e ) => setCustomClientId ( e . target . value ) }
87+ className = "w-full"
88+ />
89+ < p className = "text-sm text-gray-600" >
90+ Get your Client ID on{ " " }
91+ < a
92+ href = { `${ EASY_INVOICE_URL } /ecommerce/manage` }
93+ target = "_blank"
94+ rel = "noopener noreferrer"
95+ className = "text-green hover:text-dark-green underline"
96+ >
97+ EasyInvoice
98+ </ a >
99+ </ p >
100+ </ div >
101+
78102 { clientId && (
79103 < PaymentWidget
80104 amountInUsd = { total . toString ( ) }
@@ -126,15 +150,12 @@ export function PaymentStep() {
126150 } }
127151 onSuccess = { ( ) => {
128152 clearTickets ( ) ;
129- setTimeout ( ( ) => {
130- router . push ( "/" ) ;
131- } , 10000 ) ;
132153 } }
133154 onError = { ( error ) => {
134155 console . error ( "Payment failed:" , error ) ;
135156 } }
136157 >
137- < div className = "px-8 py-2 bg-[#099C77] text-white rounded-lg hover:bg-[#087f63] transition-colors text-center" >
158+ < div className = "px-10 py-2 bg-[#099C77] text-white rounded-lg hover:bg-[#087f63] transition-colors text-center" >
138159 Pay with crypto
139160 </ div >
140161 </ PaymentWidget >
0 commit comments