@@ -23,6 +23,8 @@ import {
2323 GetReviewsCountQuery ,
2424} from '../data/graphql'
2525
26+ import { useShowLoginCtaModalOnAuthError } from './hooks'
27+
2628export function useReviewCount (
2729 params : GetReviewsCountQueryVariables ,
2830 initialValue ?: number ,
@@ -63,11 +65,15 @@ export function useMyReview(params: GetMyReviewQueryVariables) {
6365export function useLikeReviewMutation ( ) {
6466 const { notifyReviewLiked } = useTripleClientActions ( )
6567 const queryClient = useQueryClient ( )
68+ const showLoginCtaModalOnAuthError = useShowLoginCtaModalOnAuthError ( )
6669
6770 return useMutation (
6871 ( variables : LikeReviewMutationVariables & { resourceId : string } ) =>
6972 reviewClient ( ( ) => client . LikeReview ( { reviewId : variables . reviewId } ) ) ,
7073 {
74+ onError : ( error ) => {
75+ showLoginCtaModalOnAuthError ( error )
76+ } ,
7177 onSuccess : ( data , variables ) => {
7278 notifyReviewLiked ?.( variables . resourceId , variables . reviewId )
7379
@@ -168,11 +174,15 @@ export function useLikeReviewMutation() {
168174export function useUnlikeReviewMutation ( ) {
169175 const { notifyReviewUnliked } = useTripleClientActions ( )
170176 const queryClient = useQueryClient ( )
177+ const showLoginCtaModalOnAuthError = useShowLoginCtaModalOnAuthError ( )
171178
172179 return useMutation (
173180 ( variables : UnlikeReviewMutationVariables & { resourceId : string } ) =>
174181 reviewClient ( ( ) => client . UnlikeReview ( { reviewId : variables . reviewId } ) ) ,
175182 {
183+ onError : ( error ) => {
184+ showLoginCtaModalOnAuthError ( error )
185+ } ,
176186 onSuccess : ( data , variables ) => {
177187 notifyReviewUnliked ?.( variables . resourceId , variables . reviewId )
178188
@@ -272,6 +282,7 @@ export function useUnlikeReviewMutation() {
272282export function useDeleteReviewMutation ( ) {
273283 const { notifyReviewDeleted } = useTripleClientActions ( )
274284 const queryClient = useQueryClient ( )
285+ const showLoginCtaModalOnAuthError = useShowLoginCtaModalOnAuthError ( )
275286
276287 return useMutation (
277288 async (
@@ -281,6 +292,9 @@ export function useDeleteReviewMutation() {
281292 } ,
282293 ) => reviewClient ( ( ) => client . DeleteReview ( variables ) ) ,
283294 {
295+ onError : ( error ) => {
296+ showLoginCtaModalOnAuthError ( error )
297+ } ,
284298 onSuccess : ( data , variables ) => {
285299 notifyReviewDeleted ?.(
286300 variables . resourceId ,
0 commit comments