|
1 | | -import { Button } from "@/common/components/ui/button"; |
2 | | -import { |
3 | | - DropdownMenu, |
4 | | - DropdownMenuContent, |
5 | | - DropdownMenuItem, |
6 | | - DropdownMenuLabel, |
7 | | - DropdownMenuSeparator, |
8 | | - DropdownMenuTrigger, |
9 | | -} from "@/common/components/ui/dropdown-menu"; |
10 | 1 | import { EllipsisVertical } from "lucide-react"; |
11 | 2 | import { Post } from "./post.types"; |
12 | | - |
13 | | -type MenuOption = { |
14 | | - id: string; |
15 | | - label: string; |
16 | | - description?: string; |
17 | | - condition?: (post: Post) => boolean; |
18 | | - disabled?: (post: Post) => boolean; |
19 | | - onClick: (post: Post) => void; |
20 | | - separatorBefore?: boolean; |
21 | | -}; |
| 3 | +import { GlobalDropdownMenu } from "@/common/components/ui/global-dropdown-menu"; |
22 | 4 |
|
23 | 5 | export const PostMenu = ({ post }: { post: Post }) => { |
24 | | - const menuOptions: MenuOption[] = [ |
25 | | - { |
26 | | - id: "dm", |
27 | | - label: "Send a DM", |
28 | | - description: `Ask about taking the job\nPost type: ${post.type}`, |
29 | | - condition: (post) => true, |
30 | | - disabled: (post) => false, |
31 | | - onClick: (post) => {}, |
32 | | - separatorBefore: true, |
33 | | - }, |
34 | | - ]; |
35 | | - |
36 | | - const visibleOptions = menuOptions.filter( |
37 | | - (option) => !option.condition || option.condition(post) |
38 | | - ); |
39 | | - |
40 | 6 | return ( |
41 | | - <DropdownMenu> |
42 | | - <DropdownMenuTrigger asChild> |
43 | | - <Button variant="ghost" size="icon"> |
44 | | - <EllipsisVertical size={24} /> |
45 | | - </Button> |
46 | | - </DropdownMenuTrigger> |
47 | | - <DropdownMenuContent> |
48 | | - <DropdownMenuLabel>Post Actions</DropdownMenuLabel> |
49 | | - |
50 | | - {visibleOptions.map((option) => ( |
51 | | - <div key={option.id}> |
52 | | - {option.separatorBefore && <DropdownMenuSeparator />} |
53 | | - <DropdownMenuItem |
54 | | - disabled={option.disabled?.(post)} |
55 | | - onClick={() => option.onClick(post)} |
56 | | - > |
57 | | - <p>{option.label}</p> |
58 | | - {option.description && ( |
59 | | - <p className="text-sm text-gray-500">{option.description}</p> |
60 | | - )} |
61 | | - </DropdownMenuItem> |
62 | | - </div> |
63 | | - ))} |
64 | | - </DropdownMenuContent> |
65 | | - </DropdownMenu> |
| 7 | + <GlobalDropdownMenu |
| 8 | + options={[ |
| 9 | + { |
| 10 | + id: "dm", |
| 11 | + label: "Send a DM", |
| 12 | + description: `Ask about taking the job : Post type: ${post.type}`, |
| 13 | + condition: () => true, |
| 14 | + disabled: () => false, |
| 15 | + onClick: () => {}, |
| 16 | + separatorBefore: true, |
| 17 | + }, |
| 18 | + ]} |
| 19 | + context={post} |
| 20 | + label="Post Actions" |
| 21 | + /> |
66 | 22 | ); |
67 | 23 | }; |
0 commit comments