review-list.tsx 2.6 KB

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