Skip to content

Commit

Permalink
fix type error
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsleydon committed Sep 1, 2024
1 parent 07fefde commit f24bf8d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
40 changes: 23 additions & 17 deletions apps/app/components/WrapDecimal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Box} from '@mui/material'
import {type FC, Fragment, type ReactNode, useMemo} from 'react'

const regex = /(\d+\.\d+)/g

const WrapDecimal: FC<{children: ReactNode}> = ({children}) => {
const parts = useMemo(() => {
if (typeof children === 'string') {
Expand All @@ -10,25 +11,30 @@ const WrapDecimal: FC<{children: ReactNode}> = ({children}) => {
return []
}, [children])

if (parts.length === 0) {
return children
}

return (
<>
{typeof children === 'string'
? parts.map((part, index) => {
if (part.match(regex) != null) {
const [integer, decimal] = part.split('.')
return (
// biome-ignore lint/suspicious/noArrayIndexKey: the order of parts will not change
<Fragment key={index}>
{integer}.
<Box component="span" sx={{filter: 'brightness(0.5)'}}>
{decimal}
</Box>
</Fragment>
)
}
return part
})
: children}
{parts.map((part, index) => {
if (regex.test(part)) {
const [integer, decimal] = part.split('.')
return (
<Fragment
// biome-ignore lint/suspicious/noArrayIndexKey:
key={`${part}-${index}`}
>
{integer}.
<Box component="span" sx={{filter: 'brightness(0.5)'}}>
{decimal}
</Box>
</Fragment>
)
}
// biome-ignore lint/suspicious/noArrayIndexKey:
return <Fragment key={`${part}-${index}`}>{part}</Fragment>
})}
</>
)
}
Expand Down
6 changes: 5 additions & 1 deletion apps/app/hooks/useSignAndSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ const useSignAndSend = (): ((
.catch((err) => {
reject(err)
closeSnackbar(snackbarKey)
if (err.message != null && err.message !== 'Cancelled') {
if (
err instanceof Error &&
err.message != null &&
err.message !== 'Cancelled'
) {
enqueueSnackbar(
<Box>
<Box>{name}</Box>
Expand Down
Binary file modified bun.lockb
Binary file not shown.

0 comments on commit f24bf8d

Please sign in to comment.