'use client';

import { Typography } from '@mui/material';
import { useEffect, useState } from 'react';
import axios from 'axios';

export default function IDollarYuan() {
    const [yuan, setYuan] = useState<string | undefined>('');

    useEffect(() => {
        axios.get('https://api.exchangerate-api.com/v4/latest/USD').then(res => {
            setYuan(res.data?.rates?.CNY);
        });
    }, []);

    if (!yuan) return null;

    return <Typography>1 USD = {yuan} Y</Typography>;
}
