import React from 'react';
import superagent from 'superagent';
import { Segment, Header, Message, Icon, Table } from 'semantic-ui-react'
import ApiButtonModal from '../../../CloudApi/ApiButtonModal.jsx';
export default class AccountGDPRScanDeletion extends React.Component {
constructor(props) {
super(props);
this.state = {
loading: false,
dryRunResults: null,
deletionResults: null,
error: null
};
}
async onDryRunDeletion() {
this.setState({ loading: true, error: null, dryRunResults: null });
try {
const res = await superagent
.delete(`/api/admin/fabricator/account/${this.props.account.id}/scan_data?dryRun=1`)
.accept('json');
console.log('Dry run results:', res.body);
this.setState({
dryRunResults: res.body,
loading: false
});
} catch (e) {
console.error('Dry run error:', e);
this.setState({
error: e.response?.body?.message || 'Failed to perform dry run',
loading: false
});
}
}
async onDeleteScanData() {
this.setState({ loading: true, error: null, deletionResults: null });
try {
const res = await superagent
.delete(`/api/admin/fabricator/account/${this.props.account.id}/scan_data`)
.accept('json');
console.log('Deletion results:', res.body);
this.setState({
deletionResults: res.body,
loading: false,
dryRunResults: null
});
} catch (e) {
console.error('Deletion error:', e);
this.setState({
error: e.response?.body?.message || 'Failed to delete scan data',
loading: false
});
}
}
renderResultsTable(results, title) {
if (!results) return null;
const { scanRequests, scans } = results;
return (
)}
{scanRequests.items && scanRequests.items.length > 25 && (
)}
{scans.items && scans.items.length > 25 && (
{this.state.error}
First, perform a dry run to see what scan data will be deleted without actually deleting it. This will show you all scan requests and scans that would be affected.