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

refactor: rescript core changes json, dict, string, nullable & array #212

Merged
merged 28 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7a253d1
refactor: start using @rescript/core package
seekshiva Mar 5, 2024
b293741
refactor(belt.option changes to core): refactor: Belt.Option changes …
Mar 7, 2024
e944896
refactor: json module core changes
Mar 7, 2024
a94b22e
refactor: array core changes
Mar 7, 2024
ae7bf16
refactor: array join & slice changes
Mar 7, 2024
7109f74
refactor: global removed
Mar 7, 2024
34e022a
refactor: dict changes
Mar 7, 2024
14ac800
refactor: core api changes
Mar 7, 2024
d4a79c0
refactor: nullable core changes
Mar 7, 2024
da08993
refactor: date and console core changes
Mar 7, 2024
0ff71b6
refactor: regex core changes
Mar 7, 2024
2f4e2cb
Merge branch 'main' of github.com:juspay/hyperswitch-web into refacto…
Mar 8, 2024
56965cd
Merge branches 'refactor/rescript-core-changes-json' and 'main' of gi…
Mar 8, 2024
8aa21a4
fix: package-lock
Mar 8, 2024
293f11f
Merge branch 'main' of github.com:juspay/hyperswitch-web into refacto…
Mar 11, 2024
542bcb3
Merge branch 'main' of github.com:juspay/hyperswitch-web into refacto…
Mar 12, 2024
3e02834
chore: core changes
Mar 12, 2024
d1b529b
chore: core changes
Mar 12, 2024
d71c81e
Merge branch 'main' of github.com:juspay/hyperswitch-web into refacto…
Mar 13, 2024
4661bcf
fix: array and string functions
Mar 13, 2024
5119046
Merge branch 'main' of github.com:juspay/hyperswitch-web into refacto…
Mar 14, 2024
76eb6a4
Merge branch 'main' into refactor/rescript-core-changes-json
seekshiva Mar 14, 2024
bf19099
Merge branch 'main' of github.com:juspay/hyperswitch-web into refacto…
Mar 14, 2024
42e9c71
Merge branch 'refactor/rescript-core-changes-json' of github.com:jusp…
Mar 14, 2024
b2a53fe
Merge branch 'main' into refactor/rescript-core-changes-json
Mar 14, 2024
b78ed90
chore: converted Js to Core
Mar 14, 2024
ee44956
Merge branch 'refactor/rescript-core-changes-json' of github.com:jusp…
Mar 14, 2024
c4b0187
fix: js to core
Mar 14, 2024
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
142 changes: 85 additions & 57 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion src/App.res
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let make = () => {
let sessionId = CardUtils.getQueryParamsDictforKey(url.search, "sessionId")
let publishableKey = CardUtils.getQueryParamsDictforKey(url.search, "publishableKey")
let endpoint =
CardUtils.getQueryParamsDictforKey(url.search, "endpoint")->Js.Global.decodeURIComponent
CardUtils.getQueryParamsDictforKey(url.search, "endpoint")->decodeURIComponent
<PreMountLoader publishableKey sessionId clientSecret endpoint />
}
| "achBankTransfer"
Expand Down
26 changes: 13 additions & 13 deletions src/BrowserSpec.res
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type screen = {colorDepth: int, height: int, width: int}

let checkIsSafari = () => {
let userAgentString = navigator.userAgent
let chromeAgent = userAgentString->Js.String2.indexOf("Chrome") > -1
let safariAgent = userAgentString->Js.String2.indexOf("Safari") > -1
let chromeAgent = userAgentString->String.indexOf("Chrome") > -1
let safariAgent = userAgentString->String.indexOf("Safari") > -1
chromeAgent && safariAgent ? false : safariAgent ? true : false
}

Expand All @@ -23,20 +23,20 @@ let broswerInfo = () => [
(
"browser_info",
[
("user_agent", navigator.userAgent->Js.Json.string),
("user_agent", navigator.userAgent->JSON.Encode.string),
(
"accept_header",
"text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8"->Js.Json.string,
"text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8"->JSON.Encode.string,
),
("language", navigator.language->Js.Json.string),
("color_depth", screen.colorDepth->Belt.Int.toFloat->Js.Json.number),
("screen_height", screen.height->Belt.Int.toFloat->Js.Json.number),
("screen_width", screen.width->Belt.Int.toFloat->Js.Json.number),
("time_zone", date.getTimezoneOffset(.)->Js.Json.number),
("java_enabled", true->Js.Json.boolean),
("java_script_enabled", true->Js.Json.boolean),
("language", navigator.language->JSON.Encode.string),
("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),
("java_enabled", true->JSON.Encode.bool),
("java_script_enabled", true->JSON.Encode.bool),
]
->Js.Dict.fromArray
->Js.Json.object_,
->Dict.fromArray
->JSON.Encode.object,
),
]
2 changes: 1 addition & 1 deletion src/CardPattern.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type patterns = {
issuer: string,
pattern: Js.Re.t,
pattern: Re.t,
cvcLength: array<int>,
length: array<int>,
maxCVCLenth: int,
Expand Down
38 changes: 19 additions & 19 deletions src/CardTheme.res
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let defaultAppearance = {
variables: DefaultTheme.default,
componentType: "payment",
labels: Above,
rules: Js.Dict.empty()->Js.Json.object_,
rules: Dict.make()->JSON.Encode.object,
}
let defaultFonts = {
cssSrc: "",
Expand Down Expand Up @@ -76,9 +76,9 @@ let getLocaleObject = string => {
string
}
LocaleString.localeStrings
->Js.Array2.filter(item => item.locale == val)
->Belt.Array.get(0)
->Belt.Option.getWithDefault(LocaleString.defaultLocale)
->Array.filter(item => item.locale == val)
->Array.get(0)
->Option.getOr(LocaleString.defaultLocale)
}
let defaultRecoilConfig: recoilConfig = {
config: defaultConfig,
Expand All @@ -89,9 +89,9 @@ let defaultRecoilConfig: recoilConfig = {

let getVariables = (str, dict, default, logger) => {
dict
->Js.Dict.get(str)
->Belt.Option.flatMap(Js.Json.decodeObject)
->Belt.Option.map(json => {
->Dict.get(str)
->Option.flatMap(JSON.Decode.object)
->Option.map(json => {
let validKeys = [
"fontFamily",
"fontSizeBase",
Expand Down Expand Up @@ -246,20 +246,20 @@ let getVariables = (str, dict, default, logger) => {
spacingGridRow: getWarningString(json, "spacingGridRow", default.spacingGridRow, ~logger),
}
})
->Belt.Option.getWithDefault(default)
->Option.getOr(default)
}

let getAppearance = (
str,
dict,
default: OrcaPaymentPage.CardThemeType.themeClass,
defaultRules: OrcaPaymentPage.CardThemeType.themeClass => Js.Json.t,
defaultRules: OrcaPaymentPage.CardThemeType.themeClass => JSON.t,
logger,
) => {
dict
->Js.Dict.get(str)
->Belt.Option.flatMap(Js.Json.decodeObject)
->Belt.Option.map(json => {
->Dict.get(str)
->Option.flatMap(JSON.Decode.object)
->Option.map(json => {
unknownKeysWarning(["theme", "variables", "rules", "labels"], json, "appearance", ~logger)

let rulesJson = defaultRules(getVariables("variables", json, default, logger))
Expand All @@ -280,15 +280,15 @@ let getAppearance = (
},
}
})
->Belt.Option.getWithDefault(defaultAppearance)
->Option.getOr(defaultAppearance)
}
let getFonts = (str, dict, logger) => {
dict
->Js.Dict.get(str)
->Belt.Option.flatMap(Js.Json.decodeArray)
->Belt.Option.getWithDefault([])
->Belt.Array.keepMap(Js.Json.decodeObject)
->Js.Array2.map(json => {
->Dict.get(str)
->Option.flatMap(JSON.Decode.array)
->Option.getOr([])
->Belt.Array.keepMap(JSON.Decode.object)
->Array.map(json => {
unknownKeysWarning(["cssSrc", "family", "src", "weight"], json, "fonts", ~logger)
{
cssSrc: getWarningString(json, "cssSrc", "", ~logger),
Expand All @@ -301,7 +301,7 @@ let getFonts = (str, dict, logger) => {
let itemToObjMapper = (
dict,
default: OrcaPaymentPage.CardThemeType.themeClass,
defaultRules: OrcaPaymentPage.CardThemeType.themeClass => Js.Json.t,
defaultRules: OrcaPaymentPage.CardThemeType.themeClass => JSON.t,
logger,
) => {
unknownKeysWarning(
Expand Down
Loading
Loading