accept result rank prop

Signed-off-by: Emma Indal <emma.indahl@gmail.com>
This commit is contained in:
Emma Indal
2022-11-14 10:50:59 +01:00
parent bab2ae85a5
commit 4043f4c6cf
@@ -25,19 +25,29 @@ import {
Box,
Chip,
} from '@material-ui/core';
import { useAnalytics } from '@backstage/core-plugin-api';
type StackOverflowSearchResultListItemProps = {
result: any; // TODO(emmaindal): type to StackOverflowDocument.
icon?: React.ReactNode;
rank?: number;
};
export const StackOverflowSearchResultListItem = (
props: StackOverflowSearchResultListItemProps,
) => {
const { location, title, text, answers, tags } = props.result;
const analytics = useAnalytics();
const handleClick = () => {
analytics.captureEvent('discover', title, {
attributes: { to: location },
value: props.rank,
});
};
return (
<Link to={location}>
<Link to={location} noTrack onClick={handleClick}>
<ListItem alignItems="center">
{props.icon && <ListItemIcon>{props.icon}</ListItemIcon>}
<Box flexWrap="wrap">