|
|
@@ -18,25 +18,28 @@ import {
|
|
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
import { router } from 'expo-router';
|
|
|
import { CrossLogoSvg } from '../global/SVG';
|
|
|
-import { useEffect, useRef, useState } from 'react';
|
|
|
+import { use, useEffect, useRef, useState } from 'react';
|
|
|
import { walletService } from '../../service/walletService';
|
|
|
import NormalButton from '../global/normal_button';
|
|
|
import sha256 from 'crypto-js/sha256';
|
|
|
import { useChargingStore } from '../../providers/scan_qr_payload_store';
|
|
|
+import { PaymentBonusList } from '../../service/type/walletServiceType';
|
|
|
interface AmountInputModalProps {
|
|
|
visible: boolean;
|
|
|
onClose: () => void;
|
|
|
onConfirm: (amount: number) => void;
|
|
|
}
|
|
|
const AmountInputModal = ({ visible, onClose, onConfirm }: AmountInputModalProps) => {
|
|
|
- const amounts = [
|
|
|
- // { amount: 1, percentage: 0 },
|
|
|
- { amount: 200, percentage: 0 },
|
|
|
- { amount: 500, percentage: 25 },
|
|
|
- { amount: 1000, percentage: 100 },
|
|
|
- { amount: 2000, percentage: 300 }
|
|
|
- ];
|
|
|
-
|
|
|
+ const [amounts, setAmounts] = useState<Array<{amount: number, percentage: number}>>([]);
|
|
|
+ useEffect(() => {
|
|
|
+ const fetchData = async () => {
|
|
|
+ const res: PaymentBonusList[] = await walletService.getPaymentBonusList()
|
|
|
+ setAmounts(res.map(item => ({amount: item.base_amount, percentage: item.gift_amount})))
|
|
|
+ }
|
|
|
+ if (visible){
|
|
|
+ fetchData()
|
|
|
+ }
|
|
|
+ }, [visible])
|
|
|
const getFontSize = () => {
|
|
|
const { width } = Dimensions.get('window');
|
|
|
if (width < 320) return 8;
|
|
|
@@ -137,7 +140,7 @@ export const IndividualCouponComponent = ({
|
|
|
onPress={setOpacity ? () => {} : () => onCouponClick(redeem_code as string, title)}
|
|
|
>
|
|
|
{/* price column on the left */}
|
|
|
- <View className="flex-row items-center w-[31%] items-center justify-center">
|
|
|
+ <View className="flex-row items-center w-[31%] justify-center">
|
|
|
<Text className="pl-1 lg:pl-2 text-[#02677D] text-base md:text-lg lg:text-xl">$</Text>
|
|
|
<Text className="text-3xl lg:text-4xl text-[#02677D] font-[600]">{price}</Text>
|
|
|
</View>
|
|
|
@@ -186,11 +189,9 @@ export const IndividualCouponComponent = ({
|
|
|
const WalletPageComponent = () => {
|
|
|
const [walletBalance, setWalletBalance] = useState<string | null>(null);
|
|
|
const [loading, setLoading] = useState<boolean>(false);
|
|
|
- const [modalVisible, setModalVisible] = useState(false);
|
|
|
const [coupons, setCoupons] = useState([]);
|
|
|
const [paymentType, setPaymentType] = useState({});
|
|
|
const [userID, setUserID] = useState('');
|
|
|
- const [selectedPaymentType, setSelectedPaymentType] = useState<string | null>(null);
|
|
|
const [amount, setAmount] = useState<number>(0);
|
|
|
const [amountModalVisible, setAmountModalVisible] = useState(false);
|
|
|
const [outTradeNo, setOutTradeNo] = useState('');
|