review-list.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { graphql } from '@/graphql/graphql';
  2. import { DashboardRouteDefinition, DetailPageButton, ListPage } from '@vendure/dashboard';
  3. const getReviewList = graphql(`
  4. query GetProductReviews($options: ProductReviewListOptions) {
  5. productReviews(options: $options) {
  6. items {
  7. id
  8. createdAt
  9. updatedAt
  10. product {
  11. id
  12. name
  13. }
  14. productVariant {
  15. id
  16. name
  17. sku
  18. }
  19. summary
  20. body
  21. rating
  22. authorName
  23. authorLocation
  24. upvotes
  25. downvotes
  26. state
  27. response
  28. responseCreatedAt
  29. }
  30. }
  31. }
  32. `);
  33. export const reviewList: DashboardRouteDefinition = {
  34. navMenuItem: {
  35. sectionId: 'catalog',
  36. id: 'reviews',
  37. url: '/reviews',
  38. title: 'Product Reviews',
  39. },
  40. path: '/reviews',
  41. loader: () => ({
  42. breadcrumb: 'Reviews',
  43. }),
  44. component: route => (
  45. <ListPage
  46. pageId="review-list"
  47. title="Product Reviews"
  48. listQuery={getReviewList}
  49. route={route}
  50. defaultVisibility={{
  51. productVariant: false,
  52. product: false,
  53. summary: false,
  54. rating: false,
  55. authorName: false,
  56. reviewerName: false,
  57. responseCreatedAt: false,
  58. response: false,
  59. upvotes: false,
  60. downvotes: false,
  61. }}
  62. customizeColumns={{
  63. id: {
  64. header: 'ID',
  65. cell: ({ row }) => {
  66. return <DetailPageButton id={row.original.id} label={row.original.id} />;
  67. },
  68. },
  69. product: {
  70. header: 'Product',
  71. cell: ({ row }) => {
  72. return <DetailPageButton id={row.original.id} label={row.original.product.name} />;
  73. },
  74. },
  75. reviewerName: {
  76. header: 'Reviewer Name',
  77. cell: ({ row }) => {
  78. return <div className="text-red-500">{row.original.customFields?.reviewerName}</div>;
  79. },
  80. },
  81. }}
  82. />
  83. ),
  84. };