All files / src/components/monitors EditMonitorModal.tsx

100% Statements 30/30
100% Branches 2/2
100% Functions 2/2
100% Lines 30/30

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 431x                   6x 6x 6x 6x 6x 6x 6x 6x 6x 6x   6x 6x 6x 6x 6x 6x 6x 6x 2x 2x 2x 2x 2x   6x 6x 6x 6x 6x   6x  
import MonitorForm from "./MonitorForm";
import type { MonitorRead, MonitorUpdate } from "../../types/monitor";
 
interface EditMonitorModalProps {
  monitor: MonitorRead;
  onSave: (id: string, data: MonitorUpdate) => void;
  onClose: () => void;
  isLoading?: boolean;
}
 
export default function EditMonitorModal({
  monitor,
  onSave,
  onClose,
  isLoading,
}: EditMonitorModalProps) {
  return (
    <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4">
      <div className="w-full max-w-md rounded-lg bg-white p-6 shadow-lg">
        <h2 className="text-lg font-semibold text-gray-900 mb-4">
          Edit Monitor
        </h2>
        <MonitorForm
          initialData={{
            url: monitor.url,
            interval_seconds: monitor.interval_seconds,
            is_active: monitor.is_active,
          }}
          onSubmit={(data) =>
            onSave(monitor.id, {
              url: data.url,
              interval_seconds: data.interval_seconds,
              is_active: data.is_active,
            })
          }
          onCancel={onClose}
          isLoading={isLoading}
        />
      </div>
    </div>
  );
}