diff --git a/backend/app/models/event.rb b/backend/app/models/event.rb index 3f9b1c7a1..59cf31a70 100644 --- a/backend/app/models/event.rb +++ b/backend/app/models/event.rb @@ -14,6 +14,7 @@ class Event < ApplicationRecord revoke reminder reminder_before_archive + unarchive opinion_created opinion_comment_created @@ -24,7 +25,7 @@ class Event < ApplicationRecord belongs_to :entity, polymorphic: true, optional: true belongs_to :user, optional: true - validates :user, presence: true, if: proc { |event| %w[reminder reminder_before_archive archive].exclude?(event.name) } + validates :user, presence: true, if: proc { |event| %w[reminder reminder_before_archive archive unarchive].exclude?(event.name) } validates :name, presence: true, inclusion: {in: VALID_NAMES} diff --git a/backend/spec/factories/events.rb b/backend/spec/factories/events.rb index 9e35bff2d..3b786313d 100644 --- a/backend/spec/factories/events.rb +++ b/backend/spec/factories/events.rb @@ -64,6 +64,10 @@ name { "archive" } end + trait :unarchive do + name { "unarchive" } + end + trait :opinion_created do name { "opinion_created" } diff --git a/backend/spec/models/event_spec.rb b/backend/spec/models/event_spec.rb index 2bed38d8b..d57aff85d 100644 --- a/backend/spec/models/event_spec.rb +++ b/backend/spec/models/event_spec.rb @@ -15,6 +15,7 @@ archive opinion_created opinion_comment_created + unarchive ].each do |trait| expect(build(:event, trait)).to be_valid end @@ -181,6 +182,7 @@ reminder reminder_before_archive archive + unarchive ].each do |name| context "when name is '#{name}'" do let(:name) { name } @@ -239,6 +241,8 @@ %w[ reminder reminder_before_archive + archive + unarchive ].each do |name| context "when name '#{name}'" do let(:name) { name } diff --git a/frontend/src/components/organisms/form-sections/HeadSection/index.tsx b/frontend/src/components/organisms/form-sections/HeadSection/index.tsx index a111cd75b..9f04d6255 100644 --- a/frontend/src/components/organisms/form-sections/HeadSection/index.tsx +++ b/frontend/src/components/organisms/form-sections/HeadSection/index.tsx @@ -17,7 +17,7 @@ import { EnrollmentEvent, } from '../../../../config/event-configuration'; import { processEvent } from '../../../../lib/process-event'; -import { createOrUpdateEnrollment } from '../../../../services/enrollments'; +import Enrollment from '../../../templates/Enrollment'; export const HeadSection = () => { const { @@ -32,16 +32,18 @@ export const HeadSection = () => { const handleUnarchiveClick = async () => { const event = EnrollmentEvent.unarchive; const eventConfiguration = eventConfigurations[event]; + const enrollment = Enrollment; + const updateEnrollment = Function; try { - const result = await processEvent( + await processEvent( event, eventConfiguration, enrollment, updateEnrollment ); } catch (error) { - console.error('Errur lors du désarchivage:', error); + console.error('Erreur lors du désarchivage:', error); } };