-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app): client side error on address page (#777)
- Loading branch information
1 parent
ca5954b
commit 8f0599f
Showing
3 changed files
with
83 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import FaCheckCircle from '../Icons/FaCheckCircle'; | ||
import FaHourglassStart from '../Icons/FaHourglassStart'; | ||
import FaTimesCircle from '../Icons/FaTimesCircle'; | ||
|
||
interface Props { | ||
status: 'SuccessValue' | 'Failure' | 'SuccessReceiptId' | 'Unknown'; | ||
showLabel: boolean; | ||
showReceipt?: React.ReactNode; | ||
} | ||
|
||
const getOptions = (status: Props['status']) => { | ||
switch (status) { | ||
case 'Unknown': | ||
return { | ||
bg: 'bg-yellow-50 dark:bg-black', | ||
text: 'text-yellow-500', | ||
icon: FaHourglassStart, | ||
label: 'Pending', | ||
}; | ||
case 'Failure': | ||
return { | ||
bg: 'bg-red-50 dark:bg-black', | ||
text: 'text-red-500', | ||
icon: FaTimesCircle, | ||
label: 'Fail', | ||
}; | ||
case 'SuccessValue': | ||
return { | ||
bg: 'bg-emerald-50 dark:bg-black', | ||
text: 'text-emerald-500', | ||
icon: FaCheckCircle, | ||
label: 'Success', | ||
}; | ||
case 'SuccessReceiptId': | ||
return { | ||
bg: 'bg-emerald-50 dark:bg-black', | ||
text: 'text-emerald-500', | ||
icon: FaCheckCircle, | ||
label: 'Success', | ||
}; | ||
} | ||
}; | ||
|
||
const RpcTxnStatus = (props: any) => { | ||
if (!props.status) { | ||
return null; | ||
} | ||
|
||
const statusType = Object.keys(props.status)[0] as Props['status']; | ||
const option = getOptions(statusType); | ||
const Icon = option?.icon; | ||
|
||
return ( | ||
<div className="w-full md:w-3/4 break-words inline-flex items-center"> | ||
<span | ||
className={`inline-flex items-center text-xs rounded py-1 ${option?.bg} ${option?.text} ${ | ||
props.showLabel ? ' px-2' : ' px-1' | ||
}`} | ||
> | ||
<Icon /> | ||
{props.showLabel && <span className="ml-2">{option?.label}</span>} | ||
</span> | ||
{props.showReceipt ? props.showReceipt : null} | ||
</div> | ||
); | ||
}; | ||
export default RpcTxnStatus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters