fix: payment
This commit is contained in:
parent
39c7782b55
commit
a1336a367c
@ -28,6 +28,7 @@
|
|||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"immer": "^10.0.2",
|
"immer": "^10.0.2",
|
||||||
"isomorphic-fetch": "^3.0.0",
|
"isomorphic-fetch": "^3.0.0",
|
||||||
|
"js-big-decimal": "^2.0.7",
|
||||||
"notistack": "^3.0.1",
|
"notistack": "^3.0.1",
|
||||||
"pdfjs-dist": "3.6.172",
|
"pdfjs-dist": "3.6.172",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import bigDecimal from "js-big-decimal";
|
||||||
import SectionWrapper from "@components/SectionWrapper";
|
import SectionWrapper from "@components/SectionWrapper";
|
||||||
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
||||||
import {
|
import {
|
||||||
@ -50,9 +51,6 @@ const paymentMethods: PaymentMethod[] = [
|
|||||||
|
|
||||||
type PaymentMethodType = (typeof paymentMethods)[number]["name"];
|
type PaymentMethodType = (typeof paymentMethods)[number]["name"];
|
||||||
|
|
||||||
// Нужно, что бы избежать ошибок по типу (3 * 1.2 = 3.5999999999999996)
|
|
||||||
const SAFE_VALUE = 0.0001;
|
|
||||||
|
|
||||||
export default function Payment() {
|
export default function Payment() {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const upMd = useMediaQuery(theme.breakpoints.up("md"));
|
const upMd = useMediaQuery(theme.breakpoints.up("md"));
|
||||||
@ -76,7 +74,9 @@ export default function Payment() {
|
|||||||
(location.state?.notEnoughMoneyAmount as number) ?? 0;
|
(location.state?.notEnoughMoneyAmount as number) ?? 0;
|
||||||
|
|
||||||
console.log("notEnoughMoneyAmount ", paymentValueField);
|
console.log("notEnoughMoneyAmount ", paymentValueField);
|
||||||
const paymentValue = parseFloat(paymentValueField) * 100;
|
const paymentValue = parseFloat(
|
||||||
|
bigDecimal.multiply(parseFloat(paymentValueField), 100)
|
||||||
|
);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
console.log("notEnoughMoneyAmount ", notEnoughMoneyAmount);
|
console.log("notEnoughMoneyAmount ", notEnoughMoneyAmount);
|
||||||
@ -108,7 +108,11 @@ export default function Payment() {
|
|||||||
fromSquiz,
|
fromSquiz,
|
||||||
body: {
|
body: {
|
||||||
type: selectedPaymentMethod,
|
type: selectedPaymentMethod,
|
||||||
amount: Math.trunc(Number(paymentValueField) * 100 + SAFE_VALUE),
|
amount: Number(
|
||||||
|
bigDecimal.floor(
|
||||||
|
bigDecimal.multiply(Number(paymentValueField), 100)
|
||||||
|
)
|
||||||
|
),
|
||||||
},
|
},
|
||||||
paymentPurpose: notEnoughMoneyAmount ? "paycart" : "replenishwallet",
|
paymentPurpose: notEnoughMoneyAmount ? "paycart" : "replenishwallet",
|
||||||
});
|
});
|
||||||
@ -288,7 +292,7 @@ export default function Payment() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{currencyFormatter.format(
|
{currencyFormatter.format(
|
||||||
Math.trunc(paymentValue + SAFE_VALUE) / 100
|
Number(bigDecimal.divide(bigDecimal.floor(paymentValue), 100))
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
) : (
|
) : (
|
||||||
|
@ -8292,6 +8292,11 @@ jiti@^1.19.1:
|
|||||||
resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.0.tgz#7c97f8fe045724e136a397f7340475244156105d"
|
resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.0.tgz#7c97f8fe045724e136a397f7340475244156105d"
|
||||||
integrity sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==
|
integrity sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==
|
||||||
|
|
||||||
|
js-big-decimal@^2.0.7:
|
||||||
|
version "2.0.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/js-big-decimal/-/js-big-decimal-2.0.7.tgz#fb9b44b4c1eae08903cb191c0cf37b82f3a8d7c4"
|
||||||
|
integrity sha512-XGc79t2Iv3b7LFlYaTT8WoQBuWL4K81aST+dq2YGHV6giedbnoG0s33ju24Uw/BGqLYfPPgn4HGRrPS2mfKk3Q==
|
||||||
|
|
||||||
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
|
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||||
|
Loading…
Reference in New Issue
Block a user