Skip to content

Commit

Permalink
Merge pull request #157 from BeamMW/fixes/auth
Browse files Browse the repository at this point in the history
Fixes/auth
  • Loading branch information
razoorka authored Dec 15, 2021
2 parents 03a116f + 72863a5 commit 992e974
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ const Registration: React.FC = () => {
// };

useEffect(() => {
if (!seed) {
dispatch(generateRegistrationSeed.request());
}
}, [seed, dispatch]);
dispatch(generateRegistrationSeed.request());
}, [dispatch]);

const handleNextClick: React.MouseEventHandler = () => {
navigate(ROUTES.AUTH.REGISTRATION_CONFIRM);
Expand Down
53 changes: 9 additions & 44 deletions src/app/containers/Wallet/containers/Wallet/Wallet.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import React, { useEffect, useState } from 'react';
import React, { useEffect } from 'react';
import { styled } from '@linaria/react';

import {
Button, Window, Section, Menu,
} from '@app/shared/components';
import { compact } from '@core/utils';

import { ArrowUpIcon, ArrowDownIcon } from '@app/shared/icons';

Expand All @@ -22,35 +21,6 @@ import { Assets, Transactions } from '../../components/Wallet';

const TXS_MAX = 4;

const TABLE_CONFIG = [
{
name: 'create_time',
title: 'Created',
},
{
name: 'sender',
title: 'From',
fn: compact,
},
{
name: 'receiver',
title: 'To',
fn: compact,
},
{
name: 'value',
title: 'Amount',
fn: (value: number) => {
const result = value / GROTHS_IN_BEAM;
return result.toString();
},
},
{
name: 'status_string',
title: 'Status',
},
];

const ActionsStyled = styled.div`
display: flex;
justify-content: space-between;
Expand All @@ -61,15 +31,7 @@ const ActionsStyled = styled.div`
}
`;

const menuButtonStyle = css`
position: fixed;
z-index: 3;
top: 74px;
left: 24px;
margin: 0;
`;

function createdCompartor({ create_time: a }: Transaction, { create_time: b }: Transaction): -1 | 0 | 1 {
function createdComparator({ create_time: a }: Transaction, { create_time: b }: Transaction): -1 | 0 | 1 {
if (a === b) {
return 0;
}
Expand All @@ -92,7 +54,7 @@ const Wallet = () => {

const navigate = useNavigate();

const sorted = transactions.slice().sort(createdCompartor);
const sorted = transactions.slice().sort(createdComparator);
const sliced = sorted.slice(0, TXS_MAX);

return (
Expand All @@ -108,9 +70,12 @@ const Wallet = () => {
<Section title="Assets">
<Assets data={assets} />
</Section>
<Section title="Transactions">
<Transactions data={sliced} />
</Section>

{sliced.length > 0 && (
<Section title="Transactions" showAllAction={sliced.length > TXS_MAX ? () => {} : undefined}>
<Transactions data={sliced} />
</Section>
)}
</Window>
);
};
Expand Down
34 changes: 32 additions & 2 deletions src/app/shared/components/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface SectionProps {
subtitle?: string;
collapse?: boolean;
variant?: 'regular' | 'gray';
showAllAction?: () => void;
}

const SectionStyled = styled.div`
Expand Down Expand Up @@ -39,8 +40,31 @@ const ButtonStyled = styled.button`
white-space: nowrap;
`;

const ShowAll = styled.div`
font-size: 14px;
font-weight: bold;
font-stretch: normal;
font-style: normal;
line-height: normal;
letter-spacing: normal;
text-align: center;
color: #00f6d2;
cursor: pointer;
`;

const TitleWrapper = styled.div`
display: flex;
justify-content: space-between;
margin-bottom: 20px;
`;

const Section: React.FC<SectionProps> = ({
title, collapse = false, variant = 'regular', subtitle, children,
title,
collapse = false,
variant = 'regular',
subtitle,
children,
showAllAction,
}) => {
const [hidden, setHidden] = useState(collapse);

Expand All @@ -60,7 +84,13 @@ const Section: React.FC<SectionProps> = ({
<Angle value={hidden ? 180 : 0} margin={hidden ? 3 : 3} />
</ButtonStyled>
)}
{!!title && <Title>{title}</Title>}
{!!title && (
<TitleWrapper>
<Title>{title}</Title>
{' '}
{showAllAction && <ShowAll onClick={showAllAction}>Show All</ShowAll>}
</TitleWrapper>
)}
{!!subtitle && <Title variant="subtitle">{subtitle}</Title>}
{!hidden && children}
</SectionComponent>
Expand Down

0 comments on commit 992e974

Please sign in to comment.