All files / src/components/Chatbot UserMessage.tsx

95.65% Statements 22/23
75% Branches 3/4
100% Functions 1/1
95.65% Lines 22/23

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    1x 2x 2x 2x 2x 2x   2x 2x 2x 2x 2x 2x 2x 1x     1x   1x     1x 2x 2x 2x 2x   2x  
import { UserMessageProps } from '@copilotkit/react-ui';
 
export const UserMessage = ({
  message: originalMessage,
  rawData,
}: UserMessageProps) => {
  const message =
    typeof originalMessage === 'string'
      ? (originalMessage as string).trim()
      : (originalMessage as unknown as { content: string })?.content?.trim();
  return (
    <div className="flex items-start gap-4 py-2.5 flex-row-reverse">
      <div className="relative py-2.5 px-[15px] rounded-lg w-fit max-w-cb-message-box text-3xs text-left text-muted-foreground leading-5 bg-primary-200 border border-primary-200 shadow-sm break-words dark:text-background dark:bg-secondary-950 dark:border-secondary-950">
        <p
          dangerouslySetInnerHTML={{
            __html: rawData?.image
              ? `
          <div class="flex flex-col gap-2">
            <span class="text-3xs leading-tight font-normal">
              ${message}
            </span>
            <img src="${rawData?.image}" alt="Preview asset" width="55" />
          </div>
        `
              : message,
          }}
        />
      </div>
    </div>
  );
};