Skip to content

Commit

Permalink
chore: dead code removal
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja committed Dec 4, 2023
1 parent 4ef0b57 commit 095fb1e
Show file tree
Hide file tree
Showing 14 changed files with 7 additions and 266 deletions.
6 changes: 0 additions & 6 deletions src/entryPoints/hyperswitch/FeatureFlagUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ type featureFlag = {
testLiveToggle: bool,
magicLink: bool,
quickStart: bool,
stripePlusPayPal: bool,
wooCommerce: bool,
openSDK: bool,
switchMerchant: bool,
testLiveMode: option<bool>,
auditTrail: bool,
Expand Down Expand Up @@ -34,9 +31,6 @@ let featureFlagType = (featureFlags: Js.Json.t) => {
testLiveToggle: dict->getBool("test_live_toggle", false),
magicLink: dict->getBool("magic_link", false),
quickStart: dict->getBool("quick_start", false),
stripePlusPayPal: dict->getBool("stripe_plus_paypal", false),
wooCommerce: dict->getBool("woocommerce", false),
openSDK: dict->getBool("open_sdk", false),
switchMerchant: dict->getBool("switch_merchant", false),
testLiveMode: dict->getOptionBool("test_live_mode"),
auditTrail: dict->getBool("audit_trail", false),
Expand Down
4 changes: 1 addition & 3 deletions src/entryPoints/hyperswitch/HyperSwitchEntry.res
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ module HyperSwitchEntryComponent = {
(await postDetails(url, Js.Dict.empty()->Js.Json.object_, Post))->Js.Json.stringify
setFeatureFlag(._ => stringifiedResponse)
} catch {
| Js.Exn.Error(e) => {
let _err = Js.Exn.message(e)->Belt.Option.getWithDefault("Failed to Fetch!")
}
| _ => ()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/entryPoints/hyperswitch/SidebarValues.res
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ let reconTag = (recon, isReconEnabled) =>
: emptyComponent

let getHyperSwitchAppSidebars = (
~isReconEnabled=false,
~isReconEnabled: bool,
~featureFlagDetails: FeatureFlagUtils.featureFlag,
~userRole,
(),
Expand Down
6 changes: 1 addition & 5 deletions src/screens/HyperSwitch/Analytics/HSAnalyticsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ let getStringListFromArrayDict = metrics => {
metrics->Js.Array2.map(item => item->getDictFromJsonObject->getString("name", ""))
}

let getCustomFormattedFloatDate = (floatDate, format) => {
floatDate->Js.Date.fromFloat->Js.Date.toISOString->Table.dateFormat(format)
}

module NoData = {
@react.component
let make = (~title, ~subTitle) => {
Expand Down Expand Up @@ -209,7 +205,7 @@ let generateTablePayload = (
~isIndustry: bool,
~mode: option<string>,
~customFilter,
~showDeltaMetrics=false,
~showDeltaMetrics,
~moduleName as _: string,
~source: string="BATCH",
(),
Expand Down
16 changes: 1 addition & 15 deletions src/screens/HyperSwitch/Developer/DeveloperUtils.res
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
open HSwitchSettingTypes
let titleClass = "md:font-bold font-semibold md:text-fs-16 text-fs-13 text-jp-gray-900 text-opacity-75 dark:text-white dark:text-opacity-75"

let paymentsEvents = ["succeeded", "failed", "processing", "action_required"]
let refundsEvents = ["succeeded", "failed"]
let disputesEvents = ["opened", "expired", "accepted", "cancelled", "challenged", "won", "lost"]

let webhookEventsDict =
[
("payment", paymentsEvents->Js.Array2.map(Js.Json.string)->Js.Json.array),
("refund", refundsEvents->Js.Array2.map(Js.Json.string)->Js.Json.array),
("dispute", disputesEvents->Js.Array2.map(Js.Json.string)->Js.Json.array),
]->Js.Dict.fromArray

let validateAPIKeyForm = (
values: Js.Json.t,
~setIsDisabled=_ => (),
keys: array<string>,
~setShowCustomDate=_ => (),
~setShowCustomDate,
(),
) => {
let errors = Js.Dict.empty()
Expand Down Expand Up @@ -81,7 +69,6 @@ let getRecordTypeFromString = value => {

type apiKey = {
key_id: string,
merchant_id: string,
name: string,
description: string,
prefix: string,
Expand All @@ -93,7 +80,6 @@ type apiKey = {
let itemToObjMapper = dict => {
open LogicUtils
{
merchant_id: getString(dict, "merchant_id", ""),
key_id: getString(dict, "key_id", ""),
name: getString(dict, "name", ""),
description: getString(dict, "description", ""),
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Developer/Webhooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let make = (~webhookOnly=false, ~showFormOnly=false, ~profileId="") => {
open HSwitchSettingTypes
HSwitchMerchantAccountUtils.validateMerchantAccountForm(
~values,
~setIsDisabled,
~setIsDisabled=Some(setIsDisabled),
~fieldsToValidate={
[WebhookUrl, ReturnUrl]->Js.Array2.filter(urlField =>
urlField === WebhookUrl || !webhookOnly
Expand Down
151 changes: 0 additions & 151 deletions src/screens/HyperSwitch/HSwitchUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -92,111 +92,13 @@ module ConnectorCustomCell = {
}
}
}
module HelpDeskSection = {
@react.component
let make = (~helpdeskModal, ~setHelpdeskModal) => {
let hyperswitchMixPanel = HSMixPanel.useSendEvent()
let url = RescriptReactRouter.useUrl()
let textStyle = "font-medium text-fs-14"
let {setShowFeedbackModal} = React.useContext(GlobalProvider.defaultContext)
let handleMixpanelEvents = eventName => {
[url.path->LogicUtils.getListHead, `global`]->Js.Array2.forEach(ele =>
hyperswitchMixPanel(~pageName=ele, ~contextName="helpdesk", ~actionName=eventName, ())
)
}
let handleFeedbackClicked = _ => {
setShowFeedbackModal(_ => true)
"submitfeedback"->handleMixpanelEvents
}

let hoverEffectStyle = "flex gap-3 cursor-pointer hover:border hover:border-blue-700 hover:rounded-md hover:!shadow-[0_0_4px_2px_rgba(0,_112,_255,_0.15)] p-3 border border-transparent"
<>
<UIUtils.RenderIf condition={helpdeskModal}>
<FramerMotion.Motion.Div
initial={{scale: 0.0}}
animate={{scale: 1.0}}
exit={{scale: 0.0}}
transition={{duration: 0.3}}
style={transformOrigin: "top"}
className="absolute top-14 right-0 bg-white p-4 border shadow-[-22px_-8px_41px_-15px_rgba(0,0,0,_0.25)] w-60 flex flex-col gap-2.5 z-10 rounded-md">
<div className=hoverEffectStyle onClick={_ => handleFeedbackClicked()}>
<Icon name="feedback" size=16 />
<p className=textStyle> {"Submit feedback"->React.string} </p>
</div>
<div
className=hoverEffectStyle
onClick={_ => {
"contactonslack"->handleMixpanelEvents
Window._open("https://hyperswitch-io.slack.com/ssb/redirect")
}}>
<Icon size=16 name="slack" />
<p className=textStyle> {"Connect on Slack"->React.string} </p>
</div>
<div
className=hoverEffectStyle
onClick={_ => {
"joindiscord"->handleMixpanelEvents
Window._open("https://discord.gg/an7gRdWkhw")
}}>
<Icon size=16 name="discord" />
<p className=textStyle> {"Join Discord"->React.string} </p>
</div>
</FramerMotion.Motion.Div>
</UIUtils.RenderIf>
<Icon
className="cursor-pointer ml-auto"
name="help-desk"
size=30
onClick={ev => {
open ReactEvent.Mouse
ev->stopPropagation
setHelpdeskModal(prevValue => {
let globalEventText = !prevValue ? "global_helpdesk_open" : "global_helpdesk_close"
let localEventText = !prevValue ? "helpdesk_open" : "helpdesk_close"
let currentPath = url.path->LogicUtils.getListHead

[`${currentPath}_${localEventText}`, globalEventText]->Js.Array2.forEach(ele =>
hyperswitchMixPanel(~eventName=Some(ele), ())
)
!prevValue
})
}}
/>
</>
}
}

let pathToVariantMapper = routeName => {
switch routeName {
| "home" => HOME
| "payments" => PAYMENTS
| "refunds" => REFUNDS
| "disputes" => DISPUTES
| "connectors" => CONNECTOR
| "routing" => ROUTING
| "analytics-payments" => ANALYTICS_PAYMENTS
| "analytics-refunds" => ANALYTICS_REFUNDS
| "settings" => SETTINGS
| "developers" => DEVELOPERS
| _ => HOME
}
}

let isValidEmail = value =>
!Js.Re.test_(
%re(`/^(([^<>()[\]\.,;:\s@"]+(\.[^<>()[\]\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/`),
value,
)

let isUserJourneyAnalyticsAccessAvailable = email => email->Js.String2.includes("juspay")

let convertJsonArrayToArrayOfString = (. val) => {
val
->Js.Json.decodeArray
->Belt.Option.getWithDefault([])
->Js.Array2.map(ele => ele->Js.Json.decodeString->Belt.Option.getWithDefault(""))
}

let useMerchantDetailsValue = () =>
Recoil.useRecoilValueFromAtom(merchantDetailsValueAtom)->safeParse

Expand Down Expand Up @@ -382,49 +284,9 @@ let constructOnboardingBody = (
("account_activation", copyOfIntegrationDetails.account_activation->returnIntegrationJson),
])->Js.Json.object_
}
module OnboardingChecklistTile = {
@react.component
let make = (~setShowOnboardingModal) => {
let hyperswitchMixPanel = HSMixPanel.useSendEvent()
let url = RescriptReactRouter.useUrl()
<div
className="absolute bottom-0 right-0 cursor-pointer px-5 py-2 bg-white h-20 w-[26rem] flex justify-between items-center !shadow-checklistShadow"
onClick={_ => {
setShowOnboardingModal(_ => true)

[url.path->LogicUtils.getListHead, "global"]->Js.Array2.forEach(ele =>
hyperswitchMixPanel(~eventName=Some(`${ele}_onboarding_checklist`), ())
)
}}>
<div className="w-full flex nowrap items-center gap-2">
<div className="font-semibold text-xl"> {"Onboarding Checklist"->React.string} </div>
<span className="relative flex h-3 w-3">
<span
className="animate-ping absolute inline-flex h-full w-full rounded-full bg-sky-400 opacity-75"
/>
<span className="relative inline-flex rounded-full h-3 w-3 bg-sky-500" />
</span>
</div>
<Icon name="arrow-without-tail" />
</div>
}
}

let isEmptyString = str => str->Js.String2.length <= 0

let parseUrl = url => {
url
->Js.Global.decodeURI
->Js.String2.split("&")
->Belt.Array.keepMap(str => {
let arr = str->Js.String2.split("=")
let key = arr->Belt.Array.get(0)->Belt.Option.getWithDefault("-")
let val = arr->Belt.Array.sliceToEnd(1)->Js.Array2.joinWith("=")
key === "" || val === "" ? None : Some((key, val))
})
->Js.Dict.fromArray
}

type textVariantType =
| H1
| H2
Expand Down Expand Up @@ -453,19 +315,6 @@ let getTextClass = (~textVariant, ~h3TextVariant=Leading_1, ~paragraphTextVarian
}
}

module CardLoader = {
@react.component
let make = () => {
<div className="w-full h-full flex justify-center items-center">
<div className="w-24 h-24 scale-[0.5]">
<div className="-mt-5 -ml-12">
<Loader />
</div>
</div>
</div>
}
}

let checkStripePlusPayPal = (enumDetails: QuickStartTypes.responseType) => {
enumDetails.stripeConnected.processorID->Js.String2.length > 0 &&
enumDetails.paypalConnected.processorID->Js.String2.length > 0 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,55 +733,3 @@ app.post("/create-payment", async (req, res) => {
});
app.listen(4242, () => console.log("Node server listening on port 4242!"));`

let reactDisplayPaymentConfirmation: string = `const handleSubmit = async (e) => {
e.preventDefault();
if (!hyper || !widgets) {
// hyper-js has not yet loaded.
// Make sure to disable form submission until hyper-js has loaded.
return;
}
setIsLoading(true);
const { error } = await hyper.confirmPayment({
widgets,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: "https://example.com/complete",
},
});
// This point will only be reached if there is an immediate error occurring while confirming the payment. Otherwise, your customer will be redirected to your "return_url"
// For some payment flows such as Sofort, iDEAL, your customer will be redirected to an intermediate page to complete authorization of the payment, and then redirected to the "return_url".
if (error.type === "validation_error") {
setMessage(error.message);
} else {
setMessage("An unexpected error occurred.");
}
setIsLoading(false);
};`

let nodeDisplayPaymentConfirmation: string = `//Look for a parameter called "payment_intent_client_secret" in the url which gives a payment ID, which is then used to retrieve the status of the payment
const paymentID = new URLSearchParams(window.location.search).get(
"payment_intent_client_secret"
);
if (!paymentID) {
return;
}
hyper.retrievePaymentIntent(paymentID).then(({ paymentIntent }) => {
switch (paymentIntent.status) {
case "succeeded":
setMessage("Payment succeeded!");
break;
case "processing":
setMessage("Your payment is processing.");
break;
case "requires_payment_method":
setMessage("Your payment was not successful, please try again.");
break;
default:
setMessage("Something went wrong.");
break;
}
});`
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
let headerTextCss = "font-semibold text-grey-700 text-xl"
let subTextCss = "font-normal text-grey-700 opacity-50 text-base"

let buildHyperswitch: array<UserOnboardingTypes.sectionContentType> = [
{
headerIcon: "migrate-from-stripe",
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Settings/BusinessDetails.res
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ let make = () => {
validateMerchantAccountForm(
~values,
~fieldsToValidate=[PrimaryPhone, PrimaryEmail, Website, SecondaryEmail, SecondaryPhone],
~setIsDisabled,
~setIsDisabled=Some(setIsDisabled),
~initialData={merchantInfo->Js.Json.object_},
)
}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ let getItems: Js.Json.t => array<profileEntity> = json => {
LogicUtils.getArrayDataFromJson(json, itemToObjMapper)
}

let apiKeysTableEntity = EntityType.makeEntity(
~uri="",
~getObjects=getItems,
~defaultColumns,
~allColumns,
~getHeading,
~dataKey="",
~getCell,
(),
)

let businessProfileTabelEntity = showLink =>
EntityType.makeEntity(
~uri="",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ let validateCustom = (key, errors, value) => {
let validateMerchantAccountForm = (
~values: Js.Json.t,
~fieldsToValidate: array<validationFields>,
~setIsDisabled=?,
~setIsDisabled,
~initialData,
) => {
let errors = Js.Dict.empty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ let roleListResponseMapper: Js.Dict.t<
> => HSwitchUserRoleEntity.roleListResponse = dict => {
open LogicUtils
{
permissions: dict->getStrArray("permissions"),
role_id: dict->getString("role_id", ""),
role_name: dict->getString("role_name", ""),
}
Expand Down
Loading

0 comments on commit 095fb1e

Please sign in to comment.