Skip to content

Commit

Permalink
com-8701 Added custom message on toster if cart is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Kibo-TriptiV committed Jul 1, 2024
1 parent a3cc706 commit c60357c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/react-query/queryClient.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { QueryClient, MutationCache, QueryCache } from '@tanstack/react-query'
import { getCookie } from 'cookies-next'

const isCSR = getCookie('isCSR')

const getErrorMessage = (code: string, message: string) => {
const messages: any = {
GRAPHQL_VALIDATION_FAILED: 'Something went wrong',
UNAUTHENTICATED: 'Invalid Credentials',
CART_NOT_FOUND: 'Cart was not found',
}

if (isCSR && message.includes(messages.CART_NOT_FOUND)) {
return (message || messages[code]) + ` Please close the window and re-visit the cart takeover.`
}

return message || messages[code] || 'Unable to connect server'
Expand Down

0 comments on commit c60357c

Please sign in to comment.