|
119 | 119 | </div> |
120 | 120 | </div> |
121 | 121 | <% else %> |
122 | | - |
123 | 122 | <% title "Account Settings" %> |
124 | 123 | <% page_md %> |
| 124 | + <% disabled = !policy(@user).update? %> |
| 125 | + |
125 | 126 | <%= render "users/nav", selected: :settings %> |
126 | 127 | <h1>Settings</h1> |
127 | 128 | <turbo-frame id="settings" autoscroll data-autoscroll-behavior="smooth"> |
128 | 129 | <%= render "settings_nav", active: "general" unless @onboarding %> |
129 | 130 | <section> |
130 | | - <% if @onboarding %> |
131 | | - <p>Complete your profile to get started.</p> |
132 | | - <% end %> |
133 | 131 | <%= form_with(model: @user, local: true, html: { onsubmit: "onSubmit()" }, data: { turbo_frame: "_top" }) do |form| %> |
134 | 132 | <%= form_errors @user, "profile", "We couldn't update your" %> |
135 | 133 | <% if current_season(override_preference: true) %> |
136 | 134 | <div class="field field--checkbox"> |
137 | | - <%= form.check_box :seasonal_themes_enabled %> |
| 135 | + <%= form.check_box :seasonal_themes_enabled, disabled: %> |
138 | 136 | <%= form.label :seasonal_themes_enabled, "#{by_season "✨", override_preference: true, fall: "🎃", winter: "🎄"} Enable #{current_season(override_preference: true)} theme", class: "h3 bold" %> |
139 | 137 | </div> |
140 | 138 | <% end %> |
141 | 139 |
|
142 | 140 | <div class="field"> |
143 | 141 | <%= form.label :full_name %> |
144 | | - <%= form.text_field :full_name, required: true, placeholder: "Fiona Hackworth III", pattern: '^\S+.+' %> |
| 142 | + <%= form.text_field :full_name, required: true, placeholder: "Fiona Hackworth III", pattern: '^\S+.+', disabled: %> |
145 | 143 | <% @user.errors.full_messages_for(:full_name).each do |message| %> |
146 | 144 | <div class="primary"><%= message %></div> |
147 | 145 | <% end %> |
148 | 146 | </div> |
149 | 147 | <div class="field"> |
150 | 148 | <%= form.label :preferred_name %> |
151 | 149 | <p class="h5 muted mt0 mb1">If you go by a different name.</p> |
152 | | - <%= form.text_field :preferred_name, placeholder: @user.full_name.presence || "FiFi Hacks", maxlength: 30 %> |
| 150 | + <%= form.text_field :preferred_name, placeholder: @user.full_name.presence || "FiFi Hacks", maxlength: 30, disabled: %> |
153 | 151 | </div> |
154 | 152 |
|
155 | 153 | <div class="field"> |
156 | 154 | <%= form.label :phone_number, "Mobile phone number" %> |
157 | | - <% if @onboarding %> |
158 | | - <p class="h5 muted mt0 mb1"> |
159 | | - To contact you on short notice. |
160 | | - </p> |
161 | | - <% end %> |
162 | 155 | <% if @user.use_sms_auth %> |
163 | 156 | <p class="h5 muted mt0 mb1"> |
164 | 157 | Changing your number will turn off SMS login codes. |
|
183 | 176 | start_year: Date.today.year, |
184 | 177 | end_year: Date.today.year - 100, |
185 | 178 | order: [:month, :day, :year], |
186 | | - prompt: @user.birthday.nil? %> |
| 179 | + prompt: @user.birthday.nil?, |
| 180 | + disabled: %> |
187 | 181 | <% unless @user.birthday.nil? %> |
188 | 182 | <% admin_tool do %> |
189 | | - <%= @user.birthday > 19.years.ago ? "✅ Teenager" : "Not a teenager" %> |
| 183 | + <%= @user.teenager? ? "✅ Teenager" : "Not a teenager" %> |
190 | 184 | <% end %> |
191 | 185 | <% end %> |
192 | 186 | </div> |
193 | 187 | </div> |
194 | 188 | <div class="field"> |
195 | 189 | <%= form.label :email %> |
196 | | - <%= form.email_field :email %> |
| 190 | + <%= form.email_field :email, disabled: %> |
197 | 191 | <% if @user.email_updates.active.any? %> |
198 | 192 | <p style="max-width: 420px;"> |
199 | 193 | <small> |
|
221 | 215 | </p> |
222 | 216 | <div class="field field--fileupload"> |
223 | 217 | <%= form.label :profile_picture, "Upload picture", class: "field--fileupload__label" %> |
224 | | - <%= form.file_field :profile_picture, accept: "image/png, image/jpeg", class: "field--fileupload__field" %> |
| 218 | + <%= form.file_field :profile_picture, accept: "image/png, image/jpeg", class: "field--fileupload__field", disabled: %> |
225 | 219 | </div> |
226 | 220 | </div> |
227 | 221 |
|
228 | | - <% unless @onboarding %> |
229 | | - <% if @user.has_discord_account? %> |
230 | | - <div class="card max-w-6xl"> |
231 | | - <p class="medium">Connected Discord account</p> |
232 | | - <p class="h5 muted mt-0 mb-3"> |
233 | | - You've set up the HCB discord bot |
234 | | - </p> |
235 | | - <p>@<%= @user.discord_account.username %></p> |
236 | | - </div> |
237 | | - <% end %> |
238 | | - |
239 | | - <fieldset> |
240 | | - <legend class="medium">Share usage data with HCB</legend> |
| 222 | + <% if @user.has_discord_account? %> |
| 223 | + <div class="card max-w-6xl"> |
| 224 | + <p class="medium">Connected Discord account</p> |
241 | 225 | <p class="h5 muted mt-0 mb-3"> |
242 | | - Help us improve HCB by sending usage data. |
243 | | - Off by default. |
| 226 | + You've set up the HCB discord bot |
244 | 227 | </p> |
245 | | - <div class="field field--options"> |
246 | | - <%= form.radio_button :sessions_reported, true %> |
247 | | - <%= form.label :sessions_reported, value: true do %> |
248 | | - <%= inline_icon "support", size: 28 %> |
249 | | - <strong>Sure thing!</strong> |
250 | | - <% end %> |
251 | | - <%= form.radio_button :sessions_reported, false %> |
252 | | - <%= form.label :sessions_reported, value: false do %> |
253 | | - <%= inline_icon "thumbsdown", size: 28 %> |
254 | | - <strong>No thanks</strong> |
255 | | - <% end %> |
256 | | - </div> |
257 | | - </fieldset> |
| 228 | + <p>@<%= @user.discord_account.username %></p> |
| 229 | + </div> |
258 | 230 | <% end %> |
259 | 231 |
|
| 232 | + <fieldset> |
| 233 | + <legend class="medium">Share usage data with HCB</legend> |
| 234 | + <p class="h5 muted mt-0 mb-3"> |
| 235 | + Help us improve HCB by sending usage data. |
| 236 | + Off by default. |
| 237 | + </p> |
| 238 | + <div class="field field--options"> |
| 239 | + <%= form.radio_button :sessions_reported, true, disabled: %> |
| 240 | + <%= form.label :sessions_reported, value: true do %> |
| 241 | + <%= inline_icon "support", size: 28 %> |
| 242 | + <strong>Sure thing!</strong> |
| 243 | + <% end %> |
| 244 | + <%= form.radio_button :sessions_reported, false, disabled: %> |
| 245 | + <%= form.label :sessions_reported, value: false do %> |
| 246 | + <%= inline_icon "thumbsdown", size: 28 %> |
| 247 | + <strong>No thanks</strong> |
| 248 | + <% end %> |
| 249 | + </div> |
| 250 | + </fieldset> |
| 251 | + |
260 | 252 | <div class="actions flex"> |
261 | | - <%= form.submit @onboarding ? "Start using HCB" : "Save settings" %> |
| 253 | + <%= form.submit "Save settings", disabled: %> |
262 | 254 | </div> |
263 | 255 | <% end %> |
264 | 256 | <script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.13/js/intlTelInput.min.js" integrity="sha512-QMUqEPmhXq1f3DnAVdXvu40C8nbTgxvBGvNruP6RFacy3zWKbNTmx7rdQVVM2gkd2auCWhlPYtcW2tHwzso4SA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> |
|
0 commit comments