Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ DC_STRIPE_API_KEY=
DC_STRIPE_WEBHOOK_SECRET=

# Optional Herbatica seed XML sources. Keep empty unless running seedHerbatica.
DC_HERBATICA_XML_PATH=
DC_HERBATICA_CATEGORIES_XML_PATH=
DC_HERBATICA_REVIEWS_XML_PATH=
DC_HERBATICA_XML_PATH=

# Medusa BE container: app DB identity (source of truth; DATABASE_URL is generated in docker-compose)
DC_MEDUSA_APP_DB_USER=medusa_app
Expand Down
6 changes: 6 additions & 0 deletions apps/medusa-be/medusa-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,18 @@ module.exports = defineConfig({
{
resolve: "./src/modules/product-list",
},
{
resolve: "./src/modules/product-review",
},
{
resolve: "./src/modules/email-log",
},
{
resolve: "./src/modules/order-receipt",
},
{
resolve: "./src/modules/workflow-queue",
},
...(FEATURE_PAYMENT_QR_ENABLED
? [
{
Expand Down
1 change: 1 addition & 0 deletions apps/medusa-be/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"setInitialPublishableKey": "bash -euo pipefail -c 'PUBLISHABLE_KEY_TITLE=\"${INITIAL_PUBLISHABLE_KEY_NAME:-Storefront Publishable Key}\"; if [ -f ./src/scripts/output-publishable-key.ts ]; then medusa exec ./src/scripts/output-publishable-key.ts \"$PUBLISHABLE_KEY_TITLE\"; else medusa exec ./src/scripts/output-publishable-key.js \"$PUBLISHABLE_KEY_TITLE\"; fi | grep -o \"<PK_TOKEN>.*</PK_TOKEN>\" | sed \"s/<PK_TOKEN>//g;s/<\\\\/PK_TOKEN>//g\" | tr -d \"\\n\\r\"'",
"setInitialPublishableKeyZerops": "bash -euo pipefail -c \"npm run -s setInitialPublishableKey | tr -d '\\n\\r' | zsc setSecretEnv CHANNEL_PUBLISHABLE_KEY\"",
"seedHerbatica": "medusa exec ./src/scripts/herbatica-seed.ts",
"seedHerbaticaReviews": "medusa exec ./src/scripts/herbatica-reviews-seed.ts",
"cleanupHerbaticaLegacyCategories": "medusa exec ./src/scripts/herbatica-cleanup-legacy-categories.ts",
"auditXmlVsDb": "medusa exec ./src/scripts/audit-xml-vs-db.ts",
"debugProductCount": "medusa exec ./src/scripts/debug-product-count.ts"
Expand Down
95 changes: 95 additions & 0 deletions apps/medusa-be/src/admin/lib/reviews.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { sdk } from "./sdk"

export type ReviewStatus = "approved" | "pending" | "rejected"

export type ReviewProduct = {
handle?: string
id: string
thumbnail?: null | string
title?: string
}

export type Review = {
content: string
created_at?: string
customer_id: string
first_name?: null | string
id: string
last_name?: null | string
product?: null | ReviewProduct
product_id: string
rating: number
status: ReviewStatus
title: string
updated_at?: string
}

export type ReviewsResponse = {
count: number
limit: number
offset: number
reviews: Review[]
}

export type ReviewFormInput = {
content: string
first_name?: null | string
last_name?: null | string
rating: number
status: ReviewStatus
title: string
}

export type ReviewInput = Partial<ReviewFormInput>

export type ReviewResponse = {
review: Review
}

export type UpdateReviewStatusResponse = {
reviews: Review[]
}

const toSearch = (params: Record<string, number | string | undefined>) => {
const search = new URLSearchParams()

for (const [key, value] of Object.entries(params)) {
if (value !== undefined && value !== "") {
search.set(key, String(value))
}
}

return search.toString()
}

export const reviewQueryKeys = {
detail: (id: string) => ["reviews", id] as const,
list: (params: Record<string, unknown>) => ["reviews", params] as const,
lists: () => ["reviews"] as const,
}

export const listReviews = (params: {
limit: number
offset: number
order_by?: string
q?: string
status?: ReviewStatus
}) => sdk.client.fetch<ReviewsResponse>(`/admin/reviews?${toSearch(params)}`)

export const retrieveReview = (id: string) =>
sdk.client.fetch<ReviewResponse>(`/admin/reviews/${id}`)

export const updateReview = (id: string, input: ReviewInput) =>
sdk.client.fetch<ReviewResponse>(`/admin/reviews/${id}`, {
body: input,
method: "PATCH",
})

export const updateReviewStatus = (input: {
ids: string[]
status: ReviewStatus
}) =>
sdk.client.fetch<UpdateReviewStatusResponse>("/admin/reviews/status", {
body: input,
method: "POST",
})
Loading
Loading