All files / apps/web/src/backoffice/components FormField.jsx

0% Statements 0/3
0% Branches 0/10
0% Functions 0/3
0% Lines 0/3

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                                                         
export function FormField({ label, error, children, required }) {
  return (
    <div>
      {label && (
        <label className="block text-sm font-medium text-gray-700 mb-2">
          {label}
          {required && <span className="text-red-500 ml-1">*</span>}
        </label>
      )}
      {children}
      {error && (
        <p className="mt-1 text-sm text-red-600">{error}</p>
      )}
    </div>
  );
}
 
export function getFieldClass(hasError) {
  return hasError 
    ? 'w-full p-2 border border-red-500 bg-red-50 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent' 
    : 'w-full p-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent';
}
 
export function getContainerClass(hasError) {
  return hasError 
    ? 'border border-red-500 bg-red-50 rounded-lg p-4' 
    : 'border border-gray-300 rounded-lg p-4';
}