import type { FunctionComponent } from 'react'; import { useState } from 'react'; import { Label, LabelGroup, LabelGroupProps, LabelProps } from '@patternfly/react-core'; import { CheckIcon } from '@patternfly/react-icons'; import { css } from '@patternfly/react-styles'; export interface QuickResponse extends Omit { content: string; id: string; onClick?: () => void; } export interface QuickResponseProps { /** Props for quick responses */ quickResponses: QuickResponse[]; /** Props for quick responses container */ quickResponseContainerProps?: Omit; /** Callback when a response is clicked; used in feedback cards */ onSelect?: (id: string) => void; /** Sets the quick responses to compact styling */ isCompact?: boolean; } export const QuickResponse: FunctionComponent = ({ quickResponses, quickResponseContainerProps = { numLabels: 5 }, onSelect, isCompact }: QuickResponseProps) => { const [selectedQuickResponse, setSelectedQuickResponse] = useState(); const handleQuickResponseClick = (id: string, onClick?: () => void) => { setSelectedQuickResponse(id); onClick && onClick(); onSelect && onSelect(id); }; return ( {quickResponses.map(({ id, onClick, content, className, ...props }: QuickResponse) => ( ))} ); }; export default QuickResponse;