demarches-normaliennes/app/graphql/mutations/dossier_repasser_en_construction.rb
2024-08-22 09:26:48 +02:00

29 lines
1.1 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# frozen_string_literal: true
module Mutations
class DossierRepasserEnConstruction < Mutations::BaseMutation
include DossierHelper
description "Re-passer le dossier en construction."
argument :dossier_id, ID, "Dossier ID", required: true, loads: Types::DossierType
argument :instructeur_id, ID, "Instructeur qui prend la décision sur le dossier.", required: true, loads: Types::ProfileType
argument :disable_notification, Boolean, "Désactiver lenvoi de lemail de notification après lopération", required: false, default_value: false
field :dossier, Types::DossierType, null: true
field :errors, [Types::ValidationErrorType], null: true
def resolve(dossier:, instructeur:, disable_notification:)
dossier.repasser_en_construction!(instructeur:, disable_notification:)
{ dossier: }
end
def authorized?(dossier:, instructeur:, **args)
if !dossier.en_instruction?
return false, { errors: ["Le dossier est déjà #{dossier_display_state(dossier, lower: true)}"] }
end
dossier_authorized_for?(dossier, instructeur)
end
end
end