@hanzo/commerce 1.1.12 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,12 +30,6 @@ const ContactInfo: React.FC<{
30
30
  <Form {...form}>
31
31
  <form className='text-left'>
32
32
  <div className='flex flex-col gap-4'>
33
- <div className='flex gap-4 items-center'>
34
- <User />
35
- <EnhHeadingBlockComponent block={{blockType: 'enh-heading',
36
- heading: { text: `Contact Info`, level: 4 },
37
- } as EnhHeadingBlock}/>
38
- </div>
39
33
  <div className='flex flex-col sm:flex-row gap-4'>
40
34
  <FormField
41
35
  control={form.control}
@@ -8,10 +8,10 @@ import { zodResolver } from '@hookform/resolvers/zod'
8
8
  import * as z from 'zod'
9
9
  import { useForm } from 'react-hook-form'
10
10
 
11
- import { ApplyTypography, Button, Main, Separator } from '@hanzo/ui/primitives'
11
+ import { Button, Main, Separator, Toaster } from '@hanzo/ui/primitives'
12
12
  import { cn } from '@hanzo/ui/util'
13
13
  import { useAuth } from '@hanzo/auth/service'
14
- import { LoginComponent } from '@hanzo/auth/components'
14
+ import { LoginComponent, AuthWidget } from '@hanzo/auth/components'
15
15
 
16
16
  import ShippingInfo from './shipping-info'
17
17
  import ThankYou from './thank-you'
@@ -86,45 +86,45 @@ const Checkout: React.FC<{toggleCheckout: () => void}> = observer(({toggleChecko
86
86
  const steps = [step1, step2, step3, step4]
87
87
 
88
88
  return (
89
- <div className="fixed top-0 left-0 !max-w-none w-full h-full min-h-screen bg-background z-[51]">
90
- <Main className='grid grid-cols-5 justify-center gap-8 overflow-y-auto h-full'>
91
- <Button
92
- variant='ghost'
93
- size='icon'
94
- className='absolute sm:ml-2 sm:mt-2'
95
- onClick={() => {
96
- setCurrentStep(0)
97
- toggleCheckout()
98
- }}
99
- >
100
- <ChevronLeft/>
101
- </Button>
102
-
103
- <div className='col-span-2 hidden md:flex'>
104
- <Cart hideCheckout className='fixed justify-center border-none mt-10 w-1/3 max-w-[40rem]'/>
105
- </div>
89
+ <div className="fixed top-0 left-0 !max-w-none w-full h-full min-h-screen bg-background z-[51]">
90
+ <Toaster/>
91
+ <Main className='flex flex-col gap-1 h-full'>
92
+ <div className='flex justify-between'>
93
+ <Button
94
+ variant='ghost'
95
+ size='icon'
96
+ className='sm:ml-2 sm:mt-2'
97
+ onClick={() => {
98
+ setCurrentStep(0)
99
+ toggleCheckout()
100
+ }}
101
+ >
102
+ <ChevronLeft/>
103
+ </Button>
104
+ <AuthWidget/>
105
+ </div>
106
+
107
+ <div className='grid grid-cols-5 justify-center gap-8 h-full'>
108
+ <div className='col-span-2 hidden md:flex'>
109
+ <Cart hideCheckout className='fixed justify-center border-none mt-10 w-1/3 max-w-[40rem]'/>
110
+ </div>
106
111
 
107
- <div className='flex flex-col gap-8 sm:gap-14 col-span-5 md:col-span-3 max-w-[40rem] mx-auto'>
108
- <ApplyTypography className='w-full'>
109
- <h3 className='!text-center w-1/2 mx-auto sm:w-full sm:mt-5'>FINALIZE PAYMENT</h3>
110
- </ApplyTypography>
111
- <div className='flex gap-2 mx-auto items-center text-xxs sm:text-base'>
112
- <div className={cn('w-6 h-6 rounded-full border border-foreground flex flex-col justify-center items-center', currentStep === 1 ? 'bg-foreground text-muted-4' : '')}>
113
- 1
114
- <div className='relative text-foreground top-2 h-0 whitespace-nowrap'>Contact info</div>
115
- </div>
116
- <Separator className='w-[4rem] sm:w-[6rem]'/>
117
- <div className={cn('w-6 h-6 rounded-full border border-foreground flex flex-col justify-center items-center', currentStep === 2 ? 'bg-foreground text-muted-4' : '')}>
118
- 2
119
- <div className='relative text-foreground top-2 h-0 whitespace-nowrap'>Payment</div>
120
- </div>
121
- <Separator className='w-[4rem] sm:w-[6rem]'/>
122
- <div className={cn('w-6 h-6 rounded-full border border-foreground flex flex-col justify-center items-center', currentStep === 3 ? 'bg-foreground text-muted-4' : '')}>
123
- 3
124
- <div className='relative text-foreground top-2 h-0 whitespace-nowrap'>Shipping info</div>
112
+ <div className='flex flex-col gap-8 sm:gap-14 col-span-5 md:col-span-3 max-w-[30rem] w-full mx-auto overflow-y-auto h-[calc(100%-40px)] sm:h-[calc(100%-48px)] py-4'>
113
+ <div className='flex gap-2 mx-auto items-center text-xxs sm:text-base'>
114
+ <div className={cn('w-6 h-6 rounded-full border border-foreground flex flex-col justify-center items-center', currentStep === 1 ? 'bg-foreground text-muted-4' : '')}>
115
+ <div className='relative text-foreground top-4 h-0 whitespace-nowrap'>Contact</div>
116
+ </div>
117
+ <Separator className='w-[4rem] sm:w-[6rem]'/>
118
+ <div className={cn('w-6 h-6 rounded-full border border-foreground flex flex-col justify-center items-center', currentStep === 2 ? 'bg-foreground text-muted-4' : '')}>
119
+ <div className='relative text-foreground top-4 h-0 whitespace-nowrap'>Payment</div>
120
+ </div>
121
+ <Separator className='w-[4rem] sm:w-[6rem]'/>
122
+ <div className={cn('w-6 h-6 rounded-full border border-foreground flex flex-col justify-center items-center', currentStep === 3 ? 'bg-foreground text-muted-4' : '')}>
123
+ <div className='relative text-foreground top-4 h-0 whitespace-nowrap'>Delivery</div>
124
+ </div>
125
125
  </div>
126
+ {steps[currentStep - 1]}
126
127
  </div>
127
- {steps[currentStep - 1]}
128
128
  </div>
129
129
  </Main>
130
130
  </div>
@@ -27,13 +27,6 @@ const InfoField: React.FC<{label: string, value: ReactNode, copyValue: string}>
27
27
 
28
28
  const PayByBankTransfer: React.FC<{setCurrentStep: (step: number) => void}> = ({setCurrentStep}) => {
29
29
  return (<>
30
- <EnhHeadingBlockComponent
31
- block={{blockType: 'enh-heading',
32
- specifiers: 'center byline-center',
33
- heading: { text: `WIRE INFO`, level: 3 },
34
- byline: { text: 'Click the copy icon to copy text to your clipboard.', level: 6}
35
- } satisfies EnhHeadingBlock as Block}
36
- />
37
30
  <Tabs defaultValue="usd" className='w-full mx-auto max-w-[50rem]'>
38
31
  <TabsList className="grid w-full grid-cols-2 max-w-[15rem] mx-auto bg-level-2">
39
32
  <TabsTrigger value="usd">USD</TabsTrigger>
@@ -47,10 +47,12 @@ const PayWithCrypto: React.FC<{
47
47
  const [amount, setAmount] = useState<number>()
48
48
  const [availableAmount, setAvailableAmount] = useState<number>()
49
49
  const [provider, setProvider] = useState<ethers.BrowserProvider>()
50
+ const [transactionStatus, setTransactionStatus] = useState<'unpaid' | 'paid' | 'confirmed' | 'error'>('unpaid')
50
51
 
51
52
  //const selectedToken = 'eth'
52
53
 
53
54
  useEffect(() => {
55
+ setTransactionStatus('unpaid')
54
56
  // responding to changes in user.walletAddress
55
57
  return autorun(() => {
56
58
  const newProvider = new ethers.BrowserProvider(window.ethereum)
@@ -121,7 +123,17 @@ const PayWithCrypto: React.FC<{
121
123
  })
122
124
  console.log({ ether, addr: process.env.NEXT_PUBLIC_ETH_PAYMENT_ADDRESS })
123
125
  console.log('tx', tx)
124
- setCurrentStep(3)
126
+ setTransactionStatus('paid')
127
+
128
+ provider.waitForTransaction(tx.hash)
129
+ .then((receipt) => {
130
+ console.log(receipt)
131
+ setTransactionStatus('confirmed')
132
+ })
133
+ .catch((error) => {
134
+ console.log(error)
135
+ setTransactionStatus('error')
136
+ })
125
137
  } catch (err) {
126
138
  console.log(err)
127
139
  // :aa TODO string table
@@ -155,12 +167,18 @@ const PayWithCrypto: React.FC<{
155
167
  <Input value={amount ? amount/(10**18) : amount} contentEditable={false}/>
156
168
  <div className='relative flex items-center gap-2 -top-[32px] justify-end px-2 py-1 rounded-lg bg-muted-4 w-fit text-xs float-right mr-3'><Eth height={10}/>ETH</div>
157
169
  </div>
158
- <Button
159
- onClick={() => sendPayment(amount ? amount/(10**18) : 0)}
160
- disabled={!amount || loadingPrice}
161
- >
162
- Pay now
163
- </Button>
170
+ {transactionStatus === 'unpaid' || transactionStatus === 'error' ? (
171
+ <Button
172
+ onClick={() => sendPayment(amount ? amount/(10**18) : 0)}
173
+ disabled={!amount || loadingPrice}
174
+ >
175
+ Pay now
176
+ </Button>
177
+ ) : transactionStatus === 'paid' ? (
178
+ <h4>Waiting for transaction to be confirmed on chain.</h4>
179
+ ) : (
180
+ <h4>Transaction confirmed!</h4>
181
+ )}
164
182
  </div>
165
183
  )
166
184
 
@@ -169,7 +187,7 @@ const PayWithCrypto: React.FC<{
169
187
  {payWidget}
170
188
  <div className='flex gap-4 items-center mt-6'>
171
189
  <Button variant='outline' onClick={() => setCurrentStep(1)} className='mx-auto w-full'>Back</Button>
172
- <Button onClick={() => setCurrentStep(3)} className='mx-auto w-full'>Continue (Pay later)</Button>
190
+ <Button onClick={() => setCurrentStep(3)} disabled={transactionStatus !== 'confirmed'} className='mx-auto w-full'>Continue</Button>
173
191
  </div>
174
192
  </div>
175
193
  )
@@ -66,12 +66,6 @@ const ShippingInfo: React.FC<{
66
66
  <Form {...shippingForm}>
67
67
  <form onSubmit={shippingForm.handleSubmit(onSubmit)} className='text-left'>
68
68
  <div className='flex flex-col gap-4'>
69
- <div className='flex gap-4 items-center'>
70
- <BookUser />
71
- <EnhHeadingBlockComponent block={{blockType: 'enh-heading',
72
- heading: { text: `Shipping address`, level: 4 },
73
- } as EnhHeadingBlock}/>
74
- </div>
75
69
  <div className='flex gap-4 items-end'>
76
70
  <FormField
77
71
  control={shippingForm.control}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/commerce",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "Library with shopping cart components.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",