2024-06-28 12:40:44 +02:00
|
|
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import {
|
|
|
|
CommandResultGroup,
|
|
|
|
StyledButtonTypography,
|
|
|
|
StyledListItemIcon,
|
|
|
|
StyledListItemText,
|
|
|
|
listItemButtonStyle,
|
|
|
|
type CommandResultGroupItem,
|
|
|
|
} from './RecentlyVisited/CommandResultGroup';
|
|
|
|
import { ListItemButton } from '@mui/material';
|
|
|
|
import { IconRenderer } from 'component/layout/MainLayout/NavigationSidebar/IconRenderer';
|
|
|
|
|
2024-07-02 12:59:18 +02:00
|
|
|
export const CommandSearchPages = ({
|
2024-06-28 12:40:44 +02:00
|
|
|
items,
|
2024-07-02 10:12:08 +02:00
|
|
|
onClick,
|
2024-06-28 12:40:44 +02:00
|
|
|
}: {
|
|
|
|
items: CommandResultGroupItem[];
|
2024-07-02 10:12:08 +02:00
|
|
|
onClick: () => void;
|
2024-06-28 12:40:44 +02:00
|
|
|
}) => {
|
|
|
|
const { trackEvent } = usePlausibleTracker();
|
|
|
|
const groupName = 'Pages';
|
|
|
|
|
2024-07-02 10:12:08 +02:00
|
|
|
const onItemClick = (item: CommandResultGroupItem) => {
|
2024-06-28 12:40:44 +02:00
|
|
|
trackEvent('command-bar', {
|
|
|
|
props: {
|
|
|
|
eventType: `click`,
|
|
|
|
source: 'search',
|
|
|
|
eventTarget: groupName,
|
|
|
|
...(groupName === 'Pages' && { pageType: item.name }),
|
|
|
|
},
|
|
|
|
});
|
2024-07-02 10:12:08 +02:00
|
|
|
onClick();
|
2024-06-28 12:40:44 +02:00
|
|
|
};
|
|
|
|
return (
|
2024-07-02 10:12:08 +02:00
|
|
|
<CommandResultGroup
|
|
|
|
groupName={'Pages'}
|
|
|
|
icon={'default'}
|
|
|
|
onClick={onClick}
|
|
|
|
>
|
2024-06-28 12:40:44 +02:00
|
|
|
{items.map((item, index) => (
|
|
|
|
<ListItemButton
|
|
|
|
key={`command-result-group-pages-${index}`}
|
|
|
|
dense={true}
|
|
|
|
component={Link}
|
|
|
|
to={item.link}
|
|
|
|
onClick={() => {
|
2024-07-02 10:12:08 +02:00
|
|
|
onItemClick(item);
|
2024-06-28 12:40:44 +02:00
|
|
|
}}
|
|
|
|
sx={listItemButtonStyle}
|
|
|
|
>
|
2024-07-02 11:33:37 +02:00
|
|
|
<StyledListItemIcon>
|
2024-06-28 12:40:44 +02:00
|
|
|
<IconRenderer path={item.link} />
|
|
|
|
</StyledListItemIcon>
|
|
|
|
<StyledListItemText>
|
|
|
|
<StyledButtonTypography color='textPrimary'>
|
|
|
|
{item.name}
|
|
|
|
</StyledButtonTypography>
|
|
|
|
</StyledListItemText>
|
|
|
|
</ListItemButton>
|
|
|
|
))}
|
|
|
|
</CommandResultGroup>
|
|
|
|
);
|
|
|
|
};
|