All files / components/CATME CATMEAuditResults.jsx

100% Statements 5/5
100% Branches 12/12
100% Functions 3/3
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80        15x 15x   15x                                                             10x                                                       10x                          
import React from "react";
import { Alert, Table } from "react-bootstrap";
 
export default function CATMEAuditResults({ result }) {
  const updates = result.studentsToUpdate ?? [];
  const drops = result.studentsToDrop ?? [];
 
  return (
    <div className="mt-4" data-testid="catme-audit-results">
      <h5>Audit Results</h5>
 
      {updates.length === 0 && drops.length === 0 ? (
        <Alert variant="success">
          No student updates or removals were detected.
        </Alert>
      ) : (
        <Alert variant="warning">
          Found {updates.length} updates and {drops.length} removals.
        </Alert>
      )}
 
      <h6>Students to Update ({updates.length})</h6>
 
      {updates.length === 0 ? (
        <p>No students need updating.</p>
      ) : (
        <Table striped bordered hover responsive>
          <thead>
            <tr>
              <th>Student ID</th>
              <th>Name</th>
              <th>Field</th>
              <th>Old Value</th>
              <th>New Value</th>
            </tr>
          </thead>
          <tbody>
            {updates.map((student, index) => (
              <tr key={`${student.studentId}-${student.field}-${index}`}>
                <td>{student.studentId}</td>
                <td>{student.name}</td>
                <td>{student.field}</td>
                <td>{student.oldValue}</td>
                <td>{student.newValue}</td>
              </tr>
            ))}
          </tbody>
        </Table>
      )}
 
      <h6>Students to Drop ({drops.length})</h6>
 
      {drops.length === 0 ? (
        <p>No students need removing.</p>
      ) : (
        <Table striped bordered hover responsive>
          <thead>
            <tr>
              <th>Student ID</th>
              <th>Name</th>
              <th>Email</th>
              <th>Section</th>
            </tr>
          </thead>
          <tbody>
            {drops.map((student, index) => (
              <tr key={`${student.studentId}-${index}`}>
                <td>{student.studentId}</td>
                <td>{student.name}</td>
                <td>{student.email}</td>
                <td>{student.section}</td>
              </tr>
            ))}
          </tbody>
        </Table>
      )}
    </div>
  );
}