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

Fix issue about Conversion currency #162

Merged
merged 7 commits into from
Feb 1, 2024
Merged
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
31 changes: 29 additions & 2 deletions components/atoms/Stepper/Forms/payment2.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,33 @@
currencyPatient,
);

setConvertResult(res);
setConvertRequest(false);

};

const convertAutomaticallyOnFirstSelect = async (e) => {
// e.currentTarget.value && setAmountTemp(Number(e.currentTarget.value));

setConvertRequest(true);

Check warning on line 308 in components/atoms/Stepper/Forms/payment2.js

View check run for this annotation

Codecov / codecov/patch

components/atoms/Stepper/Forms/payment2.js#L307-L308

Added lines #L307 - L308 were not covered by tests
const res = await convertCurrency(
e.currentTarget.value,
Number(amountTemp),
currencyPatient,
);

setConvertRequest(false);

Check warning on line 315 in components/atoms/Stepper/Forms/payment2.js

View check run for this annotation

Codecov / codecov/patch

components/atoms/Stepper/Forms/payment2.js#L314-L315

Added lines #L314 - L315 were not covered by tests
setConvertResult(res);
};

const convertAutomaticallyOnSecondSelect = async (e) => {
setConvertRequest(true);

Check warning on line 320 in components/atoms/Stepper/Forms/payment2.js

View check run for this annotation

Codecov / codecov/patch

components/atoms/Stepper/Forms/payment2.js#L319-L320

Added lines #L319 - L320 were not covered by tests
const res = await convertCurrency(
currencySender,
Number(amountTemp),
e.currentTarget.value,
);

Check warning on line 326 in components/atoms/Stepper/Forms/payment2.js

View check run for this annotation

Codecov / codecov/patch

components/atoms/Stepper/Forms/payment2.js#L326

Added line #L326 was not covered by tests
setConvertRequest(false);
setConvertResult(res);
};
Expand Down Expand Up @@ -448,7 +475,7 @@
className="block w-full border-transparent rounded-md focus:ring-orange focus:border-blue-600 "
onChange={(e) => {
setCurrencySender(e.target.value);
convertAutomatically(null);
convertAutomaticallyOnFirstSelect(e);
}}
>
<option>USD</option>
Expand Down Expand Up @@ -515,7 +542,7 @@
e.target.selectedIndex
].getAttribute('currency'),
);
convertAutomatically(null);
convertAutomaticallyOnSecondSelect(e);
}}
>
{symbols.map((symbol, index) => (
Expand Down