Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final tweaks for wallet staking #87

Merged
merged 2 commits into from
May 26, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Improvements

- Add helper script for CHANGELOG
- Time is now displayed in 24hr format

### Bug Fixes

Expand Down
7 changes: 6 additions & 1 deletion src/Components/UserAccount/UserAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ const WalletBtn = styled(Button)`
const AccountBtn = styled(Button)`
border: none;
background: none;
/* animate.css @keyframe */
animation: heartBeat;
animation-duration: 1s;
animation-delay: 2s;
animation-iteration-count: ${({ isLoggedIn }) => (isLoggedIn ? 0 : 2)};

@media ${breakpoints.up('md')} {
margin-left: 10px;
Expand Down Expand Up @@ -107,7 +112,7 @@ const UserAccount = ({ isMobile }) => {

return (
<Container ref={containerRef}>
<AccountBtn onClick={toggleShowPopup}>
<AccountBtn onClick={toggleShowPopup} isLoggedIn={isLoggedIn}>
<Sprite icon={isLoggedIn ? ICON_NAMES.ACCOUNT : ICON_NAMES.KEY} color={theme.FONT_NAV} size="20px" />
</AccountBtn>

Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Validators/Components/ValidatorList.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ const ValidatorList = () => {
}, [accountRewards, currentVals, isDelegateFilter, setMyValTableData, tableData]);

const myValTableHeaders = [
isDelegateFilter && { displayName: 'Staking', dataName: 'manageStaking' },
{ displayName: 'Moniker', dataName: 'moniker' },
{ displayName: 'Voting Power', dataName: 'votingPower' },
{ displayName: 'Commission', dataName: 'commission' },
{ displayName: 'Delegation Amount', dataName: 'amount' },
{ displayName: 'Reward', dataName: 'reward' },
isDelegateFilter && { displayName: '', dataName: 'manageStaking' },
] // Remove the nulls
.filter((th) => th);

// Table header values in order
const tableHeaders = [
isLoggedIn && { displayName: 'Delegate', dataName: 'delegate' },
isLoggedIn && { displayName: 'Staking', dataName: 'delegate' },
{ displayName: 'Moniker', dataName: 'moniker' },
{ displayName: 'Address', dataName: 'addressId' },
{ displayName: 'Commission', dataName: 'commission' },
Expand Down
4 changes: 2 additions & 2 deletions src/utils/date/getFormattedDate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { utcToZonedTime, format as dateFnsFormat } from 'date-fns-tz';

// Get a date (in the format of your choosing, default is 'yyyy/MM/dd hh:mm:ss') for any timezone
export const getFormattedDate = (date, timeFormat = 'yyyy/MM/dd hh:mm:ss', timeZone = 'UTC') =>
// Get a date (in the format of your choosing, default is 'yyyy/MM/dd HH:mm:ss') for any timezone
export const getFormattedDate = (date, timeFormat = 'yyyy/MM/dd HH:mm:ss', timeZone = 'UTC') =>
dateFnsFormat(utcToZonedTime(date, timeZone), timeFormat, { timeZone });
4 changes: 2 additions & 2 deletions src/utils/date/getTimeSince.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const getTimeSince = (prevDate, options = {}) => {

const currentUTCDate = getUTCTime('current');
// DateFNS requires a parsed date to do any work on it (can't just take in a string)
const currentUTCDateParsed = parse(currentUTCDate, 'yyyy/MM/dd hh:mm:ss', new Date(currentUTCDate));
const prevDateParsed = parse(prevDate, 'yyyy/MM/dd hh:mm:ss', new Date(prevDate));
const currentUTCDateParsed = parse(currentUTCDate, 'yyyy/MM/dd HH:mm:ss', new Date(currentUTCDate));
const prevDateParsed = parse(prevDate, 'yyyy/MM/dd HH:mm:ss', new Date(prevDate));
// Built in date-fns time difference function
const timeSince = formatDistanceStrict(currentUTCDateParsed, prevDateParsed, { roundingMethod: 'floor', unit });
// Clean up words if longhand isn't requested
Expand Down
2 changes: 1 addition & 1 deletion src/utils/date/getUTCTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { parseISO } from 'date-fns';
import { getFormattedDate } from './getFormattedDate';

// Convert a date (or leave null, 'now', or 'current' for 'today') to UTC time in the format of your choosing (default is 'yyyy/MM/dd hh:mm:ss')
export const getUTCTime = (date, format = 'yyyy/MM/dd hh:mm:ss') => {
export const getUTCTime = (date, format = 'yyyy/MM/dd HH:mm:ss') => {
const today = !date || date === 'now' || date === 'current' ? new Date().toISOString() : new Date(date).toISOString();
const todayParsed = parseISO(today);

Expand Down
6 changes: 4 additions & 2 deletions src/utils/table/formatTableData.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ export const formatTableData = (data = [], tableHeaders) => {
case 'reward': {
const { amount = '--', denom = '--' } = serverValue?.[0] || {};
denom === 'nhash'
? (finalObj[dataName] = { value: `${currencyFormat(amount, 'nhash', 'hash')} hash` })
: (finalObj[dataName] = { value: `${numberFormat(amount, 6)} ${denom}` });
? (finalObj[dataName] = {
value: `${formatNhash(currencyFormat(amount, 'nhash', 'hash'), { decimal: 4 })} hash`,
})
: (finalObj[dataName] = { value: `${numberFormat(amount, 4)} ${denom}` });
break;
}
// Amount of currency/item and its denomination given in an object (count)
Expand Down