From 1b8671cd1aef064b0aa5c8233b2d821534ca0da5 Mon Sep 17 00:00:00 2001 From: Thomas McSherry <54848048+ThomasMcSherry@users.noreply.github.com> Date: Tue, 14 Nov 2023 09:44:44 +0000 Subject: [PATCH] Reviews now register the user to the wine as intended --- vinoa-web/sanity/sanity-utils/review-utils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vinoa-web/sanity/sanity-utils/review-utils.ts b/vinoa-web/sanity/sanity-utils/review-utils.ts index e3d0d09..7502cb8 100644 --- a/vinoa-web/sanity/sanity-utils/review-utils.ts +++ b/vinoa-web/sanity/sanity-utils/review-utils.ts @@ -9,6 +9,8 @@ export async function createReview(review: ReviewDTO) { wine: { _ref: review.wineId, _type: 'reference' }, user: { _ref: review.userId, _type: 'reference' }, }); + + await client.patch(review.wineId).setIfMissing({users: []}).append('users', [{_type: 'reference', _ref: review.userId}]).commit({autoGenerateArrayKeys: true}); } export async function getReviewsForWine(slug: string): Promise> {