Skip to content

Commit

Permalink
fix: global search minor bugs (#1040)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarnaikjuspay authored Jul 22, 2024
1 parent 2880ab1 commit f74cdfc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ let tableBorderClass = "border-collapse border border-jp-gray-940 border-solid b

let useGetData = () => {
open LogicUtils
let filters = Dict.make()
let body = Dict.make()
let merchantDetailsValue = HSwitchUtils.useMerchantDetailsValue()
let getURL = APIUtils.useGetURL()
async (
~updateDetails: (
Expand All @@ -18,13 +19,21 @@ let useGetData = () => {
~query,
~path,
) => {
filters->Dict.set("offset", offset->Int.toFloat->JSON.Encode.float)
filters->Dict.set("count", 10->Int.toFloat->JSON.Encode.float)
filters->Dict.set("query", query->JSON.Encode.string)
body->Dict.set("offset", offset->Int.toFloat->JSON.Encode.float)
body->Dict.set("count", 10->Int.toFloat->JSON.Encode.float)
body->Dict.set("query", query->JSON.Encode.string)

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)
} else {
body->Dict.set("query", query->JSON.Encode.string)
}

try {
let url = getURL(~entityName=GLOBAL_SEARCH, ~methodType=Post, ~id=Some(path), ())
let res = await updateDetails(url, filters->JSON.Encode.object, Fetch.Post, ())
let res = await updateDetails(url, body->JSON.Encode.object, Fetch.Post, ())
let data = res->LogicUtils.getDictFromJsonObject->LogicUtils.getArrayFromDict("hits", [])
let total = res->getDictFromJsonObject->getInt("count", 0)

Expand Down
3 changes: 2 additions & 1 deletion src/screens/Disputes/ShowDisputes.res
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ module DisputesInfo = {
@react.component
let make = (~id) => {
open APIUtils
let url = RescriptReactRouter.useUrl()
let getURL = useGetURL()
let fetchDetails = useGetMethod()
let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading)
Expand All @@ -193,7 +194,7 @@ let make = (~id) => {
React.useEffect(() => {
fetchDisputesData()->ignore
None
}, [])
}, [url])

let data = disputeData->LogicUtils.getDictFromJsonObject
let paymentId = data->LogicUtils.getString("payment_id", "")
Expand Down
4 changes: 3 additions & 1 deletion src/screens/Order/ShowOrder.res
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ module FraudRiskBanner = {
let make = (~id) => {
open APIUtils
open OrderUIUtils
let url = RescriptReactRouter.useUrl()
let getURL = useGetURL()
let userPermissionJson = Recoil.useRecoilValueFromAtom(HyperswitchAtom.userPermissionAtom)
let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
Expand Down Expand Up @@ -626,6 +627,7 @@ let make = (~id) => {
}
}
}

React.useEffect(() => {
let accountUrl = getURL(
~entityName=ORDERS,
Expand All @@ -636,7 +638,7 @@ let make = (~id) => {
)
fetchOrderDetails(accountUrl)->ignore
None
}, [])
}, [url])

let isRefundDataAvailable = orderData.refunds->Array.length !== 0

Expand Down
3 changes: 2 additions & 1 deletion src/screens/Refunds/ShowRefund.res
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ module RefundInfo = {
let make = (~id) => {
open LogicUtils
open HSwitchOrderUtils
let url = RescriptReactRouter.useUrl()
let getURL = APIUtils.useGetURL()
let userPermissionJson = Recoil.useRecoilValueFromAtom(HyperswitchAtom.userPermissionAtom)
let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
Expand Down Expand Up @@ -126,7 +127,7 @@ let make = (~id) => {
React.useEffect(() => {
fetchRefundData()->ignore
None
}, [])
}, [url])

let showSyncButton = React.useCallback(_ => {
let refundDict = refundData->getDictFromJsonObject
Expand Down

0 comments on commit f74cdfc

Please sign in to comment.