All files / src/components/admin/monitoring PrioritySelector.tsx

100% Statements 63/63
100% Branches 4/4
100% Functions 2/2
100% Lines 63/63

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 641x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 23x 23x 23x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 116x 116x 116x 29x 29x 29x 29x 29x 1x 1x  
'use client';
 
import { Input } from '@/components/ui';
import type { ErrorPriority } from '@prisma/client';
 
export interface PrioritySelectorProps {
  /** Current priority value */
  value: ErrorPriority | string;
  /** Callback when priority changes */
  onChange: (priority: ErrorPriority) => void;
  /** Disable the selector */
  disabled?: boolean;
  /** Optional label */
  label?: string;
  /** Optional className */
  className?: string;
}
 
const priorities: Array<{ value: ErrorPriority; label: string }> = [
  { value: 'LOW', label: 'Low' },
  { value: 'MEDIUM', label: 'Medium' },
  { value: 'HIGH', label: 'High' },
  { value: 'CRITICAL', label: 'Critical' },
];
 
/**
 * PrioritySelector Component
 *
 * Dropdown for selecting error priority level.
 */
export function PrioritySelector({
  value,
  onChange,
  disabled = false,
  label,
  className = '',
}: PrioritySelectorProps) {
  return (
    <div className={className}>
      {label && (
        <label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
          {label}
        </label>
      )}
      <Input
        as="select"
        value={value}
        onChange={(e) => onChange(e.target.value as ErrorPriority)}
        disabled={disabled}
        size="sm"
        data-testid="priority-selector"
      >
        {priorities.map((p) => (
          <option key={p.value} value={p.value}>
            {p.label}
          </option>
        ))}
      </Input>
    </div>
  );
}
 
export default PrioritySelector;