review-list.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. requiresPermission: ['ReadCatalog'],
  40. },
  41. path: '/reviews',
  42. loader: () => ({
  43. breadcrumb: 'Reviews',
  44. }),
  45. component: route => (
  46. <ListPage
  47. pageId="review-list"
  48. title="Product Reviews"
  49. listQuery={getReviewList}
  50. route={route}
  51. defaultVisibility={{
  52. productVariant: false,
  53. product: false,
  54. summary: false,
  55. rating: false,
  56. authorName: false,
  57. reviewerName: false,
  58. responseCreatedAt: false,
  59. response: false,
  60. upvotes: false,
  61. downvotes: false,
  62. }}
  63. customizeColumns={{
  64. id: {
  65. header: 'ID',
  66. cell: ({ row }) => {
  67. return <DetailPageButton id={row.original.id} label={row.original.id} />;
  68. },
  69. },
  70. product: {
  71. header: 'Product',
  72. cell: ({ row }) => {
  73. return <DetailPageButton id={row.original.id} label={row.original.product.name} />;
  74. },
  75. },
  76. reviewerName: {
  77. header: 'Reviewer Name',
  78. cell: ({ row }) => {
  79. return <div className="text-red-500">{row.original.customFields?.reviewerName}</div>;
  80. },
  81. },
  82. }}
  83. />
  84. ),
  85. };