@@ -4,7 +4,7 @@ import { PropsValidation } from "@/lib/validation";
44import  {  zodResolver  }  from  "@hookform/resolvers/zod" ; 
55import  PaymentWidget  from  "@requestnetwork/payment-widget/react" ; 
66import  {  CopyIcon  }  from  "lucide-react" ; 
7- import  {  useRef ,  useState  }  from  "react" ; 
7+ import  {  useEffect ,   useRef ,  useState  }  from  "react" ; 
88import  {  useForm  }  from  "react-hook-form" ; 
99import  {  z  }  from  "zod" ; 
1010import  {  Button  }  from  "./ui/button" ; 
@@ -21,6 +21,9 @@ import {
2121  AccordionTrigger , 
2222}  from  "./ui/accordion" ; 
2323
24+ import  {  cn  }  from  "@/lib/utils" ; 
25+ import  {  ZERO_ADDRESS  }  from  "@/lib/constants" ; 
26+ 
2427export  const  Playground  =  ( )  =>  { 
2528  const  { 
2629    register, 
@@ -38,6 +41,8 @@ export const Playground = () => {
3841      buyerInfo : { } , 
3942      invoiceNumber : "" , 
4043      enableBuyerInfo : false , 
44+       feeAddress : ZERO_ADDRESS , 
45+       feeAmount : 0 , 
4146    } , 
4247  } ) ; 
4348
@@ -65,6 +70,10 @@ export const Playground = () => {
6570      formValues . supportedCurrencies ?. length  && 
6671        `supportedCurrencies={${ JSON . stringify ( formValues . supportedCurrencies ) }  , 
6772      formValues . invoiceNumber  &&  `invoiceNumber="${ formValues . invoiceNumber }  , 
73+       formValues . feeAddress  && 
74+         formValues . feeAddress  !==  ZERO_ADDRESS  && 
75+         `feeAddress="${ formValues . feeAddress }  , 
76+       formValues . feeAmount  &&  `feeAmountInUSD={${ formValues . feeAmount }  , 
6877    ] 
6978      . filter ( Boolean ) 
7079      . join ( "\n      " ) ; 
@@ -99,6 +108,13 @@ const YourComponent = () => {
99108    } 
100109  } ; 
101110
111+   useEffect ( ( )  =>  { 
112+     if  ( formValues . feeAddress ?. length  ===  0 )  { 
113+       setValue ( "feeAddress" ,  ZERO_ADDRESS ) ; 
114+       setValue ( "feeAmount" ,  0 ) ; 
115+     } 
116+   } ,  [ formValues . feeAddress ,  formValues . feeAmount ] ) ; 
117+ 
102118  return  ( 
103119    < div  className = "flex flex-col gap-4 mt-4" > 
104120      < section  className = "flex flex-col gap-6 lg:gap-4 items-center md:items-start md:justify-between lg:flex-row" > 
@@ -359,10 +375,17 @@ const YourComponent = () => {
359375          </ div > 
360376          { /* Seller Address */ } 
361377          < div  className = "flex flex-col gap-2" > 
362-             < Label > Seller address</ Label > 
378+             < Label  className = "flex items-center" > 
379+               Seller address
380+               < span  className = "text-red-500 ml-1" > *</ span > 
381+             </ Label > 
363382            < Input 
364383              placeholder = "0x1234567890123456789012345678901234567890" 
365384              { ...register ( "sellerAddress" ) } 
385+               className = { cn ( 
386+                 "border-2" , 
387+                 errors . sellerAddress  ? "border-red-500"  : "border-gray-200" 
388+               ) } 
366389            /> 
367390            { errors . sellerAddress ?. message  &&  ( 
368391              < Error > { errors . sellerAddress . message } </ Error > 
@@ -371,12 +394,19 @@ const YourComponent = () => {
371394
372395          { /* Amount in USD */ } 
373396          < div  className = "flex flex-col gap-2" > 
374-             < Label > Amount in USD</ Label > 
397+             < Label  className = "flex items-center" > 
398+               Amount in USD
399+               < span  className = "text-red-500 ml-1" > *</ span > 
400+             </ Label > 
375401            < Input 
376402              placeholder = "25.55" 
377403              { ...register ( "amountInUSD" ,  { 
378404                valueAsNumber : true , 
379405              } ) } 
406+               className = { cn ( 
407+                 "border-2" , 
408+                 errors . amountInUSD  ? "border-red-500"  : "border-gray-200" 
409+               ) } 
380410            /> 
381411            { errors . amountInUSD ?. message  &&  ( 
382412              < Error > { errors . amountInUSD . message } </ Error > 
@@ -392,10 +422,44 @@ const YourComponent = () => {
392422            ) } 
393423          </ div > 
394424
425+           { /* Fee */ } 
426+           < div  className = "flex flex-col gap-2" > 
427+             < Label > Fee Address</ Label > 
428+             < Input 
429+               placeholder = "0x1234567890123456789012345678901234567890" 
430+               { ...register ( "feeAddress" ) } 
431+             /> 
432+             { errors . feeAddress ?. message  &&  ( 
433+               < Error > { errors . feeAddress . message } </ Error > 
434+             ) } 
435+             < Label > Fee Amount in USD</ Label > 
436+             < Input 
437+               placeholder = "25.55" 
438+               { ...register ( "feeAmount" ,  { 
439+                 valueAsNumber : true , 
440+               } ) } 
441+             /> 
442+             { errors . feeAmount ?. message  &&  ( 
443+               < Error > { errors . feeAmount . message } </ Error > 
444+             ) } 
445+           </ div > 
446+ 
395447          { /* Currencies */ } 
396448          < div  className = "flex flex-col gap-2" > 
397-             < Label > Currencies</ Label > 
398-             < CurrencyCombobox  register = { register }  name = "supportedCurrencies"  /> 
449+             < Label  className = "flex items-center" > 
450+               Currencies
451+               < span  className = "text-red-500 ml-1" > *</ span > 
452+             </ Label > 
453+             < CurrencyCombobox 
454+               register = { register } 
455+               name = "supportedCurrencies" 
456+               className = { cn ( 
457+                 "border-2" , 
458+                 errors . supportedCurrencies 
459+                   ? "border-red-500" 
460+                   : "border-gray-200" 
461+               ) } 
462+             /> 
399463            < div  className = "flex items-center gap-2 flex-wrap" > 
400464              { formValues . supportedCurrencies ?. map ( ( currency )  =>  { 
401465                return  ( 
@@ -408,6 +472,9 @@ const YourComponent = () => {
408472                ) ; 
409473              } ) } 
410474            </ div > 
475+             { errors . supportedCurrencies ?. message  &&  ( 
476+               < Error > { errors . supportedCurrencies . message } </ Error > 
477+             ) } 
411478          </ div > 
412479        </ div > 
413480        < div  className = "w-full lg:w-1/2" > 
@@ -426,6 +493,18 @@ const YourComponent = () => {
426493            // @ts -ignore 
427494            supportedCurrencies = { formValues . supportedCurrencies } 
428495            invoiceNumber = { formValues . invoiceNumber } 
496+             feeAddress = { 
497+               formValues . feeAddress  &&  formValues . feeAddress . length  >  0 
498+                 ? formValues . feeAddress 
499+                 : ZERO_ADDRESS 
500+             } 
501+             feeAmountInUSD = { 
502+               formValues . feeAddress  && 
503+               formValues . feeAddress . length  >  0  && 
504+               formValues . feeAddress  !==  ZERO_ADDRESS 
505+                 ? formValues . feeAmount 
506+                 : 0 
507+             } 
429508          /> 
430509        </ div > 
431510      </ section > 
0 commit comments