Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions packages/neuron-ui/src/components/History/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@ const groupHistory = (items: Transaction[]): Transaction[][] => {
}, [])
}

const History = (props: React.PropsWithoutRef<ContentProps & RouteComponentProps>) => {
const {
location: { search, pathname },
history,
loadings,
errorMsgs,
dispatch,
providerDispatch,
} = props
const History = ({
location: { search, pathname },
history,
// loadings,
errorMsgs,
dispatch,
providerDispatch,
}: React.PropsWithoutRef<ContentProps & RouteComponentProps>) => {
const {
chain: {
transactions: { pageNo, pageSize, totalCount, items, addresses },
Expand All @@ -82,20 +81,20 @@ const History = (props: React.PropsWithoutRef<ContentProps & RouteComponentProps
const onPageChange = useOnChangePage(search, pathname, history, queryFormatter)
const onAddressRemove = useOnAddressRemove(search, pathname, history, queryFormatter)

if (loadings.transactions) {
return <div>Loading</div>
}

return (
<Container>
<h1>{t('siderbar.history')}</h1>
{errorMsgs.transaction ? <Alert variant="warning">{t(`messages.${errorMsgs.transactions}`)}</Alert> : null}
{addresses.map(address => (
<AddressBadge variant="primary" key={address}>
{address}
<CloseIcon size="small" color="#fff" onClick={onAddressRemove(address)} />
</AddressBadge>
))}
{addresses.length > 0 ? (
addresses.map(address => (
<AddressBadge variant="primary" key={address}>
{address}
<CloseIcon size="small" color="#fff" onClick={onAddressRemove(address)} />
</AddressBadge>
))
) : (
<div>No Transactions Found</div>
)}
<ContextMenuZone menuItems={menuItems}>
{groupHistory(items).map(group => (
<Table key={dayjs(group[0].time).format(TimeFormat.Day)} striped>
Expand Down Expand Up @@ -129,11 +128,13 @@ const History = (props: React.PropsWithoutRef<ContentProps & RouteComponentProps
</Table>
))}
</ContextMenuZone>
<Row>
<Col>
<Pagination currentPage={pageNo} pageSize={pageSize} total={totalCount} onChange={onPageChange} />
</Col>
</Row>
{addresses.length > 0 ? (
<Row>
<Col>
<Pagination currentPage={pageNo - 1} pageSize={pageSize} total={totalCount} onChange={onPageChange} />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currentPage not equal to pageNo ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the convention is the (component?) community cuz pageNo => offset, pageSize => limit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one question: for an end user, what does the link for first page show, 0 or 1? It should be 1 regardless of param names we choose.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pageNo starts from 1 which outsides the component, currentPage starts from 0 which insides the component. PageNo used in the link

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why Pagination component start with 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why Pagination component start with 0

Just convention

</Col>
</Row>
) : null}
</Container>
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/components/Receive/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const Receive = (props: React.PropsWithoutRef<RouteComponentProps<{ address: str

if (!accountAddress) {
// TODO: better error handling
throw new Error('Found no addresses')
return <div>{t('receive.address-not-found')}</div>
}

const copyAddress = () => {
Expand Down
13 changes: 13 additions & 0 deletions packages/neuron-ui/src/components/WalletWizard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ const Mnemonic = ({
})
// TODO: Better Error Handle
.catch(err => console.error(err))
} else {
dispatch({
type: 'imported',
payload: '',
})
}
}, [dispatch, type])

Expand Down Expand Up @@ -139,6 +144,14 @@ const Submission = ({
type: 'name',
payload: `wallet @${Math.round(Math.random() * 100)}`,
})
dispatch({
type: 'password',
payload: '',
})
dispatch({
type: 'confirmPassword',
payload: '',
})
}, [dispatch])

const onChange = useCallback(
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/containers/Providers/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const useChannelListeners = (i18n: any, chain: any, dispatch: React.Dispa
UILayer.on(Channel.Transactions, (_e: Event, method: TransactionsMethod, args: ChannelResponse<any>) => {
if (args.status) {
switch (method) {
case TransactionsMethod.GetAll: {
case TransactionsMethod.GetAllByAddresses: {
dispatch({
type: ProviderActions.Chain,
payload: { transactions: { ...chain.transactions, ...args.result } },
Expand Down
3 changes: 3 additions & 0 deletions packages/neuron-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"this-transfer-will-send": "This transfer will send",
"scan-to-get-address": "scan the qrcode to get address"
},
"receive": {
"address-not-found": "Address not found"
},
"history": {
"meta": "meta",
"type": "type",
Expand Down
3 changes: 3 additions & 0 deletions packages/neuron-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"this-transfer-will-send": "本次交易将发送",
"scan-to-get-address": "扫码二维码以获取地址"
},
"receive": {
"address-not-found": "未找到地址"
},
"history": {
"meta": "元信息",
"type": "类型",
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/utils/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const history = (search: string) => {
const addresses = query.get('addresses')
// use Object.fromEntries in ES10
const params = {
pageNo: +(query.get('pageNo') || 0),
pageNo: +(query.get('pageNo') || 1),
pageSize: +(query.get('pageSize') || PAGE_SIZE),
addresses: addresses ? addresses.split(',') : [],
}
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-wallet/src/controllers/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class TransactionsController {
if (transactions) {
return {
status: ResponseCode.Success,
result: transactions,
result: { ...params, ...transactions },
}
}
return {
Expand Down