ghost-portal/packages/page-society/src/Overview/Bids.tsx
Jaco Greeff ebad8635f7
Adjust useCall options (#3430)
* Adjust useCall options

* Extract useCall options

* typo

* Apply suggestions from code review

* Adjust param creation in calls
2020-08-17 12:24:51 +02:00

48 lines
1.1 KiB
TypeScript

// Copyright 2017-2020 @polkadot/app-society authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Bid } from '@polkadot/types/interfaces';
import React, { useRef } from 'react';
import { Table } from '@polkadot/react-components';
import { useApi, useCall } from '@polkadot/react-hooks';
import { useTranslation } from '../translate';
import BidRow from './Bid';
interface Props {
className?: string;
}
function Bids ({ className }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const bids = useCall<Bid[]>(api.query.society.bids);
const headerRef = useRef([
[t('bids'), 'start'],
[t('kind')],
[t('value')],
[]
]);
return (
<Table
className={className}
empty={bids && t<string>('No bids')}
header={headerRef.current}
>
{bids?.map((bid, index): React.ReactNode => (
<BidRow
index={index}
key={bid.who.toString()}
value={bid}
/>
))}
</Table>
);
}
export default React.memo(Bids);