Add opportunities to search and fix a small bug (#6476)
This commit is contained in:
@ -194,6 +194,17 @@ export const CommandMenu = () => {
|
|||||||
limit: 3,
|
limit: 3,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { records: opportunities } = useFindManyRecords({
|
||||||
|
skip: !isCommandMenuOpened,
|
||||||
|
objectNameSingular: CoreObjectNameSingular.Opportunity,
|
||||||
|
filter: commandMenuSearch
|
||||||
|
? {
|
||||||
|
name: { ilike: `%${commandMenuSearch}%` },
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
limit: 3,
|
||||||
|
});
|
||||||
|
|
||||||
const peopleCommands = useMemo(
|
const peopleCommands = useMemo(
|
||||||
() =>
|
() =>
|
||||||
people.map(({ id, name: { firstName, lastName } }) => ({
|
people.map(({ id, name: { firstName, lastName } }) => ({
|
||||||
@ -214,6 +225,16 @@ export const CommandMenu = () => {
|
|||||||
[companies],
|
[companies],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const opportunityCommands = useMemo(
|
||||||
|
() =>
|
||||||
|
opportunities.map(({ id, name }) => ({
|
||||||
|
id,
|
||||||
|
label: name ?? '',
|
||||||
|
to: `object/opportunity/${id}`,
|
||||||
|
})),
|
||||||
|
[opportunities],
|
||||||
|
);
|
||||||
|
|
||||||
const noteCommands = useMemo(
|
const noteCommands = useMemo(
|
||||||
() =>
|
() =>
|
||||||
notes.map((note) => ({
|
notes.map((note) => ({
|
||||||
@ -229,9 +250,10 @@ export const CommandMenu = () => {
|
|||||||
return [
|
return [
|
||||||
...peopleCommands,
|
...peopleCommands,
|
||||||
...companyCommands,
|
...companyCommands,
|
||||||
|
...opportunityCommands,
|
||||||
...noteCommands,
|
...noteCommands,
|
||||||
] as Command[];
|
] as Command[];
|
||||||
}, [peopleCommands, companyCommands, noteCommands]);
|
}, [peopleCommands, companyCommands, noteCommands, opportunityCommands]);
|
||||||
|
|
||||||
const checkInShortcuts = (cmd: Command, search: string) => {
|
const checkInShortcuts = (cmd: Command, search: string) => {
|
||||||
return (cmd.firstHotKey + (cmd.secondHotKey ?? ''))
|
return (cmd.firstHotKey + (cmd.secondHotKey ?? ''))
|
||||||
@ -291,6 +313,7 @@ export const CommandMenu = () => {
|
|||||||
.concat(matchingNavigateCommand.map((cmd) => cmd.id))
|
.concat(matchingNavigateCommand.map((cmd) => cmd.id))
|
||||||
.concat(people.map((person) => person.id))
|
.concat(people.map((person) => person.id))
|
||||||
.concat(companies.map((company) => company.id))
|
.concat(companies.map((company) => company.id))
|
||||||
|
.concat(opportunities.map((opportunity) => opportunity.id))
|
||||||
.concat(notes.map((note) => note.id));
|
.concat(notes.map((note) => note.id));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -339,7 +362,8 @@ export const CommandMenu = () => {
|
|||||||
!matchingNavigateCommand.length &&
|
!matchingNavigateCommand.length &&
|
||||||
!people.length &&
|
!people.length &&
|
||||||
!companies.length &&
|
!companies.length &&
|
||||||
!notes.length && (
|
!notes.length &&
|
||||||
|
!opportunities.length && (
|
||||||
<StyledEmpty>No results found</StyledEmpty>
|
<StyledEmpty>No results found</StyledEmpty>
|
||||||
)}
|
)}
|
||||||
{isCopilotEnabled && (
|
{isCopilotEnabled && (
|
||||||
@ -437,6 +461,29 @@ export const CommandMenu = () => {
|
|||||||
</SelectableItem>
|
</SelectableItem>
|
||||||
))}
|
))}
|
||||||
</CommandGroup>
|
</CommandGroup>
|
||||||
|
<CommandGroup heading="Opportunities">
|
||||||
|
{opportunities.map((opportunity) => (
|
||||||
|
<SelectableItem
|
||||||
|
itemId={opportunity.id}
|
||||||
|
key={opportunity.id}
|
||||||
|
>
|
||||||
|
<CommandMenuItem
|
||||||
|
id={opportunity.id}
|
||||||
|
key={opportunity.id}
|
||||||
|
label={opportunity.name}
|
||||||
|
to={`object/opportunity/${opportunity.id}`}
|
||||||
|
Icon={() => (
|
||||||
|
<Avatar
|
||||||
|
type="rounded"
|
||||||
|
avatarUrl={null}
|
||||||
|
placeholderColorSeed={opportunity.id}
|
||||||
|
placeholder={opportunity.name}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</SelectableItem>
|
||||||
|
))}
|
||||||
|
</CommandGroup>
|
||||||
<CommandGroup heading="Notes">
|
<CommandGroup heading="Notes">
|
||||||
{notes.map((note) => (
|
{notes.map((note) => (
|
||||||
<SelectableItem itemId={note.id} key={note.id}>
|
<SelectableItem itemId={note.id} key={note.id}>
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export const getFirstNonEmptyLineOfRichText = (
|
|||||||
const contentArray = node.content as Array<{ text: string }>;
|
const contentArray = node.content as Array<{ text: string }>;
|
||||||
if (contentArray.length > 0) {
|
if (contentArray.length > 0) {
|
||||||
for (const content of contentArray) {
|
for (const content of contentArray) {
|
||||||
if (content.text.trim() !== '') {
|
if (content.text?.trim() !== '') {
|
||||||
return content.text;
|
return content.text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user