69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
import {StarIcon} from '@sanity/icons'
|
|
import {ListItemBuilder, StructureBuilder} from 'sanity/structure'
|
|
import defineStructure from '../utils/defineStructure'
|
|
|
|
function reviewList(S: StructureBuilder, title: string, filter: string) {
|
|
return S.documentTypeList('productReview')
|
|
.title(title)
|
|
.filter(filter)
|
|
.defaultOrdering([{field: 'submittedAt', direction: 'desc'}])
|
|
.initialValueTemplates([
|
|
S.initialValueTemplateItem('productReview-cms'),
|
|
S.initialValueTemplateItem('productReview'),
|
|
])
|
|
}
|
|
|
|
/**
|
|
* Product reviews (PDP UGC + CMS). Moderate visibility and add editorial reviews.
|
|
*/
|
|
export default defineStructure<ListItemBuilder>((S) =>
|
|
S.listItem()
|
|
.title('Product reviews')
|
|
.schemaType('productReview')
|
|
.child(
|
|
S.list()
|
|
.title('Product reviews')
|
|
.items([
|
|
S.listItem()
|
|
.title('Add review (CMS)')
|
|
.icon(StarIcon)
|
|
.child(
|
|
S.document()
|
|
.schemaType('productReview')
|
|
.initialValueTemplate('productReview-cms'),
|
|
),
|
|
S.divider(),
|
|
S.listItem()
|
|
.title('All reviews')
|
|
.child(reviewList(S, 'All reviews', '_type == "productReview"')),
|
|
S.listItem()
|
|
.title('Pending moderation')
|
|
.child(
|
|
reviewList(
|
|
S,
|
|
'Pending moderation',
|
|
'_type == "productReview" && (source == "customer" || !defined(source)) && isVisible != true',
|
|
),
|
|
),
|
|
S.listItem()
|
|
.title('Hidden')
|
|
.child(
|
|
reviewList(
|
|
S,
|
|
'Hidden from storefront',
|
|
'_type == "productReview" && isVisible != true',
|
|
),
|
|
),
|
|
S.listItem()
|
|
.title('Live on storefront')
|
|
.child(
|
|
reviewList(
|
|
S,
|
|
'Live on storefront',
|
|
'_type == "productReview" && isVisible == true',
|
|
),
|
|
),
|
|
]),
|
|
),
|
|
)
|