mirror of
https://github.com/penpot/penpot.git
synced 2026-09-13 15:38:38 +00:00
✨ Improve nitrate manual renew banner
This commit is contained in:
parent
92cf0cda7b
commit
98e04bc5f0
@ -7,7 +7,9 @@
|
|||||||
[app.common.time :as ct]
|
[app.common.time :as ct]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.event :as ev]
|
[app.main.data.event :as ev]
|
||||||
|
[app.main.data.modal :as modal]
|
||||||
[app.main.data.nitrate :as dnt]
|
[app.main.data.nitrate :as dnt]
|
||||||
|
[app.main.refs :as refs]
|
||||||
[app.main.router :as rt]
|
[app.main.router :as rt]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.dropdown-menu :refer [dropdown-menu-item*]]
|
[app.main.ui.components.dropdown-menu :refer [dropdown-menu-item*]]
|
||||||
@ -119,24 +121,39 @@
|
|||||||
|
|
||||||
(mf/defc nitrate-sidebar*
|
(mf/defc nitrate-sidebar*
|
||||||
[{:keys [profile teams]}]
|
[{:keys [profile teams]}]
|
||||||
(let [nitrate? (dnt/is-valid-license? profile)
|
(let [nitrate? (dnt/is-valid-license? profile)
|
||||||
nitrate-license (:subscription profile)
|
nitrate-license (:subscription profile)
|
||||||
manual-license? (:manual nitrate-license)
|
manual-license? (:manual nitrate-license)
|
||||||
subscription-warning* (mf/use-state nil)
|
subscription-warning* (mf/use-state nil)
|
||||||
subscription-warning (deref subscription-warning*)
|
subscription-warning (deref subscription-warning*)
|
||||||
days-until-expiry (or (:days-until-expiry subscription-warning)
|
route (mf/deref refs/route)
|
||||||
(:daysUntilExpiry subscription-warning)
|
route-name (get-in route [:data :name])
|
||||||
(:days-from-expiry subscription-warning)
|
|
||||||
(:daysFromExpiry subscription-warning))
|
days-until-expiry
|
||||||
expiration-date (or (:expiration-date subscription-warning)
|
(or (:days-until-expiry subscription-warning)
|
||||||
(:expirationDate subscription-warning))
|
(:daysUntilExpiry subscription-warning)
|
||||||
expiration-date-text (when expiration-date
|
(:days-from-expiry subscription-warning)
|
||||||
(ct/format-inst expiration-date "MMMM d"))
|
(:daysFromExpiry subscription-warning))
|
||||||
show-subscription-warning? (and manual-license?
|
|
||||||
(some? days-until-expiry)
|
expiration-date
|
||||||
(some? expiration-date-text))
|
(or (:expiration-date subscription-warning)
|
||||||
subscription-type (if nitrate? (:type nitrate-license) (get-subscription-type (-> profile :props :subscription)))
|
(:expirationDate subscription-warning))
|
||||||
|
expiration-date-text
|
||||||
|
(when expiration-date
|
||||||
|
(ct/format-inst expiration-date "MMMM d"))
|
||||||
|
|
||||||
|
show-subscription-warning?
|
||||||
|
(and nitrate?
|
||||||
|
manual-license?
|
||||||
|
(not= route-name :settings-subscription)
|
||||||
|
(some? days-until-expiry)
|
||||||
|
(some? expiration-date-text))
|
||||||
|
|
||||||
|
subscription-type
|
||||||
|
(if nitrate? (:type nitrate-license) (get-subscription-type (-> profile :props :subscription)))
|
||||||
|
|
||||||
teams-loaded? (seq teams)
|
teams-loaded? (seq teams)
|
||||||
|
|
||||||
no-orgs-created? (mf/with-memo [teams]
|
no-orgs-created? (mf/with-memo [teams]
|
||||||
(and (seq teams)
|
(and (seq teams)
|
||||||
(->> teams
|
(->> teams
|
||||||
@ -154,8 +171,8 @@
|
|||||||
handle-go-to-cc
|
handle-go-to-cc
|
||||||
(mf/use-fn dnt/go-to-nitrate-ac-create-org)
|
(mf/use-fn dnt/go-to-nitrate-ac-create-org)
|
||||||
|
|
||||||
handle-go-to-subscription
|
handle-open-renew-modal
|
||||||
(mf/use-fn #(st/emit! (rt/nav :settings-subscription)))]
|
(mf/use-fn #(st/emit! (modal/show :nitrate-code-activation {:renew? true})))]
|
||||||
|
|
||||||
(mf/with-effect [manual-license?]
|
(mf/with-effect [manual-license?]
|
||||||
(if manual-license?
|
(if manual-license?
|
||||||
@ -208,7 +225,7 @@
|
|||||||
[:> button* {:variant "primary"
|
[:> button* {:variant "primary"
|
||||||
:type "button"
|
:type "button"
|
||||||
:class (stl/css :nitrate-bottom-button)
|
:class (stl/css :nitrate-bottom-button)
|
||||||
:on-click handle-go-to-subscription}
|
:on-click handle-open-renew-modal}
|
||||||
(tr "subscription.dashboard.banner.renew")]]])]))
|
(tr "subscription.dashboard.banner.renew")]]])]))
|
||||||
|
|
||||||
(mf/defc nitrate-current-plan*
|
(mf/defc nitrate-current-plan*
|
||||||
|
|||||||
@ -91,18 +91,17 @@
|
|||||||
:bottom-link (not (or has-trial? code-action)))
|
:bottom-link (not (or has-trial? code-action)))
|
||||||
:on-click cta-link} cta-text])
|
:on-click cta-link} cta-text])
|
||||||
(when code-action
|
(when code-action
|
||||||
[:button {:class (stl/css-case :cta-button true
|
(if (= code-action :activate)
|
||||||
:activate-by-code (= code-action :activate)
|
[:button {:class (stl/css :cta-button :activate-by-code)
|
||||||
:renew-by-code (= code-action :renovate)
|
:on-click #(st/emit! (modal/show {:type :nitrate-code-activation}))}
|
||||||
:bottom-link (= code-action :renovate))
|
(tr "subscription.settings.activate-by-code")]
|
||||||
:on-click (cond
|
|
||||||
(= code-action :activate)
|
[:> button* {:variant "primary"
|
||||||
#(st/emit! (modal/show {:type :nitrate-code-activation}))
|
:type "button"
|
||||||
(= code-action :renovate)
|
:class (stl/css :renew-by-code :bottom-link)
|
||||||
#(st/emit! (modal/show :nitrate-code-activation {:renew? true})))}
|
:on-click #(st/emit! (modal/show :nitrate-code-activation {:renew? true}))}
|
||||||
(if (= code-action :activate)
|
(tr "nitrate.subscription.settings.renew-with-code")]))
|
||||||
(tr "subscription.settings.activate-by-code")
|
|
||||||
(tr "nitrate.subscription.settings.renew-with-code"))])
|
|
||||||
(when inline-error
|
(when inline-error
|
||||||
[:p {:class (stl/css :inline-error)} inline-error])]))
|
[:p {:class (stl/css :inline-error)} inline-error])]))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user