import React, { useEffect, useState } from 'react';
import Title from '../../forge/Component/Title';
import RenderHtml from '../../components/render-html';
import { Button } from 'antd';
import { Skeleton } from 'antd';
import Axios from 'axios';

function Public(props){
  const [value , setValue ] = useState(undefined);
  const id = props.match.params.id;

  useEffect(()=>{
    if(id && id!==value){
      setValue(parseInt(id));
      console.log(id);
    }
  },[id])

  useEffect(()=>{
    const url = `/helps/${id}.josn`;
    Axios.get(url).then(result=>{
        if(result){
            setValue(result.data.data.content);
        }
    }).catch(error=>{})
  },[id])

  return(
    <div>
      {/* <Button type={"primary"}>下载</Button> */}
      <Title>木兰公共许可证</Title>
      <div class="contents">
        <div className="pre">
          {
            value ? 
            <RenderHtml className="break_word_comments imageLayerParent" value={value} url={props.history.location}/>
            :
            <Skeleton />
          }
        </div>
      </div>
    </div>
  )
}
export default Public;