|
|
@@ -8,7 +8,9 @@ import {
|
|
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
import { router } from 'expo-router';
|
|
|
import { CrossLogoSvg } from '../global/SVG';
|
|
|
-
|
|
|
+import { useEffect, useState } from 'react';
|
|
|
+import * as SecureStore from 'expo-secure-store';
|
|
|
+import { walletService } from '../../service/walletService';
|
|
|
const coupons = [
|
|
|
{
|
|
|
title: '迎新優惠券',
|
|
|
@@ -89,7 +91,27 @@ export const IndividualCouponComponent = ({
|
|
|
);
|
|
|
|
|
|
const WalletPageComponent = () => {
|
|
|
- const image = { uri: 'https://legacy.reactjs.org/logo-og.png' };
|
|
|
+ const [token, setToken] = useState<string | null>(null);
|
|
|
+ const [walletBalance, setWalletBalance] = useState<string | null>(null);
|
|
|
+ useEffect(() => {
|
|
|
+ const getToken = async () => {
|
|
|
+ const storedToken = await SecureStore.getItemAsync('accessToken');
|
|
|
+ setToken(storedToken);
|
|
|
+ };
|
|
|
+ getToken();
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ const fetchWalletBalance = async () => {
|
|
|
+ if (token) {
|
|
|
+ const balance = await walletService.getWalletBalance(token);
|
|
|
+ setWalletBalance(balance);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ fetchWalletBalance();
|
|
|
+ }, [token]);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
return (
|
|
|
<SafeAreaView
|
|
|
@@ -130,7 +152,7 @@ const WalletPageComponent = () => {
|
|
|
style={{ fontSize: 52 }}
|
|
|
className=" text-white font-bold"
|
|
|
>
|
|
|
- $2711.8
|
|
|
+ {walletBalance}
|
|
|
</Text>
|
|
|
<Pressable
|
|
|
className="rounded-2xl items-center justify-center p-3 px-5 pr-6 "
|