Skip to content

Commit

Permalink
fix: merchant id from user-info (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhiagrawal001 authored Sep 6, 2024
1 parent 26f2dcf commit 12b0d16
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/screens/Analytics/GlobalSearch/GlobalSearchBar.res
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ let make = () => {
let permissionJson = Recoil.useRecoilValueFromAtom(HyperswitchAtom.userPermissionAtom)
let isShowRemoteResults = globalSearch && permissionJson.operationsView === Access
let mixpanelEvent = MixpanelHook.useSendEvent()
let merchantDetailsValue = HSwitchUtils.useMerchantDetailsValue()
let {userInfo: {merchantId}} = React.useContext(UserInfoProvider.defaultContext)

let redirectOnSelect = element => {
mixpanelEvent(~eventName="global_search_redirect")
let redirectLink = element.redirect_link->JSON.Decode.string->Option.getOr("/search")
Expand All @@ -232,7 +233,7 @@ let make = () => {
try {
let url = getURL(~entityName=GLOBAL_SEARCH, ~methodType=Post)

let body = generateSearchBody(~searchText, ~merchant_id={merchantDetailsValue.merchant_id})
let body = generateSearchBody(~searchText, ~merchant_id={merchantId})

let response = await fetchDetails(url, body, Post)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let tableBorderClass = "border-collapse border border-jp-gray-940 border-solid b
let useGetData = () => {
open LogicUtils
let body = Dict.make()
let merchantDetailsValue = HSwitchUtils.useMerchantDetailsValue()
let {userInfo: {merchantId}} = React.useContext(UserInfoProvider.defaultContext)
let getURL = APIUtils.useGetURL()
async (
~updateDetails: (
Expand All @@ -25,7 +25,7 @@ let useGetData = () => {
if !(query->CommonAuthUtils.isValidEmail) {
let filters = [("customer_email", [query->JSON.Encode.string]->JSON.Encode.array)]
body->Dict.set("filters", filters->getJsonFromArrayOfJson)
body->Dict.set("query", merchantDetailsValue.merchant_id->JSON.Encode.string)
body->Dict.set("query", merchantId->JSON.Encode.string)
} else {
body->Dict.set("query", query->JSON.Encode.string)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,14 @@ let make = () => {
let query = UrlUtils.useGetFilterDictFromUrl("")->getString("query", "")
let {globalSearch} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let permissionJson = Recoil.useRecoilValueFromAtom(HyperswitchAtom.userPermissionAtom)
let merchantDetailsValue = HSwitchUtils.useMerchantDetailsValue()
let {userInfo: {merchantId}} = React.useContext(UserInfoProvider.defaultContext)

let isShowRemoteResults = globalSearch && permissionJson.operationsView === Access

let getSearchResults = async results => {
try {
let url = getURL(~entityName=GLOBAL_SEARCH, ~methodType=Post)
let body = generateSearchBody(
~searchText={query},
~merchant_id={merchantDetailsValue.merchant_id},
)
let body = generateSearchBody(~searchText={query}, ~merchant_id={merchantId})
let response = await fetchDetails(url, body, Post)

let local_results = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ let make = (
let url = RescriptReactRouter.useUrl()
let form = ReactFinalForm.useForm()
let connectorID = HSwitchUtils.getConnectorIDFromUrl(url.path->List.toArray, "")
let merchantDetailsValue = HSwitchUtils.useMerchantDetailsValue()
let merchantId = merchantDetailsValue.merchant_id
let {userInfo: {merchantId}} = React.useContext(UserInfoProvider.defaultContext)
let formState: ReactFinalForm.formState = ReactFinalForm.useFormState(
ReactFinalForm.useFormSubscription(["values"])->Nullable.make,
)
Expand Down

0 comments on commit 12b0d16

Please sign in to comment.