|
110 | 110 | [rn/view
|
111 | 111 | [quo/icon :i/info {:no-color true}]]])
|
112 | 112 |
|
| 113 | +(defn- network-not-supported |
| 114 | + [] |
| 115 | + [quo/text (i18n/label :network-not-supported)]) |
| 116 | + |
| 117 | +(defn- request-access-button |
| 118 | + [id color] |
| 119 | + [quo/button |
| 120 | + {:on-press (if config/community-accounts-selection-enabled? |
| 121 | + #(rf/dispatch [:open-modal :community-account-selection |
| 122 | + {:community-id id}]) |
| 123 | + #(rf/dispatch [:open-modal :community-requests-to-join {:id id}])) |
| 124 | + :accessibility-label :show-request-to-join-screen-button |
| 125 | + :customization-color color |
| 126 | + :icon-left :i/communities} |
| 127 | + (i18n/label :t/request-to-join)]) |
| 128 | + |
113 | 129 | (defn- token-requirements
|
114 |
| - [{:keys [id color]}] |
| 130 | + [{:keys [id color role-permissions?]}] |
115 | 131 | (let [{:keys [can-request-access?
|
116 |
| - number-of-hold-tokens tokens |
| 132 | + no-member-permission? |
| 133 | + tokens |
| 134 | + networks-not-supported? |
117 | 135 | highest-permission-role]} (rf/sub [:community/token-gated-overview id])
|
118 | 136 | highest-role-text
|
119 | 137 | (i18n/label
|
120 | 138 | (communities.utils/role->translation-key highest-permission-role :t/member))]
|
121 |
| - [rn/view {:style (style/token-gated-container)} |
122 |
| - [rn/view |
123 |
| - {:style {:padding-horizontal 12 |
124 |
| - :flex-direction :row |
125 |
| - :align-items :center |
126 |
| - :justify-content :space-between |
127 |
| - :flex 1}} |
128 |
| - [quo/text {:weight :medium} |
129 |
| - (if can-request-access? |
130 |
| - (i18n/label :t/you-eligible-to-join-as {:role highest-role-text}) |
131 |
| - (i18n/label :t/you-not-eligible-to-join))] |
132 |
| - [info-button]] |
133 |
| - (when (pos? number-of-hold-tokens) |
| 139 | + (cond |
| 140 | + |
| 141 | + networks-not-supported? |
| 142 | + [network-not-supported] |
| 143 | + |
| 144 | + (or (not role-permissions?) no-member-permission?) |
| 145 | + [request-access-button id color] |
| 146 | + |
| 147 | + :else |
| 148 | + [rn/view {:style (style/token-gated-container)} |
| 149 | + [rn/view |
| 150 | + {:style {:padding-horizontal 12 |
| 151 | + :flex-direction :row |
| 152 | + :align-items :center |
| 153 | + :justify-content :space-between |
| 154 | + :flex 1}} |
| 155 | + [quo/text {:weight :medium} |
| 156 | + (if (and can-request-access? highest-permission-role) |
| 157 | + (i18n/label :t/you-eligible-to-join-as {:role highest-role-text}) |
| 158 | + (i18n/label :t/you-not-eligible-to-join))] |
| 159 | + [info-button]] |
134 | 160 | [quo/text {:style {:padding-horizontal 12 :padding-bottom 18} :size :paragraph-2}
|
135 | 161 | (if can-request-access?
|
136 |
| - (i18n/label :t/you-hold-number-of-hold-tokens-of-these |
137 |
| - {:number-of-hold-tokens number-of-hold-tokens}) |
138 |
| - (i18n/label :t/you-must-hold))]) |
139 |
| - [quo/token-requirement-list |
140 |
| - {:tokens tokens |
141 |
| - :padding? true}] |
142 |
| - [quo/button |
143 |
| - {:on-press (if config/community-accounts-selection-enabled? |
144 |
| - #(rf/dispatch [:open-modal :community-account-selection |
145 |
| - {:community-id id}]) |
146 |
| - #(rf/dispatch [:open-modal :community-requests-to-join {:id id}])) |
147 |
| - :accessibility-label :join-community-button |
148 |
| - :customization-color color |
149 |
| - :container-style {:margin-horizontal 12 :margin-top 12 :margin-bottom 12} |
150 |
| - :disabled? (not can-request-access?) |
151 |
| - :icon-left (if can-request-access? :i/unlocked :i/locked)} |
152 |
| - (i18n/label :t/join-open-community)]])) |
| 162 | + (i18n/label :t/you-hodl) |
| 163 | + (i18n/label :t/you-must-hold))] |
| 164 | + [quo/token-requirement-list |
| 165 | + {:tokens tokens |
| 166 | + :padding? true}] |
| 167 | + [quo/button |
| 168 | + {:on-press (if config/community-accounts-selection-enabled? |
| 169 | + #(rf/dispatch [:open-modal :community-account-selection |
| 170 | + {:community-id id}]) |
| 171 | + #(rf/dispatch [:open-modal :community-requests-to-join {:id id}])) |
| 172 | + :accessibility-label :join-community-button |
| 173 | + :customization-color color |
| 174 | + :container-style {:margin-horizontal 12 :margin-top 12 :margin-bottom 12} |
| 175 | + :disabled? (not can-request-access?) |
| 176 | + :icon-left (if can-request-access? :i/unlocked :i/locked)} |
| 177 | + (i18n/label :t/join-open-community)]]))) |
| 178 | + |
153 | 179 |
|
154 | 180 | (defn- join-community
|
155 |
| - [{:keys [id color joined permissions role-permissions? can-join?] :as community}] |
| 181 | + [{:keys [id joined permissions role-permissions? can-join?] :as community}] |
156 | 182 | (let [pending? (rf/sub [:communities/my-pending-request-to-join id])
|
157 | 183 | access-type (get-access-type (:access permissions))
|
158 | 184 | unknown-access? (= access-type :unknown-access)
|
159 | 185 | invite-only? (= access-type :invite-only)]
|
160 | 186 | [:<>
|
161 | 187 | (when-not (or joined pending? invite-only? unknown-access?)
|
162 |
| - (if role-permissions? |
163 |
| - [token-requirements community] |
164 |
| - [quo/button |
165 |
| - {:on-press (if config/community-accounts-selection-enabled? |
166 |
| - #(rf/dispatch [:open-modal :community-account-selection |
167 |
| - {:community-id id}]) |
168 |
| - #(rf/dispatch [:open-modal :community-requests-to-join {:id id}])) |
169 |
| - :accessibility-label :show-request-to-join-screen-button |
170 |
| - :customization-color color |
171 |
| - :icon-left :i/communities} |
172 |
| - (i18n/label :t/request-to-join)])) |
| 188 | + [token-requirements community]) |
173 | 189 | (when (not (or pending? role-permissions? can-join?))
|
174 | 190 | [quo/text
|
175 | 191 | {:size :paragraph-2
|
|
0 commit comments