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 (
{title}
{scanRequests && (
Scan Requests: {scanRequests.items.length || 0} found
{scanRequests.items && scanRequests.items.length > 0 && ( ID Created Status {scanRequests.items.slice(0, 25).map((item, idx) => ( {item.id} {item.createdAt ? new Date(item.createdAt).toLocaleString() : 'N/A'} {item.scanRequestState || 'N/A'} ))}
)} {scanRequests.items && scanRequests.items.length > 25 && ( Showing first 25 of {scanRequests.items.length} scan requests )}
)} {scans && (
Scans: {scans.items.length || 0} found
{scans.items && scans.items.length > 0 && ( ID Created Status {scans.items.slice(0, 25).map((item, idx) => ( {item.id} {item.createdAt ? new Date(item.createdAt).toLocaleString() : 'N/A'} {item.status || 'N/A'} ))}
)} {scans.items && scans.items.length > 25 && ( Showing first 25 of {scans.items.length} scans )}
)}
); } render() { return (
GDPR Scan Data Deletion Permanently delete all scan data for this customer account
{this.state.error && ( Error

{this.state.error}

)}
Step 1: Dry Run

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.

Dry Run Mode This will query all scan data for account {this.props.account.username || this.props.account.id} without deleting anything. You will see a preview of what would be deleted. {this.state.dryRunResults && this.renderResultsTable( this.state.dryRunResults, 'Dry Run Results - Data that would be deleted:' )}
Step 2: Permanent Deletion
Warning: This action is permanent This will permanently delete all scan data for this customer. This action cannot be undone. Permanent Deletion Warning Are you absolutely sure you want to permanently delete all scan data for account {this.props.account.username || this.props.account.id}?

This will delete:
  • All scan requests
  • All scan data files
  • All associated metadata

This action cannot be undone.
{this.state.deletionResults && ( Deletion Completed Successfully {this.renderResultsTable( this.state.deletionResults, 'Deleted Data Summary:' )} )}
); } }