import React from "react";
import * as File from "utils/file"
import {Button, Modal, Nav} from "react-bootstrap";

function HistoryModal({closeFn, standardCode}){
    function fileDownloadStandardCode(fileSeq){
        File.standardCode(fileSeq);
    }

    function fileDownload(fileSeq){
        File.download(fileSeq);
    }

    return(
        <>
            <Modal.Header closeButton>
                <Modal.Title id="example-modal-sizes-title-lg">개정이력</Modal.Title>
            </Modal.Header>
            <Modal.Body>
                <div>코드 : {standardCode.kcscCd}</div>
                <div className="board_list standard_code_modal">
                    <div className="head">
                        <span>고시일</span>
                        <span>기준코드</span>
                        <span>신구건설기준비교</span>
                    </div>
                    <div className={"result"}>
                        {standardCode.historyList.filter(history => {
                            return history;
                        }).map(history => {
                            return (
                                <div className="list_item">
                                    <div className="mainCategory">{history.rvsnYmd.split('T')[0]}</div>
                                    <div className="middleCategory">
                                        {history.docFileGrpId}
                                        {history.docFileGrpId?<Button size={"sm"} variant={"outline-secondary"} onClick={()=>fileDownloadStandardCode(history.docFileGrpId)}>다운로드 </Button>:''}
                                    </div>
                                    <div className="kcscCd">
                                        {history.rvsnFileGrpId}
                                        {history.rvsnFileGrpId?<Button size={"sm"} variant={"outline-secondary"} onClick={()=>fileDownload(history.rvsnFileGrpId)}>다운로드 </Button>:''}
                                    </div>
                                </div>
                            )
                        })}
                    </div>
                </div>
            </Modal.Body>
            <Modal.Footer><Button onClick={closeFn}>닫기</Button></Modal.Footer>
        </>
    )
}

export default HistoryModal;