Skip to content

Commit ee62a75

Browse files
committed
continue notif pref screen
1 parent 6b30df1 commit ee62a75

File tree

5 files changed

+39
-13
lines changed

5 files changed

+39
-13
lines changed

app/controllers/diy/base_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ module Diy
22
class BaseController < ApplicationController
33
before_action :redirect_in_offseason
44

5-
helper_method :current_path #, :illustration_folder, :illustration_path, :next_path, :prev_path, :has_unsure_option?, :method_name, :form_name
5+
def current_diy_intake
6+
if session[:diy_intake_id]
7+
DiyIntake.find(session[:diy_intake_id])
8+
else
9+
DiyIntake.new(preferred_first_name: "temp")
10+
end
11+
end
612

713
private
814

app/controllers/diy/diy_notification_preference_controller.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
module Diy
22
class DiyNotificationPreferenceController < BaseController
3+
def edit
4+
@form = DiyNotificationPreferenceForm.new
5+
end
6+
7+
def update
8+
diy_intake = current_diy_intake
9+
@form = DiyNotificationPreferenceForm.new(diy_intake)
10+
if @form.valid?
11+
@form.save
12+
session[:diy_intake_id] = diy_intake.id
13+
redirect_to(diy_continue_to_fsa_path)
14+
else
15+
render :edit
16+
end
17+
end
18+
319
private
420

521
def tracking_data
6-
# @form.attributes_for(:intake).reject { |k, _| k == :sms_phone_number }
22+
@form.attributes_for(:diy_intake)
723
end
824

925
def illustration_path

app/controllers/diy/file_yourself_controller.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def update
1010
if @form.valid?
1111
@form.save
1212
session[:diy_intake_id] = diy_intake.id
13-
#redirect_to(diy_continue_to_fsa_path)
1413
redirect_to(diy_diy_notification_preference_path)
1514
else
1615
render :edit
@@ -19,14 +18,6 @@ def update
1918

2019
private
2120

22-
def current_diy_intake
23-
if session[:diy_intake_id]
24-
DiyIntake.find(session[:diy_intake_id])
25-
else
26-
DiyIntake.new(preferred_first_name: "temp")
27-
end
28-
end
29-
3021
def create_params
3122
form_params = params.fetch(:file_yourself_form, {}).permit(*FileYourselfForm.attribute_names)
3223
if DiyIntake.should_carry_over_params_from?(current_intake)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
class DiyNotificationPreferenceForm < Form
2+
include FormAttributes
3+
attr_accessor :diy_intake
24
set_attributes_for :diy_intake, :sms_notification_opt_in, :email_notification_opt_in
35

6+
def initialize(diy_intake = nil, params = {})
7+
@diy_intake = diy_intake
8+
super(params)
9+
end
10+
411
def save
512
diy_intake.update(attributes_for(:diy_intake))
613
end
714

815
def self.existing_attributes(diy_intake)
916
HashWithIndifferentAccess.new(diy_intake.attributes)
1017
end
18+
end

app/views/diy/diy_notification_preference/edit.html.erb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<% content_for :page_title, t("views.questions.notification_preference.title") %>
22

3-
<% content_for :card do %>
3+
<section class="slab slab--white question-layout">
4+
<div class="grid">
5+
<div class="grid__item question-wrapper">
6+
<div class="main-content-inner">
7+
<%= image_tag("questions/contact-preference.svg", alt: "") %>
8+
49
<%= form_with model: @form, url: diy_diy_notification_preference_path, local: true, method: "put", builder: VitaMinFormBuilder, html: { class: "form-card" } do |f| %>
510
<h1 class="h2"><%= content_for(:page_title) %></h1>
611

@@ -30,5 +35,5 @@
3035
</div>
3136

3237
<%= f.continue %>
33-
<% end %>
3438
<% end %>
39+
</div></div></div></section>

0 commit comments

Comments
 (0)