mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-17 11:54:22 +01:00
(bug) child cannot be updated
This commit is contained in:
parent
8a3110cd0f
commit
ea83265b87
@ -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
|
||||
|
@ -116,7 +116,7 @@ export const ChildForm: React.FC<ChildFormProps> = ({ 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}
|
||||
|
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user