Skip to content

Commit c9d6651

Browse files
committed
refactor: display error message if transaction fails
1 parent eee178e commit c9d6651

File tree

1 file changed

+51
-21
lines changed

1 file changed

+51
-21
lines changed

src/components/v0/ContributionDialog.tsx

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Fragment, useRef, useState } from 'react'
22
import { Dialog, Transition } from '@headlessui/react'
3-
import { InformationCircleIcon, CheckBadgeIcon } from '@heroicons/react/24/outline'
3+
import { InformationCircleIcon, CheckBadgeIcon, ExclamationTriangleIcon } from '@heroicons/react/24/outline'
44
import { usePrepareContractWrite, useContractWrite, useWaitForTransaction, useAccount, Address } from 'wagmi'
55
import { useRouter } from 'next/router'
66
import Sector3DAOPriority from '../../../abis/v0/Sector3DAOPriority.json'
@@ -119,26 +119,56 @@ export default function ContributionDialog({ priorityTitle }: any) {
119119
</>
120120
) : (
121121
<>
122-
<p className='flex justify-center'>
123-
<CheckBadgeIcon className="h-16 w-16 text-green-400" />
124-
</p>
125-
<p className='mt-4'>
126-
Successfully added your DAO contribution!
127-
</p>
128-
<p className='mt-4'>
129-
<Link href={`${config.etherscanDomain}/tx/${transactionData?.hash}`} target='_blank'
130-
className='text-indigo-400'
131-
>
132-
View transaction on Etherscan
133-
</Link>
134-
</p>
135-
<button
136-
type="button"
137-
className="mt-4 inline-flex w-full justify-center rounded-xl bg-indigo-800 px-4 py-2 font-semibold text-indigo-200 shadow-sm hover:bg-indigo-700 sm:w-auto"
138-
onClick={() => setOpen(false)}
139-
>
140-
Close
141-
</button>
122+
{(!isTransactionSuccess) ? (
123+
<p>
124+
<>
125+
<p className='flex justify-center'>
126+
<ExclamationTriangleIcon className="h-16 w-16 text-orange-400" />
127+
</p>
128+
<p className='mt-4 text-orange-400'>
129+
Transaction failed
130+
</p>
131+
<p className='mt-4'>
132+
<Link href={`${config.etherscanDomain}/tx/${transactionData?.hash}`} target='_blank'
133+
className='text-indigo-400'
134+
>
135+
View transaction on Etherscan
136+
</Link>
137+
</p>
138+
<button
139+
type="button"
140+
className="mt-4 inline-flex w-full justify-center rounded-xl bg-indigo-800 px-4 py-2 font-semibold text-indigo-200 shadow-sm hover:bg-indigo-700 sm:w-auto"
141+
onClick={() => setOpen(false)}
142+
>
143+
Close
144+
</button>
145+
</>
146+
</p>
147+
148+
) : (
149+
<>
150+
<p className='flex justify-center'>
151+
<CheckBadgeIcon className="h-16 w-16 text-green-400" />
152+
</p>
153+
<p className='mt-4'>
154+
Successfully added your DAO contribution!
155+
</p>
156+
<p className='mt-4'>
157+
<Link href={`${config.etherscanDomain}/tx/${transactionData?.hash}`} target='_blank'
158+
className='text-indigo-400'
159+
>
160+
View transaction on Etherscan
161+
</Link>
162+
</p>
163+
<button
164+
type="button"
165+
className="mt-4 inline-flex w-full justify-center rounded-xl bg-indigo-800 px-4 py-2 font-semibold text-indigo-200 shadow-sm hover:bg-indigo-700 sm:w-auto"
166+
onClick={() => setOpen(false)}
167+
>
168+
Close
169+
</button>
170+
</>
171+
)}
142172
</>
143173
)}
144174
</div>

0 commit comments

Comments
 (0)