accept result rank prop
Signed-off-by: Emma Indal <emma.indahl@gmail.com>
This commit is contained in:
+11
-1
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user