Skip to content

Commit

Permalink
update currency field (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
mazmassa authored Jun 15, 2023
1 parent 08e19f2 commit 9498bdc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions web-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions web-frontend/src/mirage/server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createServer, Model, Factory } from 'miragejs';
import { createServer, Model, Factory, Response } from 'miragejs';
import { ENV } from '../const/env/env';
import { faker } from '@faker-js/faker';

Expand Down Expand Up @@ -91,8 +91,10 @@ function mockServer(environment = ENV.DEV) {
);

if (!amount || !fee || !recipientAddress) {
// TODO
// we must handle here the missing payload fields
return new Response(400, {
code: '0001',
message: 'missing fields',
});
}

return schema.create('transfer');
Expand Down
10 changes: 5 additions & 5 deletions web-frontend/src/pages/TransferCoins/SendCoins/SendCoins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ function SendCoins({ ...props }) {
const { account, redirect } = props;

const navigate = useNavigate();
const { nickname } = useParams();

const [submit, setSubmit] = useState<boolean>(false);
const [data, setData] = useState<object>();
const [final, setFinal] = useState<object>();
const { nickname } = useParams();
const [payloadData, setPayloadData] = useState<object>();

const { mutate, isSuccess, isLoading, error } =
usePost<SendTransactionObject>(`accounts/${nickname}/transfer`);
Expand All @@ -30,8 +31,7 @@ function SendCoins({ ...props }) {
function handleSubmit({ ...data }) {
setData(data);

setFinal({
...data,
setPayloadData({
fee: data.fees,
recipientAddress: data.recipient,
amount: toNanoMASS(data.amount).toString(),
Expand All @@ -44,7 +44,7 @@ function SendCoins({ ...props }) {
if (!confirmed) {
setSubmit(false);
} else {
mutate(final as SendTransactionObject);
mutate(payloadData as SendTransactionObject);
}
}

Expand Down

0 comments on commit 9498bdc

Please sign in to comment.