// ViewReviewPage.tsx
import React, { useState, useEffect } from 'react';
import { useLocation } from 'umi'; // 或者 'react-router-dom'
import ResultModal from './components/ResultModal';
import ViewModal from './components/ViewModal';

const ViewReviewPage: React.FC = () => {
  const [modalVisible, setModalVisible] = useState(false); // 控制弹窗
  const [modalRecord, setModalRecord] = useState<any>(null);

  // 解析url参数 ?id=xxx
  const location = useLocation();
  useEffect(() => {
    // 获取id参数
    const params = new URLSearchParams(location.search);
    const id = params.get('id');
    if (id) {
      setModalRecord({ id }); // 只传id也可以，后面可以根据id扩展更多参数

      setModalVisible(true);
    }
  }, [location.search]);

  return (
    <div style={{padding: '20px'}}>
      {/* 其他页面内容  */}
      <ViewModal
        visible={modalVisible}
        record={modalRecord}
        onCancel={() => setModalVisible(false)}
      />
      <ResultModal
        visible={modalVisible}
        record={modalRecord}
        onCancel={() => setModalVisible(false)}
      />
    </div>
  );
};

export default ViewReviewPage;
