index.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { Button, DataTableBulkActionItem, defineDashboardExtension } from '@vendure/dashboard';
  2. import { InfoIcon } from 'lucide-react';
  3. import { toast } from 'sonner';
  4. import { TextareaCustomField } from './custom-form-components';
  5. import { CustomWidget } from './custom-widget';
  6. import { reviewDetail } from './review-detail';
  7. import { reviewList } from './review-list';
  8. export default defineDashboardExtension({
  9. routes: [reviewList, reviewDetail],
  10. widgets: [
  11. {
  12. id: 'custom-widget',
  13. name: 'Custom Widget',
  14. component: CustomWidget,
  15. defaultSize: { w: 3, h: 3 },
  16. },
  17. ],
  18. actionBarItems: [
  19. {
  20. label: 'Custom Action Bar Item',
  21. component: props => {
  22. return (
  23. <Button
  24. type="button"
  25. onClick={() => {
  26. console.log('Clicked custom action bar item');
  27. }}
  28. >
  29. Test Button
  30. </Button>
  31. );
  32. },
  33. locationId: 'product-detail',
  34. },
  35. ],
  36. pageBlocks: [
  37. {
  38. id: 'my-block',
  39. component: ({ context }) => {
  40. return <div>Here is my custom block!</div>;
  41. },
  42. title: 'My Custom Block',
  43. location: {
  44. pageId: 'product-detail',
  45. column: 'side',
  46. position: { blockId: 'main-form', order: 'after' },
  47. },
  48. },
  49. ],
  50. customFormComponents: [
  51. {
  52. id: 'textarea',
  53. component: TextareaCustomField,
  54. },
  55. ],
  56. dataTables: [
  57. {
  58. pageId: 'product-list',
  59. bulkActions: [
  60. {
  61. component: props => (
  62. <DataTableBulkActionItem
  63. onClick={() => {
  64. console.log('Selection:', props.selection);
  65. toast.message(`There are ${props.selection.length} selected items`);
  66. }}
  67. label="My Custom Action"
  68. icon={InfoIcon}
  69. />
  70. ),
  71. },
  72. ],
  73. },
  74. ],
  75. });