import React, { useRef, useEffect } from 'react';
import superagent from 'superagent';
import { fromUnixTime, formatDistanceToNow } from "date-fns";
import { formatInTimeZone } from 'date-fns-tz';
import ClickableTableRow from "../Util/ClickableTableRow.jsx";
import * as ApiUtils from '../CloudApi/ApiUtils.js';
import constants, { DEFAULT_TIMEZONE } from '../CloudApi/Constants.js';
import WaxIdBitField from './WaxIdBitField.jsx';
import ToolPathDownloadButton from './ToolPathDownloadButton.jsx';
import { Header, Message, Icon, Button, Table, Label, Modal } from 'semantic-ui-react'
export default class ScanRequestsTable extends React.Component {
constructor(props) {
super(props);
this.state = {
loading: false,
revokeScanRequestModalOpen: false,
};
}
showRevokeScanRequestModal() {}
openRevokeScanRequestModal(i, e) {
this.setState({ revokeScanRequestModalOpen: true});
}
closeRevokeScanRequestModal(i, e) {
this.setState({ revokeScanRequestModalOpen: false});
}
async onRevokeScanRequest(e) {
e.preventDefault();
this.setState({ loading: true });
try {
let res = await superagent.put(`/api/admin/fabricator/scan_request/${scanRequest.id}`).send({
scanRequestState: this.props.schemas.ScanRequestStates["Revoked"]
});
window.location.reload();
} catch (e) {
window.alert("Error sending scan request email: " + e.message);
console.error(e);
}
this.setState({ loading: false, revokeScanRequestModalOpen: false});
}
onClickScanRequest(scanRequest, e) {
window.location.href = `/fabricator/scan_request/${scanRequest.id}`;
}
renderIpdLabel() {
}
renderScanRequestRow(scanRequest) {
if (scanRequest.scanRequestState === this.props.schemas.ScanRequestStates["Revoked"]) {
return (