diff --git a/app/controllers/api/children_controller.rb b/app/controllers/api/children_controller.rb index 44188807e..3725695ba 100644 --- a/app/controllers/api/children_controller.rb +++ b/app/controllers/api/children_controller.rb @@ -30,7 +30,7 @@ class API::ChildrenController < API::APIController def update authorize @child - if @child.update(child_params) + if ChildService.update(@child, child_params) render status: :ok else render json: @child.errors.full_messages, status: :unprocessable_entity diff --git a/app/frontend/src/javascript/components/family-account/child-form.tsx b/app/frontend/src/javascript/components/family-account/child-form.tsx index f9e9b4a53..1d6ebdf2e 100644 --- a/app/frontend/src/javascript/components/family-account/child-form.tsx +++ b/app/frontend/src/javascript/components/family-account/child-form.tsx @@ -116,7 +116,7 @@ export const ChildForm: React.FC = ({ child, onSubmit, supportin defaultFile={sf as FileType} id={`supporting_document_files_attributes.${index}`} accept="application/pdf" - rules={{ required: true }} + rules={{ required: !sf.attachment }} setValue={setValue} label={getSupportingDocumentsTypeName(sf.supporting_document_type_id)} showRemoveButton={false} diff --git a/app/services/child_service.rb b/app/services/child_service.rb index 45ebd1a4c..812374976 100644 --- a/app/services/child_service.rb +++ b/app/services/child_service.rb @@ -28,7 +28,9 @@ class ChildService all_files_are_upload = true SupportingDocumentType.where(document_type: 'Child').each do |sdt| file = sdt.supporting_document_files.find_by(supportable: child) - all_files_are_upload = false if file.nil? || file.attachment_identifier.nil? + if file.nil? || file.attachment_identifier.nil? || child_params['supporting_document_files_attributes']['0']['attachment'].blank? + all_files_are_upload = false + end end if all_files_are_upload NotificationCenter.call type: 'notify_admin_user_child_supporting_document_files_updated',