Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: formatting rescript code #234

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"re:build": "rescript",
"re:clean": "rescript clean",
"re:start": "rescript build -w",
"re:format": "rescript format -all",
"start:dev": "npm run re:start & npm run start",
"start:playground": "npm run postinstall && cd Hyperswitch-React-Demo-App && node promptScript.js && npm run start",
"build:playground": "npm run postinstall && cd Hyperswitch-React-Demo-App && node promptScript.js && npm run build",
Expand Down
4 changes: 2 additions & 2 deletions src/BrowserSpec.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ type navigator = {
userAgent: string,
language: string,
}
type date = {getTimezoneOffset: (. unit) => float}
type date = {getTimezoneOffset: unit => float}
type screen = {colorDepth: int, height: int, width: int}

@val external navigator: navigator = "navigator"
Expand Down Expand Up @@ -32,7 +32,7 @@ let broswerInfo = () => [
("color_depth", screen.colorDepth->Belt.Int.toFloat->JSON.Encode.float),
("screen_height", screen.height->Belt.Int.toFloat->JSON.Encode.float),
("screen_width", screen.width->Belt.Int.toFloat->JSON.Encode.float),
("time_zone", date.getTimezoneOffset(.)->JSON.Encode.float),
("time_zone", date.getTimezoneOffset()->JSON.Encode.float),
("java_enabled", true->JSON.Encode.bool),
("java_script_enabled", true->JSON.Encode.bool),
]
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Accordion.res
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ let make = (
~borderBottomStyle=borderBottom ? "solid" : "hidden",
(),
)}
onClick={_ => setSelectedOption(._ => paymentOption.paymentMethodName)}>
onClick={_ => setSelectedOption(_ => paymentOption.paymentMethodName)}>
<div
className={`flex flex-row items-center ${accordionClass}`}
style={ReactDOMStyle.make(~columnGap=themeObj.spacingUnit, ())}>
<RenderIf condition=layoutClass.radios> <Radio checked=radioClass /> </RenderIf>
<RenderIf condition=layoutClass.radios>
<Radio checked=radioClass />
</RenderIf>
<div className={`AccordionItemIcon ${accordionItemIconClass} flex items-center`}>
{switch icon {
| Some(ele) => ele
Expand Down
2 changes: 1 addition & 1 deletion src/Components/AccordionContainer.res
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ let make = (~paymentOptions: array<string>, ~checkoutEle: React.element) => {
}

React.useEffect0(() => {
layoutClass.defaultCollapsed ? setSelectedOption(._ => "") : ()
layoutClass.defaultCollapsed ? setSelectedOption(_ => "") : ()
None
})
<div className="w-full">
Expand Down
30 changes: 15 additions & 15 deletions src/Components/AddressPaymentInput.res
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ let make = (~paymentType, ~className="") => {
let checkPostalValidity = (
postal: RecoilAtomTypes.field,
setPostal: (
. OrcaPaymentPage.RecoilAtomTypes.field => OrcaPaymentPage.RecoilAtomTypes.field,
OrcaPaymentPage.RecoilAtomTypes.field => OrcaPaymentPage.RecoilAtomTypes.field
) => unit,
regex,
) => {
if RegExp.test(regex->RegExp.fromString, postal.value) && postal.value !== "" && regex !== "" {
setPostal(.prev => {
setPostal(prev => {
...prev,
isValid: Some(true),
errorString: "",
})
} else if (
regex !== "" && !RegExp.test(regex->RegExp.fromString, postal.value) && postal.value !== ""
) {
setPostal(.prev => {
setPostal(prev => {
...prev,
isValid: Some(false),
errorString: localeString.postalCodeInvalidText,
Expand Down Expand Up @@ -125,7 +125,7 @@ let make = (~paymentType, ~className="") => {
let onPostalChange = ev => {
let val = ReactEvent.Form.target(ev)["value"]

setPostalCode(.prev => {
setPostalCode(prev => {
...prev,
value: val,
errorString: "",
Expand All @@ -138,13 +138,13 @@ let make = (~paymentType, ~className="") => {
let onPostalBlur = ev => {
let val = ReactEvent.Focus.target(ev)["value"]
if regex !== "" && RegExp.test(regex->RegExp.fromString, val) && val !== "" {
setPostalCode(.prev => {
setPostalCode(prev => {
...prev,
isValid: Some(true),
errorString: "",
})
} else if regex !== "" && !RegExp.test(regex->RegExp.fromString, val) && val !== "" {
setPostalCode(.prev => {
setPostalCode(prev => {
...prev,
isValid: Some(false),
errorString: localeString.postalCodeInvalidText,
Expand All @@ -158,7 +158,7 @@ let make = (~paymentType, ~className="") => {
}, (regex, country.value))

React.useEffect1(() => {
setState(.prev => {
setState(prev => {
...prev,
value: "",
})
Expand All @@ -171,31 +171,31 @@ let make = (~paymentType, ~className="") => {
let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper
if confirm.doSubmit {
if line1.value == "" {
setLine1(.prev => {
setLine1(prev => {
...prev,
errorString: localeString.line1EmptyText,
})
}
if line2.value == "" {
setLine2(.prev => {
setLine2(prev => {
...prev,
errorString: localeString.line2EmptyText,
})
}
if state.value == "" {
setState(.prev => {
setState(prev => {
...prev,
errorString: localeString.stateEmptyText,
})
}
if postalCode.value == "" {
setPostalCode(.prev => {
setPostalCode(prev => {
...prev,
errorString: localeString.postalCodeEmptyText,
})
}
if city.value == "" {
setCity(.prev => {
setCity(prev => {
...prev,
errorString: localeString.cityEmptyText,
})
Expand All @@ -216,7 +216,7 @@ let make = (~paymentType, ~className="") => {
value=line1
onChange={ev => {
setShowOtherFields(_ => true)
setLine1(.prev => {
setLine1(prev => {
...prev,
value: ReactEvent.Form.target(ev)["value"],
})
Expand All @@ -239,7 +239,7 @@ let make = (~paymentType, ~className="") => {
setValue={setLine2}
value=line2
onChange={ev => {
setLine2(.prev => {
setLine2(prev => {
...prev,
value: ReactEvent.Form.target(ev)["value"],
})
Expand Down Expand Up @@ -288,7 +288,7 @@ let make = (~paymentType, ~className="") => {
className
value=city
onChange={ev => {
setCity(.prev => {
setCity(prev => {
...prev,
value: ReactEvent.Form.target(ev)["value"],
})
Expand Down
8 changes: 4 additions & 4 deletions src/Components/BillingNamePaymentInput.res
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ let make = (~paymentType, ~customFieldName=None, ~requiredFields as optionalRequ

let changeName = ev => {
let val: string = ReactEvent.Form.target(ev)["value"]
setBillingName(.prev => {
setBillingName(prev => {
value: val,
isValid: Some(val !== ""),
errorString: val !== "" ? "" : prev.errorString,
})
}
let onBlur = ev => {
let val: string = ReactEvent.Focus.target(ev)["value"]
setBillingName(.prev => {
setBillingName(prev => {
...prev,
isValid: Some(val !== ""),
})
Expand All @@ -42,15 +42,15 @@ let make = (~paymentType, ~customFieldName=None, ~requiredFields as optionalRequ
let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper
if confirm.doSubmit {
if billingName.value == "" {
setBillingName(.prev => {
setBillingName(prev => {
...prev,
errorString: fieldName->localeString.nameEmptyText,
})
} else {
switch optionalRequiredFields {
| Some(requiredFields) =>
if !DynamicFieldsUtils.checkIfNameIsValid(requiredFields, BillingName, billingName) {
setBillingName(.prev => {
setBillingName(prev => {
...prev,
errorString: fieldName->localeString.completeNameEmptyText,
})
Expand Down
6 changes: 3 additions & 3 deletions src/Components/BlikCodePaymentInput.res
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ let make = () => {

let changeblikCode = ev => {
let val: string = ReactEvent.Form.target(ev)["value"]
setblikCode(.prev => {
setblikCode(prev => {
...prev,
value: val->formatBSB,
})
}

React.useEffect1(() => {
setblikCode(.prev => {
setblikCode(prev => {
...prev,
errorString: switch prev.isValid {
| Some(val) => val ? "" : "Invalid blikCode"
Expand All @@ -45,7 +45,7 @@ let make = () => {
let confirm = json->Utils.getDictFromJson->ConfirmType.itemToObjMapper
if confirm.doSubmit {
if blikCode.value == "" {
setblikCode(.prev => {
setblikCode(prev => {
...prev,
errorString: "blikCode cannot be empty",
})
Expand Down
Loading
Loading