diff --git a/package.json b/package.json index 037ef1af3e..c3591d2b86 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "@internxt/css-config": "^1.0.2", "@internxt/inxt-js": "=1.2.21", "@internxt/lib": "^1.2.0", + "@internxt/sdk": "=1.9.9", "@internxt/ui": "^0.0.16", - "@internxt/sdk": "=1.9.8", "@phosphor-icons/react": "^2.1.7", "@popperjs/core": "^2.11.6", "@reduxjs/toolkit": "^1.6.0", diff --git a/src/app/newSettings/Sections/Account/Plans/PlansSection.tsx b/src/app/newSettings/Sections/Account/Plans/PlansSection.tsx index cc3405b10a..f72b2478b8 100644 --- a/src/app/newSettings/Sections/Account/Plans/PlansSection.tsx +++ b/src/app/newSettings/Sections/Account/Plans/PlansSection.tsx @@ -275,10 +275,31 @@ const PlansSection = ({ changeSection, onClosePreferences }: PlansSectionProps) } }; + const handleIndividualUserCurrentSubscription = (plan: DisplayPrice) => { + switch (individualSubscription?.type) { + case 'free': + return false; + case 'subscription': + return ( + individualSubscription?.productId === plan.productId && individualSubscription.interval === plan.interval + ); + case 'lifetime': + return individualSubscription.productId === plan.productId && plan.interval === 'lifetime'; + + default: + return false; + } + }; + const isCurrentSubscriptionPlan = (plan: DisplayPrice) => { + const isBusinessCurrentPlanSelected = + businessSubscription?.type === 'subscription' && + businessSubscription?.productId === plan.productId && + businessSubscription.interval === plan.interval; + return isIndividualSubscriptionSelected - ? individualSubscription?.type === 'subscription' && individualSubscription?.priceId === plan.id - : businessSubscription?.type === 'subscription' && businessSubscription?.priceId === plan.id; + ? handleIndividualUserCurrentSubscription(plan) + : isBusinessCurrentPlanSelected; }; return ( @@ -358,11 +379,7 @@ const PlansSection = ({ changeSection, onClosePreferences }: PlansSectionProps) onCancelSubscription={setIsCancelSubscriptionModalOpen} priceSelected={priceSelected} pricesToRender={pricesFilteredAndSorted(selectedSubscriptionType)} - isCurrentPlan={ - isIndividualSubscriptionSelected - ? individualSubscription?.type === 'subscription' && individualSubscription?.priceId === priceSelected.id - : businessSubscription?.type === 'subscription' && businessSubscription?.priceId === priceSelected.id - } + isCurrentPlan={isCurrentSubscriptionPlan(priceSelected)} isBusinessPlan={isBusinessSubscriptionSelected} translate={translate} handleOnPlanSelected={handleOnPlanSelected} diff --git a/yarn.lock b/yarn.lock index f7fd4cd899..54e63a2700 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2735,10 +2735,10 @@ resolved "https://npm.pkg.github.com/download/@internxt/prettier-config/1.0.2/5bd220b8de76734448db5475b3e0c01f9d22c19b#5bd220b8de76734448db5475b3e0c01f9d22c19b" integrity sha512-t4HiqvCbC7XgQepwWlIaFJe3iwW7HCf6xOSU9nKTV0tiGqOPz7xMtIgLEloQrDA34Cx4PkOYBXrvFPV6RxSFAA== -"@internxt/sdk@=1.9.8": - version "1.9.8" - resolved "https://npm.pkg.github.com/download/@internxt/sdk/1.9.8/c69dfd1c47469eeaa9d753af720fb841f36579a3#c69dfd1c47469eeaa9d753af720fb841f36579a3" - integrity sha512-LpXRcz6SNYwc/IpTT6xr8emCCXOYFh+oEl7VMfDF1ODfA4tOvFzqGYKLpB0irSgjWjlzvTWq8v6qXgboDhcicw== +"@internxt/sdk@=1.9.9": + version "1.9.9" + resolved "https://npm.pkg.github.com/download/@internxt/sdk/1.9.9/41aaf713bfa85688a09bcfce35814b831389b9be#41aaf713bfa85688a09bcfce35814b831389b9be" + integrity sha512-3bhC/WBunAeGLpexEOj84xgZbznwDdTripoLj/fmnPEKW4PpCGP0tS7f58IMDSMkpPMhB6wTSMAXXLW9LfQNNg== dependencies: axios "^0.24.0" query-string "^7.1.0" @@ -6950,7 +6950,7 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" -crypto-browserify@^3.12.0, "crypto@npm:crypto-browserify": +crypto-browserify@^3.12.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== @@ -6977,6 +6977,23 @@ crypto-random-string@^2.0.0: resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== +"crypto@npm:crypto-browserify": + version "3.12.0" + resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" + integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== + dependencies: + browserify-cipher "^1.0.0" + browserify-sign "^4.0.0" + create-ecdh "^4.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.0" + diffie-hellman "^5.0.0" + inherits "^2.0.1" + pbkdf2 "^3.0.3" + public-encrypt "^4.0.0" + randombytes "^2.0.0" + randomfill "^1.0.3" + css-blank-pseudo@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/css-blank-pseudo/-/css-blank-pseudo-3.0.3.tgz#36523b01c12a25d812df343a32c322d2a2324561" @@ -14201,7 +14218,16 @@ string-natural-compare@^3.0.1: resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4" integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw== -"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -14284,7 +14310,14 @@ stringify-object@^3.3.0: is-obj "^1.0.1" is-regexp "^1.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -15937,7 +15970,7 @@ workbox-window@6.6.1: "@types/trusted-types" "^2.0.2" workbox-core "6.6.1" -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -15955,6 +15988,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.0.1, wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"