ghost-portal/packages/page-tech-comm/src/Overview/Members.tsx
Keith Ingram 38405a8d3a
Display collective prime voter info and warnings (#2374)
* Display prime voter info

* enhancements

* Update packages/page-council/src/index.tsx

* Use React.memo, align society with council displays

* Fix merge lints

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-03-13 12:39:37 +01:00

77 lines
2.1 KiB
TypeScript

// Copyright 2017-2020 @polkadot/app-tech-comm 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 { AccountId } from '@polkadot/types/interfaces';
import React from 'react';
import styled from 'styled-components';
import { AddressSmall, Badge, Icon, Table } from '@polkadot/react-components';
import { useTranslation } from '../translate';
interface Props {
className?: string;
members?: AccountId[];
prime?: AccountId | null;
}
function Members ({ className, members, prime }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
return (
<div className={className}>
{members?.length
? (
<Table>
<Table.Body>
{members.map((accountId): React.ReactNode => {
const isPrime = prime?.toString() === accountId.toString();
return (
<tr
className={isPrime ? 'techcomm--isPrime' : ''}
key={accountId.toString()}
>
<td className='all'>
<AddressSmall value={accountId} />
</td>
<td className='right techcomm--prime'>
{isPrime && (
<div>
<Badge
info={<Icon name='chess king' />}
isInline
type='green'
/>
<span>{' '}{t('prime voter')}</span>
</div>
)}
</td>
</tr>
);
})}
</Table.Body>
</Table>
)
: t('No members found')
}
</div>
);
}
export default styled(Members)`
.techcomm--isPrime td {
background: rgba(239, 255, 239, 0.8);
}
.techcomm--prime > div {
display: inline-flex;
align-items: center;
white-space: nowrap;
> span {
color: green;
}
}
`;