This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: improve `sendMessage` mutation * feat: ticket comments * refactor: rename sender to author * chore: cleanup * feat: add command menu
- Loading branch information
1 parent
c3ab2fd
commit 8206268
Showing
33 changed files
with
1,018 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
apps/customer-service/src/components/command-menu/command-menu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
'use client'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { useSetAtom } from 'jotai'; | ||
import { FormattedMessage, useIntl } from 'react-intl'; | ||
|
||
import { messageModeAtom } from '~/components/messages/message-mode-atom'; | ||
import { | ||
CommandDialog, | ||
CommandEmpty, | ||
CommandGroup, | ||
CommandInput, | ||
CommandItem, | ||
CommandList, | ||
} from '~/components/ui/command'; | ||
|
||
export function CommandMenu() { | ||
const { formatMessage } = useIntl(); | ||
|
||
const [open, setOpen] = useState(false); | ||
const setMessageMode = useSetAtom(messageModeAtom); | ||
|
||
useEffect(() => { | ||
const down = (e: KeyboardEvent) => { | ||
if (e.key === 'k' && (e.metaKey || e.ctrlKey)) { | ||
e.preventDefault(); | ||
setOpen((open) => !open); | ||
} | ||
}; | ||
document.addEventListener('keydown', down); | ||
return () => document.removeEventListener('keydown', down); | ||
}, []); | ||
|
||
return ( | ||
<CommandDialog open={open} onOpenChange={setOpen}> | ||
<CommandInput | ||
placeholder={formatMessage({ id: 'command_menu.search.placeholder' })} | ||
/> | ||
<CommandList> | ||
<CommandEmpty> | ||
<FormattedMessage id="command_menu.no_results" /> | ||
</CommandEmpty> | ||
<CommandGroup heading={formatMessage({ id: 'command_menu.commands' })}> | ||
<CommandItem | ||
onSelect={() => { | ||
setMessageMode('comment'); | ||
setOpen(false); | ||
}} | ||
> | ||
<span> | ||
<FormattedMessage id="command_menu.commands.write_note" /> | ||
</span> | ||
</CommandItem> | ||
<CommandItem | ||
onSelect={() => { | ||
setMessageMode('message'); | ||
setOpen(false); | ||
}} | ||
> | ||
<span> | ||
<FormattedMessage id="command_menu.commands.write_message" /> | ||
</span> | ||
</CommandItem> | ||
<CommandItem> | ||
<span> | ||
<FormattedMessage id="command_menu.commands.assign_to_me" /> | ||
</span> | ||
</CommandItem> | ||
</CommandGroup> | ||
</CommandList> | ||
</CommandDialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.