All files / src/components/Chatbot MessageWithIcon.tsx

100% Statements 24/24
100% Branches 5/5
100% Functions 1/1
100% Lines 24/24

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  1x 1x 1x         1x               1x 3x 3x 3x 3x 3x   3x 3x 3x 2x   1x   3x 3x 3x 3x 3x   3x 3x 3x   3x  
// Icons
import { QUERY_STATUS } from '@/types';
import { CheckCircleIcon } from '@shared/icons/CheckCircleIcon';
import { WarningIcon } from '@shared/icons/WarningIcon';
 
// Types
 
// Utils
import { combineClasses } from '@shared/utils';
 
interface MessageWithIconProps {
  message: string;
  type?: QUERY_STATUS;
  className?: string;
}
 
export const MessageWithIcon = ({
  message,
  type = QUERY_STATUS.SUCCESS,
  className,
}: MessageWithIconProps) => {
  const isSuccess = type === QUERY_STATUS.SUCCESS;
 
  return (
    <div className={combineClasses('flex items-start gap-2 mt-2', className)}>
      {isSuccess ? (
        <CheckCircleIcon className="size-3.5 mt-1" />
      ) : (
        <WarningIcon className="size-3.5 mt-1 fill-destructive" />
      )}
      <div
        className={combineClasses(
          'w-fit text-3xs success-message',
          isSuccess ? 'text-success-secondary' : 'text-destructive',
        )}
      >
        {message}
      </div>
    </div>
  );
};