Skip to content

Commit bd104f5

Browse files
committed
frontend: refactor send into a functional component
1 parent 63286f4 commit bd104f5

File tree

6 files changed

+407
-418
lines changed

6 files changed

+407
-418
lines changed

frontends/web/src/api/account.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ export const sendTx = (
364364
return apiPost(`account/${code}/sendtx`, txNote);
365365
};
366366

367-
export type FeeTargetCode = 'custom' | 'low' | 'economy' | 'normal' | 'high';
367+
export type FeeTargetCode = 'custom' | 'low' | 'economy' | 'normal' | 'high' | 'mHour' | 'mHalfHour' | 'mFastest';
368368

369369
export interface IProposeTxData {
370370
address?: string;

frontends/web/src/routes/account/send/components/inputs/receiver-address-input.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
justify-content: center;
2727
padding: 0;
2828
position: absolute;
29-
top: calc(50% - var(--space-quarter));
29+
top: calc(50% - var(--space-eight));
3030
right: calc(var(--spacing-default) - var(--space-quarter));
3131
cursor: pointer;
3232
}

frontends/web/src/routes/account/send/feetargets.module.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ select.priority {
9191
.feeCustom input {
9292
padding-right: 58px;
9393
}
94+
.feeCustom input:disabled {
95+
padding-right: 66px;
96+
padding-top: 2px;
97+
}
9498

9599
.feeDescription,
96100
.feeProposed {
@@ -102,7 +106,12 @@ select.priority {
102106
}
103107

104108
.feeProposed {
105-
margin: 0;
109+
margin: 0 0 var(--space-quarter) 0;
110+
}
111+
@media (min-width: 769px) {
112+
.feeProposed {
113+
margin: 0;
114+
}
106115
}
107116

108117
.feeDescription + .feeProposed {

frontends/web/src/routes/account/send/feetargets.test.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ describe('routes/account/send/feetargets', () => {
7878
}}
7979
customFee=""
8080
onCustomFee={vi.fn()}
81-
onFeeTargetChange={vi.fn()} />,
81+
onFeeTargetChange={vi.fn()}
82+
// value="normal"
83+
/>,
8284
);
8385
waitFor(() => expect(container).toMatchSnapshot());
8486
});
@@ -98,7 +100,9 @@ describe('routes/account/send/feetargets', () => {
98100
fiatUnit="EUR"
99101
customFee=""
100102
onCustomFee={vi.fn()}
101-
onFeeTargetChange={vi.fn()} />,
103+
onFeeTargetChange={vi.fn()}
104+
// value="normal"
105+
/>,
102106
);
103107
await waitFor(() => expect(container).toMatchSnapshot());
104108
});
@@ -126,7 +130,9 @@ describe('routes/account/send/feetargets', () => {
126130
fiatUnit="USD"
127131
customFee=""
128132
onCustomFee={vi.fn()}
129-
onFeeTargetChange={onFeeTargetChangeCB} />,
133+
onFeeTargetChange={onFeeTargetChangeCB}
134+
// value="normal"
135+
/>,
130136
);
131137
await waitFor(() => expect(apiGetMock).toHaveBeenCalled());
132138
}));

frontends/web/src/routes/account/send/feetargets.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type Props = {
3535
showCalculatingFeeLabel?: boolean;
3636
onFeeTargetChange: (code: accountApi.FeeTargetCode) => void;
3737
onCustomFee: (customFee: string) => void;
38+
// value?: accountApi.FeeTargetCode;
3839
error?: string;
3940
}
4041

@@ -54,11 +55,12 @@ export const FeeTargets = ({
5455
showCalculatingFeeLabel,
5556
onFeeTargetChange,
5657
onCustomFee,
57-
error
58+
error,
5859
}: Props) => {
5960
const { t } = useTranslation();
6061
const config = useLoad(getConfig);
6162
const [feeTarget, setFeeTarget] = useState<string>('');
63+
// const [feeTarget, setFeeTarget] = useState<accountApi.FeeTargetCode | undefined>(value);
6264
const [options, setOptions] = useState<TOptions[] | null>(null);
6365
const [noFeeTargets, setNoFeeTargets] = useState<boolean>(false);
6466

@@ -93,6 +95,11 @@ export const FeeTargets = ({
9395
setOptions(options);
9496
setFeeTarget(feeTargets.defaultFeeTarget);
9597
onFeeTargetChange(feeTargets.defaultFeeTarget);
98+
// if (!feeTarget) {
99+
// setFeeTarget(feeTargets.defaultFeeTarget);
100+
// console.log('ONLY ONCE????', feeTargets.defaultFeeTarget);
101+
// onFeeTargetChange(feeTargets.defaultFeeTarget);
102+
// }
96103
if (feeTargets.feeTargets.length === 0) {
97104
setNoFeeTargets(true);
98105
}

0 commit comments

Comments
 (0)