Skip to content

Commit

Permalink
Filter recurrent providers
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayesivan committed May 29, 2024
1 parent f2a6a23 commit 7adc5cb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/status_im/contexts/wallet/sheets/buy_token/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@
[utils.re-frame :as rf]))

(defn- crypto-on-ramp-item
[{:keys [name description fees logo-url site-url]}]
[quo/settings-item
{:title name
:description :text
:description-props {:text description}
:tag :context
:tag-props {:icon :i/fees
:context fees}
:action :arrow
:action-props {:alignment :flex-start
:icon :i/external}
:image :icon-avatar
:image-props {:icon logo-url}
:on-press #(rn/open-url site-url)}])
[{:keys [name description fees logo-url site-url recurrent-site-url]} _ _ {:keys [tab]}]
(let [open-url (rn/use-callback (fn []
(rn/open-url (if (= tab :recurrent) recurrent-site-url site-url)))
[site-url recurrent-site-url tab])]
[quo/settings-item
{:title name
:description :text
:description-props {:text description}
:tag :context
:tag-props {:icon :i/fees
:context fees}
:action :arrow
:action-props {:alignment :flex-start
:icon :i/external}
:image :icon-avatar
:image-props {:icon logo-url}
:on-press open-url}]))

(def ^:private tabs
[{:id :one-time
Expand All @@ -35,8 +38,8 @@
[]
(rn/use-mount (fn []
(rf/dispatch [:wallet/get-crypto-on-ramps])))
(let [crypto-on-ramps (rf/sub [:wallet/crypto-on-ramps])
crypto-recurrent []
(let [one-time-crypto-on-ramps (rf/sub [:wallet/one-time-crypto-on-ramps])
recurrent-crypto-on-ramps (rf/sub [:wallet/recurrent-crypto-on-ramps])
[selected-tab set-selected-tab] (rn/use-state initial-tab)
[min-height set-min-height] (rn/use-state 0)
on-layout (rn/use-callback
Expand All @@ -52,9 +55,10 @@
:on-change set-selected-tab
:data tabs}])
[rn/flat-list
{:data (if (and (ff/enabled? ::ff/wallet.buy-recurrent-assets) (= selected-tab :recurrent))
crypto-recurrent
crypto-on-ramps)
:on-layout on-layout
:style (style/list-container min-height)
:render-fn crypto-on-ramp-item}]]))
{:data (if (and (ff/enabled? ::ff/wallet.buy-recurrent-assets) (= selected-tab :recurrent))
recurrent-crypto-on-ramps
one-time-crypto-on-ramps)
:on-layout on-layout
:style (style/list-container min-height)
:render-data {:tab selected-tab}
:render-fn crypto-on-ramp-item}]]))
12 changes: 12 additions & 0 deletions src/status_im/subs/wallet/buy.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@
:wallet/crypto-on-ramps
:<- [:wallet]
:-> :crypto-on-ramps)

(rf/reg-sub
:wallet/one-time-crypto-on-ramps
:<- [:wallet/crypto-on-ramps]
(fn [crypto-on-ramps _]
(filter #(seq (:site-url %)) crypto-on-ramps)))

(rf/reg-sub
:wallet/recurrent-crypto-on-ramps
:<- [:wallet/crypto-on-ramps]
(fn [crypto-on-ramps _]
(filter #(seq (:recurrent-site-url %)) crypto-on-ramps)))

0 comments on commit 7adc5cb

Please sign in to comment.