From f73c060f73e17ddcb606f013fc6aa4724c3f491d Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Tue, 5 Mar 2024 19:42:07 +0530 Subject: [PATCH] fix: cardtheme props --- src/BrutalTheme.res | 8 ++++++-- src/CardTheme.res | 22 +++++++++++++++------- src/CharcoalTheme.res | 4 ++-- src/Components/PayNowButton.res | 12 ++---------- src/DefaultTheme.res | 4 ++-- src/LoaderController.res | 19 +++++++++++++++++++ src/MidnightTheme.res | 4 ++-- src/NoTheme.res | 4 ++-- src/SoftTheme.res | 4 ++-- src/Types/CardThemeType.res | 2 -- 10 files changed, 52 insertions(+), 31 deletions(-) diff --git a/src/BrutalTheme.res b/src/BrutalTheme.res index 6db891163..8b00dbb67 100644 --- a/src/BrutalTheme.res +++ b/src/BrutalTheme.res @@ -38,8 +38,6 @@ let brutal = { colorIconCardError: "#ff1a1a", spacingGridColumn: "20px", spacingGridRow: "20px", - buttonBackgroundColor: "#f5fb1f", - buttonTextColor: "#000000", } let brutalRules = (theme: CardThemeType.themeClass) => { @@ -171,3 +169,9 @@ let brutalRules = (theme: CardThemeType.themeClass) => let default = brutal let defaultRules = brutalRules + +let defaultPayNowProps = { + ...PaymentType.defaultValueSdkHandleConfirmPaymentProps, + buttonBackgroundColor: "#f5fb1f", + textColor: "#000000", +} diff --git a/src/CardTheme.res b/src/CardTheme.res index 160a0cab0..9e1956b7b 100644 --- a/src/CardTheme.res +++ b/src/CardTheme.res @@ -2,6 +2,8 @@ open CardThemeType open Utils open ErrorUtils +external toJson: 'a => Js.Json.t = "%identity" + let getTheme = (val, logger) => { switch val { | "default" => Default @@ -244,13 +246,13 @@ let getVariables = (str, dict, default, logger) => { ~logger, ), spacingGridRow: getWarningString(json, "spacingGridRow", default.spacingGridRow, ~logger), - buttonBackgroundColor: getWarningString( - json, - "buttonBackgroundColor", - default.buttonBackgroundColor, - ~logger, - ), - buttonTextColor: getWarningString(json, "buttonTextColor", default.buttonTextColor, ~logger), + // buttonBackgroundColor: getWarningString( + // json, + // "buttonBackgroundColor", + // default.buttonBackgroundColor, + // ~logger, + // ), + // buttonTextColor: getWarningString(json, "buttonTextColor", default.buttonTextColor, ~logger), } }) ->Belt.Option.getWithDefault(default) @@ -325,3 +327,9 @@ let itemToObjMapper = ( loader: getWarningString(dict, "loader", "auto", ~logger)->getShowLoader(logger), } } + +let getSdkHandleConfirmPaymentProps = (str, dict, default) => { + let val = dict->Js.Dict.get(str)->Belt.Option.getWithDefault(Js.Json.null) + Js.log2("Champ val", val) + mergeJsons(val->toJson, default->toJson) +} diff --git a/src/CharcoalTheme.res b/src/CharcoalTheme.res index af37d1c24..9f81eaa7f 100644 --- a/src/CharcoalTheme.res +++ b/src/CharcoalTheme.res @@ -38,8 +38,8 @@ let charcoal = { colorIconCardError: "#fd1717", spacingGridColumn: "20px", spacingGridRow: "20px", - buttonBackgroundColor: "#000000", - buttonTextColor: "#ffffff", + // buttonBackgroundColor: "#000000", + // buttonTextColor: "#ffffff", } let charcoalRules = theme => diff --git a/src/Components/PayNowButton.res b/src/Components/PayNowButton.res index 28fe8f9b8..b236279ed 100644 --- a/src/Components/PayNowButton.res +++ b/src/Components/PayNowButton.res @@ -56,11 +56,7 @@ let make = () => { onClick=handleOnClick className={`w-full flex flex-row justify-center items-center rounded-md`} style={ReactDOMStyle.make( - ~backgroundColor={ - sdkHandleConfirmPaymentProps.buttonBackgroundColor->Js.String2.length > 0 - ? sdkHandleConfirmPaymentProps.buttonBackgroundColor - : themeObj.buttonBackgroundColor - }, + ~backgroundColor=sdkHandleConfirmPaymentProps.buttonBackgroundColor, ~height={ sdkHandleConfirmPaymentProps.buttonHeight->Js.String2.length > 0 ? sdkHandleConfirmPaymentProps.buttonHeight @@ -79,11 +75,7 @@ let make = () => { Js.String2.length > 0 - ? sdkHandleConfirmPaymentProps.textColor - : themeObj.buttonTextColor - }, + ~color=sdkHandleConfirmPaymentProps.textColor, ~fontSize={ sdkHandleConfirmPaymentProps.textFontSize->Js.String2.length > 0 ? sdkHandleConfirmPaymentProps.textFontSize diff --git a/src/DefaultTheme.res b/src/DefaultTheme.res index 2a7efee4d..71fe2d796 100644 --- a/src/DefaultTheme.res +++ b/src/DefaultTheme.res @@ -38,8 +38,8 @@ let default = { colorIconCardError: "#fd1717", spacingGridColumn: "20px", spacingGridRow: "20px", - buttonBackgroundColor: "#006df9", - buttonTextColor: "#ffffff", + // buttonBackgroundColor: "#006df9", + // buttonTextColor: "#ffffff", } let defaultRules = theme => { diff --git a/src/LoaderController.res b/src/LoaderController.res index 0beff2771..2bbfc5e3d 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -105,6 +105,16 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger) => { let appearance = optionsAppearance == CardTheme.defaultAppearance ? config.appearance : optionsAppearance + Js.log2("Champ optionsDict", optionsDict) + + let sdkHandleConfirmPaymentProps = CardTheme.getSdkHandleConfirmPaymentProps( + "sdkHandleConfirmPaymentProps", + optionsDict, + PaymentType.defaultValueSdkHandleConfirmPaymentProps, + ) + + Js.log2("Champ sdkHandleConfirmPaymentProps", sdkHandleConfirmPaymentProps) + setConfig(._ => { config: { appearance, @@ -119,6 +129,15 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger) => { : CardTheme.getLocaleObject(localeString), showLoader: config.loader == Auto || config.loader == Always, }) + + setOptionsPayment(.prev => { + ...prev, + sdkHandleConfirmPaymentProps: { + ...prev.sdkHandleConfirmPaymentProps, + buttonBackgroundColor: "red", + textColor: "white", + }, + }) } React.useEffect0(() => { diff --git a/src/MidnightTheme.res b/src/MidnightTheme.res index adfe2bff2..61825a522 100644 --- a/src/MidnightTheme.res +++ b/src/MidnightTheme.res @@ -38,8 +38,8 @@ let midnight = { colorIconCardError: "#fd1717", spacingGridColumn: "20px", spacingGridRow: "20px", - buttonBackgroundColor: "#85d996", - buttonTextColor: "#000000", + // buttonBackgroundColor: "#85d996", + // buttonTextColor: "#000000", } let midnightRules = theme => diff --git a/src/NoTheme.res b/src/NoTheme.res index 81395bcf7..7340bd18d 100644 --- a/src/NoTheme.res +++ b/src/NoTheme.res @@ -39,8 +39,8 @@ let nakedValues = { colorIconCardError: "#fd1717", spacingGridColumn: "20px", spacingGridRow: "20px", - buttonBackgroundColor: "", - buttonTextColor: "", + // buttonBackgroundColor: "", + // buttonTextColor: "", } let nakedValuesRules = _ => Js.Dict.empty()->Js.Json.object_ diff --git a/src/SoftTheme.res b/src/SoftTheme.res index b2433e8a7..05a66d945 100644 --- a/src/SoftTheme.res +++ b/src/SoftTheme.res @@ -39,8 +39,8 @@ let soft = { colorIconCardError: "#fe87a1", spacingGridColumn: "20px", spacingGridRow: "20px", - buttonBackgroundColor: "transparent", - buttonTextColor: "#7d8fff", + // buttonBackgroundColor: "transparent", + // buttonTextColor: "#7d8fff", } let softRules = theme => diff --git a/src/Types/CardThemeType.res b/src/Types/CardThemeType.res index a9345c236..97505436f 100644 --- a/src/Types/CardThemeType.res +++ b/src/Types/CardThemeType.res @@ -51,8 +51,6 @@ type themeClass = { colorIconCardError: string, spacingGridColumn: string, spacingGridRow: string, - buttonBackgroundColor: string, - buttonTextColor: string, } type appearance = { theme: theme,