Skip to content

Commit

Permalink
Update family and individual request validation to match create [#4579]
Browse files Browse the repository at this point in the history
  • Loading branch information
awwaiid committed Jan 5, 2025
1 parent 9c7bf05 commit a622b15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/controllers/partners/family_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ def create
def validate
family_requests_attributes = build_family_requests_attributes(params)

@partner_request = Partners::FamilyRequestCreateService.new(
create_service = Partners::FamilyRequestCreateService.new(
partner_user_id: current_user.id,
family_requests_attributes: family_requests_attributes,
request_type: "child"
).initialize_only
if @partner_request.valid?
if create_service.errors.none?
@partner_request = create_service.partner_request
@total_items = @partner_request.total_items
@quota_exceeded = current_partner.quota_exceeded?(@total_items)
body = render_to_string(template: 'partners/requests/validate', formats: [:html], layout: false)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/partners/individuals_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ def create
end

def validate
@partner_request = Partners::FamilyRequestCreateService.new(
create_service = Partners::FamilyRequestCreateService.new(
partner_user_id: current_user.id,
comments: individuals_request_params[:comments],
family_requests_attributes: individuals_request_params[:items_attributes]&.values,
request_type: "individual"
).initialize_only
if @partner_request.valid?
if create_service.errors.none?
@partner_request = create_service.partner_request
@total_items = @partner_request.total_items
@quota_exceeded = current_partner.quota_exceeded?(@total_items)
body = render_to_string(template: 'partners/requests/validate', formats: [:html], layout: false)
Expand Down

0 comments on commit a622b15

Please sign in to comment.