refactor calculation code
- implement fee - centralize the code
This commit is contained in:
@@ -3,7 +3,11 @@ import { Group } from "antd/es/radio";
|
||||
import ArabicPrice from "components/ArabicPrice";
|
||||
import DifferentCardIcon from "components/Icons/paymentMethods/DifferentCardIcon";
|
||||
import ProText from "components/ProText";
|
||||
import { selectCart, updatePaymentMethod } from "features/order/orderSlice";
|
||||
import {
|
||||
selectCart,
|
||||
selectGrandTotal,
|
||||
updatePaymentMethod,
|
||||
} from "features/order/orderSlice";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||
import { colors, ProGray1 } from "../../ThemeConstants";
|
||||
@@ -14,6 +18,7 @@ const PaymentMethods = () => {
|
||||
const { t } = useTranslation();
|
||||
const { paymentMethod, orderType } = useAppSelector(selectCart);
|
||||
const dispatch = useAppDispatch();
|
||||
const grandTotal = useAppSelector(selectGrandTotal);
|
||||
|
||||
const options: {
|
||||
label: string;
|
||||
@@ -21,26 +26,35 @@ const PaymentMethods = () => {
|
||||
price?: string;
|
||||
icon?: React.ReactNode;
|
||||
style?: React.CSSProperties;
|
||||
hideCurrency?: boolean;
|
||||
}[] = [
|
||||
...(orderType !== "gift"
|
||||
? [
|
||||
{
|
||||
label: t("checkout.creditDebitCard"),
|
||||
value: "creditDebitCard",
|
||||
price: t("checkout.expiresIn") + ":12/26",
|
||||
label: t("checkout.cash"),
|
||||
value: "cash",
|
||||
price: grandTotal.toString(),
|
||||
style: {
|
||||
color: colors.primary,
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
|
||||
{
|
||||
label: t("checkout.creditDebitCard"),
|
||||
value: "creditDebitCard",
|
||||
price: t("checkout.expiresIn") + ":12/26",
|
||||
hideCurrency: true,
|
||||
},
|
||||
{
|
||||
label: t("checkout.differentCard"),
|
||||
value: "differentCard",
|
||||
icon: (
|
||||
<div className={styles.differentCardIcon}>
|
||||
{" "}
|
||||
<DifferentCardIcon />
|
||||
</div>
|
||||
),
|
||||
hideCurrency: true,
|
||||
},
|
||||
{
|
||||
label: t("checkout.fascanoWallet"),
|
||||
@@ -108,6 +122,7 @@ const PaymentMethods = () => {
|
||||
{!option.icon ? (
|
||||
<ArabicPrice
|
||||
price={option.price || 0}
|
||||
hideCurrency={option.hideCurrency}
|
||||
style={{
|
||||
fontSize: "0.75rem",
|
||||
color: ProGray1,
|
||||
|
||||
Reference in New Issue
Block a user