[#21615] fix: hide tabs if there is no recurrent data

This commit is contained in:
Mohsen 2024-11-21 18:39:54 +03:00
parent dadb10bf37
commit 47777132bd
No known key found for this signature in database
GPG Key ID: 20BACCB8426033CE
1 changed files with 25 additions and 15 deletions

View File

@ -49,6 +49,7 @@
(rf/dispatch [:wallet/get-crypto-on-ramps])))
(let [crypto-on-ramps (rf/sub [:wallet/crypto-on-ramps])
account (rf/sub [:wallet/current-viewing-account-or-default])
has-recurrent? (seq (: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
@ -56,18 +57,27 @@
(oops/oget % :nativeEvent :layout :height)))]
[:<>
[quo/drawer-top {:title (or title (i18n/label :t/ways-to-buy-assets))}]
[quo/segmented-control
{:size 32
:container-style style/tabs
:default-active initial-tab
:on-change set-selected-tab
:data tabs}]
[rn/flat-list
{:data (if (= 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
:account account}
:render-fn crypto-on-ramp-item}]]))
(when has-recurrent?
[:<>
[quo/segmented-control
{:size 32
:container-style style/tabs
:default-active initial-tab
:on-change set-selected-tab
:data tabs}]
[rn/flat-list
{:data (if (= 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
:account account}
:render-fn crypto-on-ramp-item}]])
(when-not has-recurrent?
[rn/flat-list
{:data (:one-time crypto-on-ramps)
:on-layout on-layout
:style (style/list-container min-height)
:render-data {:account account}
:render-fn crypto-on-ramp-item}])]))