Skip to content

Commit

Permalink
refactor: unit removed (#544)
Browse files Browse the repository at this point in the history
Co-authored-by: Saksham Sharma <[email protected]>
  • Loading branch information
sakksham7 and Saksham Sharma authored Aug 6, 2024
1 parent a0dd203 commit 2dca7cd
Show file tree
Hide file tree
Showing 55 changed files with 106 additions and 372 deletions.
10 changes: 8 additions & 2 deletions src/App.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let make = () => {
let paymentMode = CardUtils.getQueryParamsDictforKey(url.search, "componentName")
let paymentType = paymentMode->CardThemeType.getPaymentMode
let (logger, initTimestamp) = React.useMemo0(() => {
(OrcaLogger.make(~source=Elements(paymentType), ()), Date.now())
(OrcaLogger.make(~source=Elements(paymentType)), Date.now())
})
let fullscreenMode = CardUtils.getQueryParamsDictforKey(url.search, "fullscreenType")

Expand Down Expand Up @@ -47,7 +47,13 @@ let make = () => {
let merchantHostname = CardUtils.getQueryParamsDictforKey(url.search, "merchantHostname")

<PreMountLoader
publishableKey sessionId clientSecret endpoint ephemeralKey hyperComponentName merchantHostname
publishableKey
sessionId
clientSecret
endpoint
ephemeralKey
hyperComponentName
merchantHostname
/>
}
| "achBankTransfer"
Expand Down
2 changes: 1 addition & 1 deletion src/CardUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ let getAllBanknames = obj => {
let clientTimeZone = dateTimeFormat().resolvedOptions().timeZone
let clientCountry = Utils.getClientCountry(clientTimeZone)

let postalRegex = (postalCodes: array<PostalCodeType.postalCodes>, ~country=?, ()) => {
let postalRegex = (postalCodes: array<PostalCodeType.postalCodes>, ~country=?) => {
let country = country->Option.getOr(clientCountry.isoAlpha2)
let countryPostal = Utils.getCountryPostal(country, postalCodes)
countryPostal.regex
Expand Down
2 changes: 1 addition & 1 deletion src/Components/DropdownField.res
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let make = (

let handleFocus = _ => {
setInputFocused(_ => true)
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL, ())
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL)
}

let handleChange = ev => {
Expand Down
3 changes: 1 addition & 2 deletions src/Components/DynamicFields.res
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ let make = (
requiredFields,
~isSavedCardFlow,
~isAllStoredCardsHaveName,
(),
)
->DynamicFieldsUtils.updateDynamicFields(billingAddress, ())
->DynamicFieldsUtils.updateDynamicFields(billingAddress)
->Belt.SortArray.stableSortBy(PaymentMethodsRecord.sortPaymentMethodFields)
//<...>//
}, (requiredFields, isAllStoredCardsHaveName, isSavedCardFlow))
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Input.res
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let make = (
setFocus(true)
setValid(None)
setInputFocused(_ => true)
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL, ())
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL)
}

let handleBlur = ev => {
Expand Down
4 changes: 2 additions & 2 deletions src/Components/InputField.res
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let make = (
}
setFocus(true)
setIsValid(_ => None)
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL, ())
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL)
}

let handleBlur = ev => {
Expand All @@ -74,7 +74,7 @@ let make = (
}
setFocus(false)
onBlur(ev)
Utils.handleOnBlurPostMessage(~targetOrigin=parentURL, ())
Utils.handleOnBlurPostMessage(~targetOrigin=parentURL)
}
React.useEffect(() => {
if value->String.length > 0 {
Expand Down
2 changes: 1 addition & 1 deletion src/Components/PaymentDropDownField.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let make = (
}, [options])
let handleFocus = _ => {
setInputFocused(_ => true)
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL, ())
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL)
}
let focusClass = if inputFocused || value.value->String.length > 0 {
`mb-7 pb-1 pt-2 ${themeObj.fontSizeXs} transition-all ease-in duration-75`
Expand Down
4 changes: 2 additions & 2 deletions src/Components/PaymentField.res
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let make = (
})
| None => ()
}
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL, ())
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL)
}

let handleBlur = ev => {
Expand All @@ -52,7 +52,7 @@ let make = (
| Some(fn) => fn(ev)
| None => ()
}
Utils.handleOnBlurPostMessage(~targetOrigin=parentURL, ())
Utils.handleOnBlurPostMessage(~targetOrigin=parentURL)
}

let backgroundClass = switch paymentType {
Expand Down
4 changes: 2 additions & 2 deletions src/Components/PaymentInputField.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let make = (
| Some(fn) => fn(_ => None)
| None => ()
}
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL, ())
Utils.handleOnFocusPostMessage(~targetOrigin=parentURL)
}

let handleBlur = ev => {
Expand All @@ -45,7 +45,7 @@ let make = (
| Some(fn) => fn(ev)
| None => ()
}
Utils.handleOnBlurPostMessage(~targetOrigin=parentURL, ())
Utils.handleOnBlurPostMessage(~targetOrigin=parentURL)
}

let backgroundClass = switch paymentType {
Expand Down
5 changes: 1 addition & 4 deletions src/Components/SavedMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let make = (
let loggerState = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)
let setUserError = message => {
postFailedSubmitResponse(~errortype="validation_error", ~message)
loggerState.setLogError(~value=message, ~eventName=INVALID_FORMAT, ())
loggerState.setLogError(~value=message, ~eventName=INVALID_FORMAT)
}
let (isSaveCardsChecked, setIsSaveCardsChecked) = React.useState(_ => false)
let {displaySavedPaymentMethodsCheckbox, readOnly} = Recoil.useRecoilValueFromAtom(
Expand Down Expand Up @@ -155,7 +155,6 @@ let make = (
~confirmParam=confirm.confirmParams,
~handleUserError=false,
~manualRetry=isManualRetryEnabled,
(),
)
}
| Some("apple_pay") =>
Expand All @@ -173,7 +172,6 @@ let make = (
~confirmParam=confirm.confirmParams,
~handleUserError=false,
~manualRetry=isManualRetryEnabled,
(),
)
}
| _ =>
Expand All @@ -186,7 +184,6 @@ let make = (
~confirmParam=confirm.confirmParams,
~handleUserError=false,
~manualRetry=isManualRetryEnabled,
(),
)
}
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/Components/SavedPaymentManagement.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ let make = (~savedMethods: array<PaymentType.customerMethods>, ~setSavedMethods)
logger.setLogInfo(
~value="Successfully Deleted Saved Payment Method",
~eventName=DELETE_SAVED_PAYMENT_METHOD,
(),
)
setSavedMethods(prev => prev->removeSavedMethod(paymentMethodId))
} else {
logger.setLogError(~value=res->JSON.stringify, ~eventName=DELETE_SAVED_PAYMENT_METHOD, ())
logger.setLogError(~value=res->JSON.stringify, ~eventName=DELETE_SAVED_PAYMENT_METHOD)
}
handlePostMessage([("fullscreen", false->JSON.Encode.bool)])
resolve()
Expand All @@ -53,7 +52,6 @@ let make = (~savedMethods: array<PaymentType.customerMethods>, ~setSavedMethods)
logger.setLogError(
~value=`Error Deleting Saved Payment Method: ${exceptionMessage}`,
~eventName=DELETE_SAVED_PAYMENT_METHOD,
(),
)
handlePostMessage([("fullscreen", false->JSON.Encode.bool)])
resolve()
Expand Down
1 change: 0 additions & 1 deletion src/Hooks/OutsideClick.res
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ let useOutsideClick = (
~isActive,
~events=["click"],
~callback,
(),
) => {
let useEvent0 = callback => {
let callbackRef = React.useRef(callback)
Expand Down
23 changes: 3 additions & 20 deletions src/LoaderController.res
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,18 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
}
switch updatedState {
| Loaded(_) =>
logger.setLogInfo(~value="Loaded", ~eventName=LOADER_CHANGED, ~latency=finalLoadLatency, ())
logger.setLogInfo(~value="Loaded", ~eventName=LOADER_CHANGED, ~latency=finalLoadLatency)
| Loading =>
logger.setLogInfo(~value="Loading", ~eventName=LOADER_CHANGED, ~latency=finalLoadLatency, ())
logger.setLogInfo(~value="Loading", ~eventName=LOADER_CHANGED, ~latency=finalLoadLatency)
| SemiLoaded => {
setPaymentMethodList(_ => updatedState)
logger.setLogInfo(
~value="SemiLoaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)
logger.setLogInfo(~value="SemiLoaded", ~eventName=LOADER_CHANGED, ~latency=finalLoadLatency)
}
| LoadError(x) =>
logger.setLogError(
~value="LoadError: " ++ x->JSON.stringify,
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)
}
Window.addEventListener("click", ev =>
Expand Down Expand Up @@ -282,7 +276,6 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
~value=Window.hrefWithoutSearch,
~eventName=APP_RENDERED,
~latency=initLoadlatency,
(),
)
[
("iframeId", "no-element"->JSON.Encode.string),
Expand All @@ -297,7 +290,6 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
~eventName=PAYMENT_OPTIONS_PROVIDED,
~latency=renderLatency,
~value="",
(),
)
}
} else if dict->getDictIsSome("paymentOptions") {
Expand Down Expand Up @@ -415,14 +407,12 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
~value="Loaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)
| LoadError(x) =>
logger.setLogError(
~value="LoadError: " ++ x->JSON.stringify,
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)
| _ => ()
}
Expand All @@ -438,7 +428,6 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
~value="Loaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)
: evalMethodsList()
| NoResult(_) => evalMethodsList()
Expand Down Expand Up @@ -467,14 +456,12 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
~value="Loaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)
| LoadError(x) =>
logger.setLogError(
~value="LoadError: " ++ x->JSON.stringify,
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)
| _ => ()
}
Expand All @@ -487,7 +474,6 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
~value="Loaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)
} else {
evalMethodsList()
Expand All @@ -514,14 +500,12 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
~value="Loaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)
| LoadError(x) =>
logger.setLogError(
~value="LoadError: " ++ x->JSON.stringify,
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)

| _ => ()
Expand All @@ -535,7 +519,6 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
~value="Loaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadLatency,
(),
)
} else {
evalMethodsList()
Expand Down
16 changes: 4 additions & 12 deletions src/Payment.res
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,7 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
}

let submitAPICall = (body, confirmParam) => {
intent(
~bodyArr=body,
~confirmParam,
~handleUserError=false,
~manualRetry=isManualRetryEnabled,
(),
)
intent(~bodyArr=body, ~confirmParam, ~handleUserError=false, ~manualRetry=isManualRetryEnabled)
}
React.useEffect(() => {
setCvcNumber(_ => "")
Expand Down Expand Up @@ -269,7 +263,6 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
~cardHolderName="",
~cvcNumber,
~cardBrand=cardNetwork,
(),
)
| CardNumberElement =>
let (month, year) = getExpiryDates(getCardElementValue(iframeId, "card-expiry"))
Expand All @@ -281,7 +274,6 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
~cardHolderName="",
~cvcNumber=localCvcNumber,
~cardBrand=cardNetwork,
(),
)
| _ => []
}
Expand Down Expand Up @@ -321,13 +313,13 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
let json = ev.data->safeParse
let dict = json->Utils.getDictFromJson
if dict->Dict.get("doBlur")->Option.isSome {
logger.setLogInfo(~value="doBlur Triggered", ~eventName=BLUR, ())
logger.setLogInfo(~value="doBlur Triggered", ~eventName=BLUR)
setBlurState(_ => true)
} else if dict->Dict.get("doFocus")->Option.isSome {
logger.setLogInfo(~value="doFocus Triggered", ~eventName=FOCUS, ())
logger.setLogInfo(~value="doFocus Triggered", ~eventName=FOCUS)
cardRef.current->Nullable.toOption->Option.forEach(input => input->focus)->ignore
} else if dict->Dict.get("doClearValues")->Option.isSome {
logger.setLogInfo(~value="doClearValues Triggered", ~eventName=CLEAR, ())
logger.setLogInfo(~value="doClearValues Triggered", ~eventName=CLEAR)
//clear all values
setCardNumber(_ => "")
setCardExpiry(_ => "")
Expand Down
3 changes: 0 additions & 3 deletions src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
SDK_CONNECTOR_WARNING,
~dynamicStr="Please enable Card Payment in the dashboard, or 'ShowCard.FormByDefault' to false.",
~logger=loggerState,
(),
)
} else if !checkPriorityList(paymentMethodOrder) {
ErrorUtils.manageErrorWarning(
Expand All @@ -185,7 +184,6 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
", ",
)} . Please enable Card Payment as 1st priority to show it as default.`,
~logger=loggerState,
(),
)
}
: ()
Expand Down Expand Up @@ -268,7 +266,6 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
~value="",
~eventName=PAYMENT_METHOD_CHANGED,
~paymentMethod=selectedOption->String.toUpperCase,
(),
)
}
None
Expand Down
2 changes: 0 additions & 2 deletions src/Payments/ACHBankDebit.res
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ let make = (~paymentType: CardThemeType.mode) => {
~callback=() => {
setOpenToolTip(_ => false)
},
(),
)

React.useEffect(() => {
Expand Down Expand Up @@ -91,7 +90,6 @@ let make = (~paymentType: CardThemeType.mode) => {
~confirmParam=confirm.confirmParams,
~handleUserError=false,
~manualRetry=isManualRetryEnabled,
(),
)
| None => ()
}
Expand Down
1 change: 0 additions & 1 deletion src/Payments/ACHBankTransfer.res
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ let make = (~paymentType: CardThemeType.mode) => {
~handleUserError=false,
~iframeId,
~manualRetry=isManualRetryEnabled,
(),
)
} else {
postFailedSubmitResponse(~errortype="validation_error", ~message="Please enter all fields")
Expand Down
Loading

0 comments on commit 2dca7cd

Please sign in to comment.