From aaa47a137ddb81bf2136c3e71d9aee34af48c5fc Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <77892330+PritishBudhiraja@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:11:35 +0530 Subject: [PATCH] chore: remove dead code (#38) Co-authored-by: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> --- src/screens/login/AuthTypes.res | 72 ------- .../HSwitchLoginFlow/HyperSwitchAuthForm.res | 17 -- .../HSwitchLoginFlow/HyperSwitchAuthTypes.res | 4 - .../HSwitchLoginFlow/HyperSwitchAuthUtils.res | 46 ---- src/server/NodeJs.res | 6 +- src/server/Server.res | 9 - src/utils/AnalyticsNewUtils.res | 39 ---- src/utils/AnalyticsTypesUtils.res | 196 ------------------ src/utils/ArrayUtils.res | 24 --- src/utils/CurrencyFormatUtils.res | 10 - src/utils/DateRangeUtils.res | 9 - src/utils/DictionaryUtils.res | 44 +--- src/utils/Formatter.res | 46 ---- src/utils/HyperSwitchUtils.res | 17 -- 14 files changed, 2 insertions(+), 537 deletions(-) delete mode 100644 src/utils/Formatter.res diff --git a/src/screens/login/AuthTypes.res b/src/screens/login/AuthTypes.res index d0d87d6e6..cf51ce9fc 100644 --- a/src/screens/login/AuthTypes.res +++ b/src/screens/login/AuthTypes.res @@ -1,73 +1 @@ type authorization = NoAccess | Read | ReadWrite | Checker -open LogicUtils - -let getAccessTypeFromString = str => { - switch str { - | "R" => Read - | "Read" => Read - | "RW" => ReadWrite - | "ReadWrite" => ReadWrite - | "Write" => ReadWrite - | "CHECKER" => Checker - | _ => NoAccess - } -} - -let getAccessTypeFromBool = boolean => { - switch boolean { - | true => ReadWrite - | false => NoAccess - } -} - -let getArrayData = (dict, key) => { - switch Js.Dict.get(dict, key) { - | Some(value) => - switch value->Js.Json.decodeArray { - | Some(arr) => - let loginRoleArray = arr->Js.Array2.reduce((acc, item) => { - switch item->Js.Json.decodeString { - | Some(str) => - let _ = Js.Array2.push(acc, str) - | None => () - } - acc - }, []) - loginRoleArray - | None => [] - } - | None => [] - } -} - -let getAccessType = (accessType: Js.Nullable.t) => { - switch accessType->Js.Nullable.toOption { - | Some(str) => getAccessTypeFromString(str) - | None => NoAccess - } -} - -let getConvertedAuthInfoType = (dict, key) => { - let access = getString(dict, key, "NA") - getAccessType(access->Js.Nullable.return) -} - -let bestOf = (authorizations: array) => { - authorizations->Js.Array2.includes(ReadWrite) - ? ReadWrite - : authorizations->Js.Array2.includes(Checker) - ? Checker - : authorizations->Js.Array2.includes(Read) - ? Read - : NoAccess -} - -let worstOf = (authorizations: array) => { - authorizations->Js.Array2.includes(NoAccess) - ? NoAccess - : authorizations->Js.Array2.includes(Read) - ? Read - : authorizations->Js.Array2.includes(Checker) - ? Checker - : ReadWrite -} diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res index c4e0885ef..18c1d0752 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res @@ -36,20 +36,3 @@ module ResetPasswordForm = { } } - -module ResendVerifyEmailForm = { - @react.component - let make = (~disableBtn) => { -
- -
- } -} diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthTypes.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthTypes.res index c8d4a9beb..16d723ecc 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthTypes.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthTypes.res @@ -9,10 +9,6 @@ type authInfo = { type authStatus = LoggedOut | LoggedIn(authInfo) | CheckingAuthStatus open LogicUtils -let getBoolFromSideBarConfig = dict => { - dict->getDictfromDict("sideBarConfig") -} - let getAuthInfo = (json, str) => { let dict = json->JsonFlattenUtils.flattenObject(false) let emailKey = "email" diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res index 2e79f95aa..599639e1a 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res @@ -306,52 +306,6 @@ module ToggleLiveTestMode = { } } -module InfoWithBack = { - @react.component - let make = (~authType, ~setAuthType) => { - let showInfoWithBack = switch authType { - | MagicLinkEmailSent - | ForgetPassword - | ForgetPasswordEmailSent - | ResendVerifyEmailSent - | ResendVerifyEmail => true - | _ => false - } - - - - -
{ - let backState = switch authType { - | MagicLinkEmailSent => SignUP - | ForgetPasswordEmailSent => ForgetPassword - | ResendVerifyEmailSent => ResendVerifyEmail - | ForgetPassword | _ => LoginWithPassword - } - setAuthType(_ => backState) - }}> - -
{"Back"->React.string}
-
-
- {switch authType { - | MagicLinkEmailSent | ForgetPasswordEmailSent | ResendVerifyEmailSent => -
- -
- | _ => React.null - }} -
-
- } -} - module Header = { @react.component let make = (~authType, ~setAuthType, ~email) => { diff --git a/src/server/NodeJs.res b/src/server/NodeJs.res index 45612dc7b..6a13d8ffb 100644 --- a/src/server/NodeJs.res +++ b/src/server/NodeJs.res @@ -1,9 +1,5 @@ type promisifyable - -type execResponse = { - stdout: string, - stderr: string, -} +type execResponse type promiseableExecFile = (. string, array) => Promise.t module Util = { diff --git a/src/server/Server.res b/src/server/Server.res index c2bed2f80..1851223e1 100644 --- a/src/server/Server.res +++ b/src/server/Server.res @@ -31,15 +31,6 @@ module ServerHandler = { external handler: (Http.request, Http.response, options) => Promise.t = "serve-handler" } -let execFile = Util.promisify(ChildProcess.execFile) - -let optionalReplace = (mainStr, from, optionalReplacement) => { - switch optionalReplacement { - | Some(replacementText) => mainStr->Js.String2.replace(from, replacementText) - | None => mainStr - } -} - if appName === Some("hyperswitch") { let htmlInFs = Fs.readFileSync("dist/hyperswitch/index.html", {"encoding": "utf8"}) diff --git a/src/utils/AnalyticsNewUtils.res b/src/utils/AnalyticsNewUtils.res index d9bfb018d..39f5cd689 100644 --- a/src/utils/AnalyticsNewUtils.res +++ b/src/utils/AnalyticsNewUtils.res @@ -41,21 +41,6 @@ let calculateHistoricTime = ( } } -let calculateDelta = ( - ~currentValue: float, - ~previousValue: float, - ~statType: AnalyticsTypesUtils.metricsType, -) => { - let delta = switch statType { - | Volume | Latency | Amount => - ((currentValue -. previousValue) /. previousValue *. 100.) - ->Js.Float.toFixedWithPrecision(~digits=2) - | Rate | NegativeRate => (currentValue -. previousValue)->Js.Float.toFixedWithPrecision(~digits=2) - } - - Js.Float.fromString(delta) -} - let makeFilters = (~filters: Js.Json.t, ~cardinalityArr) => { let decodeFilter = filters->getDictFromJsonObject @@ -528,27 +513,3 @@ let apiBodyMaker = ( finalBody->Js.Dict.set("interval", timeObj->Js.Json.object_) finalBody->Js.Json.object_ } - -let domainFromModeValue = modeValue => - if modeValue === "ORDER" { - "orders" - } else { - "txns" - } - -let getModeName = mode => { - if mode === "txns" { - "Transactions" - } else { - "Orders" - } -} - -let filterAddButtonFn = showDropDown => { -
- {React.string("+Add")} -
-} diff --git a/src/utils/AnalyticsTypesUtils.res b/src/utils/AnalyticsTypesUtils.res index 4df30b27b..0104d829d 100644 --- a/src/utils/AnalyticsTypesUtils.res +++ b/src/utils/AnalyticsTypesUtils.res @@ -10,199 +10,3 @@ type timeObj = { apiStartTime: float, apiEndTime: float, } - -let timeObj = { - apiStartTime: 0., - apiEndTime: 0., -} - -// type txnmetrics = -// | TotalVolume -// | SuccessVolume -// | SuccessRate -// | ConflictTxnRate -// | AverageLatency -// | AvgTicketSize -// | TotalAmount - -// type txndimension = -// | PaymentGateway -// | OrderType -// | TxnLatency -// | BusinessRegion -// | Currency -// | TicketSize -// | SsEmi -// | PgRrrorMessage -// | TxnFlowType -// | CardBrand -// | PreviousTxnStatus -// | RunDate -// | Lob -// | AuthType -// | PaymentStatus -// | MerchantId -// | TxnType -// | TokenRepeat -// | EmiType -// | ActualPaymentStatus -// | IsTokenBin -// | EmiBank -// | StatusSyncSource -// | Bank -// | IsTxnConflicted -// | PaymentMethodType -// | PaymentMethodSubtype -// | CardExpMonth -// | CardExpYear -// | UsingStoredCard -// | RunMonth -// | Card_issuerCountry -// | PaymentFlow -// | EmiTenure - -// let txnmetrics = [ -// TotalVolume, -// SuccessVolume, -// SuccessRate, -// ConflictTxnRate, -// AverageLatency, -// AvgTicketSize, -// TotalAmount, -// ] - -// let txndimension = [ -// Bank, -// MerchantId, -// PaymentGateway, -// PaymentMethodType, -// OrderType, -// TxnLatency, -// BusinessRegion, -// Currency, -// TicketSize, -// SsEmi, -// PgRrrorMessage, -// TxnFlowType, -// CardBrand, -// PreviousTxnStatus, -// RunDate, -// Lob, -// AuthType, -// PaymentStatus, -// TxnType, -// TokenRepeat, -// EmiType, -// ActualPaymentStatus, -// IsTokenBin, -// EmiBank, -// StatusSyncSource, -// IsTxnConflicted, -// PaymentMethodSubtype, -// CardExpMonth, -// CardExpYear, -// UsingStoredCard, -// RunMonth, -// Card_issuerCountry, -// PaymentFlow, -// EmiTenure, -// ] - -// type timeFilter = T_ONEDAY | T_SEVENDAY | T_THIRTYDAY | T_SIXTYDAY -// type granularValue = G_ONEMIN | G_FIVEMIN | G_FIFTEENMIN | G_ONEHOUR | G_ONEDAY -// type lastDays = Day(float) | Week(float) | Month(float) | Today | Yesterday -// type sortOrder = ASC | DESC - -// let sortOrderMapper = sortOrder => { -// switch sortOrder { -// | ASC => "ASC" -// | DESC => "DESC" -// } -// } - -// let txnMetricsMapper = (metric: txnmetrics) => { -// switch metric { -// | TotalVolume => "total_volume" -// | SuccessVolume => "success_volume" -// | SuccessRate => "success_rate" -// | ConflictTxnRate => "conflict_txn_rate" -// | AverageLatency => "average_latency" -// | AvgTicketSize => "avg_ticket_size" -// | TotalAmount => "total_amount" -// } -// } - -// let txnMetricsTypeMapper = (metric: txnmetrics) => { -// switch metric { -// | TotalVolume => Volume -// | SuccessVolume => Volume -// | SuccessRate => Rate -// | ConflictTxnRate => Rate -// | AverageLatency => Latency -// | AvgTicketSize => Amount -// | TotalAmount => Amount -// } -// } - -// let txnDimsMapper = (dims: txndimension) => { -// switch dims { -// | PaymentGateway => "payment_gateway" -// | OrderType => "order_type" -// | TxnLatency => "txn_latency" -// | BusinessRegion => "business_region" -// | Currency => "currency" -// | TicketSize => "ticket_size" -// | SsEmi => "is_emi" -// | PgRrrorMessage => "pg_error_message" -// | TxnFlowType => "txn_flow_type" -// | CardBrand => "card_brand" -// | PreviousTxnStatus => "previous_txn_status" -// | RunDate => "run_date" -// | Lob => "lob" -// | AuthType => "auth_type" -// | PaymentStatus => "payment_status" -// | MerchantId => "merchant_id" -// | TxnType => "txn_type" -// | TokenRepeat => "token_repeat" -// | EmiType => "emi_type" -// | ActualPaymentStatus => "actual_payment_status" -// | IsTokenBin => "is_token_bin" -// | EmiBank => "emi_bank" -// | StatusSyncSource => "status_sync_source" -// | Bank => "bank" -// | IsTxnConflicted => "is_txn_conflicted" -// | PaymentMethodType => "payment_method_type" -// | PaymentMethodSubtype => "payment_method_subtype" -// | CardExpMonth => "card_exp_month" -// | CardExpYear => "card_exp_year" -// | UsingStoredCard => "using_stored_card" -// | RunMonth => "run_month" -// | Card_issuerCountry => "card_issuer_country" -// | PaymentFlow => "payment_flow" -// | EmiTenure => "emi_tenure" -// } -// } - -let metricsTypeMapper = metricsType => { - switch metricsType { - | Latency => "Latency" - | Volume => "Volume" - | Rate => "Rate" - | Amount => "Amount" - | NegativeRate => "NegativeRate" - } -} - -let metricsTypeMapperOPP = metricsType => { - switch metricsType { - | "Latency" => Latency - | "Volume" => Volume - | "Rate" => Rate - | "Amount" => Amount - | "NegativeRate" => NegativeRate - | _ => - raise( - Invalid_argument(`invalid values, only Volume, Rate, Amount,NegativeRate is accepted as values`), - ) - } -} diff --git a/src/utils/ArrayUtils.res b/src/utils/ArrayUtils.res index a06f90d92..3c60d55a3 100644 --- a/src/utils/ArrayUtils.res +++ b/src/utils/ArrayUtils.res @@ -6,27 +6,3 @@ let getUniqueStrArray = (arr: array) => { ->Js.Dict.fromArray ->Js.Dict.keys } - -let getUniqueIntArr = (arr: array) => { - arr - ->Js.Array2.map(item => { - (item->Belt.Int.toString, 0) - }) - ->Js.Dict.fromArray - ->Js.Dict.keys - ->Js.Array2.map(item => item->Belt.Int.fromString->Belt.Option.getWithDefault(0)) -} - -let getUniqueFloatArr = (arr: array) => { - arr - ->Js.Array2.map(item => { - (item->Belt.Float.toString, 0) - }) - ->Js.Dict.fromArray - ->Js.Dict.keys - ->Js.Array2.map(item => item->Belt.Float.fromString->Belt.Option.getWithDefault(0.)) -} - -let arrayDiff = (arra, arrb) => { - arra->Js.Array2.copy->Js.Array2.filter(item => !(arrb->Js.Array2.includes(item))) -} diff --git a/src/utils/CurrencyFormatUtils.res b/src/utils/CurrencyFormatUtils.res index 76857cf16..ae8dbb3d1 100644 --- a/src/utils/CurrencyFormatUtils.res +++ b/src/utils/CurrencyFormatUtils.res @@ -2,13 +2,3 @@ type currencyFormat = | IND | USD | DefaultConvert -/* Add more currencies here */ - -let getCountryCurrencyFromString = currency => { - switch currency { - | "IND" => IND - | "USD" => USD - | _ => DefaultConvert - /* Add more currencies here */ - } -} diff --git a/src/utils/DateRangeUtils.res b/src/utils/DateRangeUtils.res index e6104656b..bd06e14dd 100644 --- a/src/utils/DateRangeUtils.res +++ b/src/utils/DateRangeUtils.res @@ -186,12 +186,3 @@ let changeTimeFormat = (~customTimezoneToISOString, ~date, ~time, ~format) => { ) TimeZoneHook.formattedISOString(dateTimeCheck, format) } - -let daysBetween2dates = (~firstDate, ~secondDate) => { - let timeleft = secondDate -. firstDate - let days = - Js.Math.ceil_float( - Js.Math.ceil_float(Js.Math.ceil_float(timeleft /. 1000.) /. 60.) /. 60., - ) /. 24. - days -} diff --git a/src/utils/DictionaryUtils.res b/src/utils/DictionaryUtils.res index fab8e413e..c58239f53 100644 --- a/src/utils/DictionaryUtils.res +++ b/src/utils/DictionaryUtils.res @@ -29,14 +29,6 @@ let appnedDataToKey = (dict, key, value) => { dict->Js.Dict.set(key, updatedValue) } -let appnedArrDataToKey = (dict, key, value) => { - let updatedValue = switch dict->Js.Dict.get(key) { - | Some(val) => Belt.Array.concat(val, value) - | None => value - } - dict->Js.Dict.set(key, updatedValue) -} - let mergeDicts = (arrDict: array>) => { arrDict->Js.Array2.reduce((acc, dict) => { acc->Js.Array2.concat(dict->Js.Dict.entries) @@ -61,19 +53,7 @@ let equalDicts = (dictionary1, dictionary2) => { ->Belt.Option.isNone } -let updateDict = (dict, key, value) => { - let updatedValue = switch dict->Js.Dict.get(key) { - | Some(val) => { - let _ = val->Js.Array2.push(value) - val - } - - | None => [value] - } - dict->Js.Dict.set(key, updatedValue) -} - -let checkEqualJsonDicts = (~checkKeys=[], ~ignoreKeys=[], dictionary1, dictionary2) => { +let checkEqualJsonDicts = (~checkKeys, ~ignoreKeys, dictionary1, dictionary2) => { let dictionary1 = dictionary1->Js.Json.object_->JsonFlattenUtils.flattenObject(false) let dictionary2 = dictionary2->Js.Json.object_->JsonFlattenUtils.flattenObject(false) @@ -125,25 +105,3 @@ let checkEqualJsonDicts = (~checkKeys=[], ~ignoreKeys=[], dictionary1, dictionar let copyOfDict = dict => { dict->Js.Dict.entries->Js.Array2.copy->Js.Dict.fromArray } - -let sortKeysByAlphaOrder = dict => { - dict - ->Js.Dict.entries - ->Js.Array2.sortInPlaceWith((item1, item2) => { - let (key1, _) = item1 - let (key2, _) = item2 - - key1 <= key2 ? -1 : 1 - }) - ->Js.Dict.fromArray -} - -let filterDictFromArray = (dict, array) => { - dict - ->Js.Dict.entries - ->Js.Array2.filter(item => { - let (key, _) = item - !(array->Js.Array2.includes(key)) - }) - ->Js.Dict.fromArray -} diff --git a/src/utils/Formatter.res b/src/utils/Formatter.res deleted file mode 100644 index 32eec613a..000000000 --- a/src/utils/Formatter.res +++ /dev/null @@ -1,46 +0,0 @@ -let numericArrayStringFormat = (. ~value, ~name as _) => { - LogicUtils.getArrayFromJson(value, [])->Js.Array2.joinWith(",")->Js.Json.string -} -let upperCaseFormat = (. ~value, ~name as _) => { - value->LogicUtils.getStringFromJson("")->Js.String2.toUpperCase->Js.Json.string -} -let lowerCaseFormat = (. ~value, ~name as _) => { - value->LogicUtils.getStringFromJson("")->Js.String2.toLowerCase->Js.Json.string -} -let numericArrayStrArrayFormat = (. ~value, ~name as _) => { - let val = switch Js.Json.decodeArray(value) { - | Some(arr) => arr->Js.Array2.reduce((acc, jsonItem) => { - switch jsonItem->Js.Json.decodeNumber { - | Some(num) => { - let _ = acc->Js.Array2.push(num->Belt.Float.toString->Js.Json.string) - } - - | None => () - } - acc - }, []) - - | _ => [] - } - - val->Js.Json.array -} - -let numericStrFormat = (. ~value, ~name as _) => { - value->Js.Json.decodeNumber->Belt.Option.getWithDefault(0.0)->Belt.Float.toString->Js.Json.string -} - -let strArrayFormat = (. ~value, ~name as _) => { - let strVal = value->Js.Json.decodeString->Belt.Option.getWithDefault("") - - let arr = - strVal - ->Js.String2.split(",") - ->Js.Array2.map(Js.String2.trim) - ->Belt.Array.keepMap(LogicUtils.getNonEmptyString) - - arr->Js.Json.stringArray -} -let trimString = (. ~value, ~name as _) => { - value->LogicUtils.getStringFromJson("")->Js.String2.trim->Js.Json.string -} diff --git a/src/utils/HyperSwitchUtils.res b/src/utils/HyperSwitchUtils.res index 366056b01..3aa77c8f6 100644 --- a/src/utils/HyperSwitchUtils.res +++ b/src/utils/HyperSwitchUtils.res @@ -2,23 +2,6 @@ let fetchRequestIdFromAPI = res => { Fetch.Headers.get("x-request-id")(res->Fetch.Response.headers)->Belt.Option.getWithDefault("") } -//to remove -let getErrorStringifiedJson = (json, key) => { - json - ->Js.Json.decodeObject - ->Belt.Option.getWithDefault(Js.Dict.empty()) - ->LogicUtils.getJsonObjectFromDict(key) - ->Js.Json.stringifyAny - ->Belt.Option.getWithDefault("") -} - -let parseErrorJson = json => { - open LogicUtils - let valuesDict = json->getDictFromJsonObject - let errorDict = valuesDict->getObj("error", Js.Dict.empty()) - errorDict->getString("message", "") -} - let getMixpanelRouteName = (pageTitle, url: RescriptReactRouter.url) => { switch (url.path, url.search) { | (list{"payments", ""}, _)