Skip to content

Commit

Permalink
[BUGFIX] Aficher les catégories de profiles cibles lors de la duplica…
Browse files Browse the repository at this point in the history
…tion d'une campagne (PIX-13265)

 #9484
  • Loading branch information
pix-service-auto-merge authored Jul 10, 2024
2 parents 0552ac7 + 73ec7b0 commit 766dbb4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
12 changes: 2 additions & 10 deletions orga/app/components/campaign/create-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ export default class CreateForm extends Component {
@service intl;

@tracked wantIdPix = Boolean(this.args.campaign.idPixLabel);
@tracked targetProfiles = [];

constructor() {
super(...arguments);
Promise.resolve(this.args.targetProfiles).then((targetProfiles) => {
this.targetProfiles = targetProfiles;
});
}

get isMultipleSendingAssessmentEnabled() {
return this.currentUser.prescriber.enableMultipleSendingAssessment;
Expand All @@ -27,7 +19,7 @@ export default class CreateForm extends Component {
}

get targetOwnerOptions() {
const options = this.targetProfiles.map((targetProfile) => {
const options = this.args.targetProfiles.map((targetProfile) => {
return {
value: targetProfile.id,
label: targetProfile.name,
Expand Down Expand Up @@ -94,7 +86,7 @@ export default class CreateForm extends Component {

@action
selectTargetProfile(targetProfileId) {
this.args.campaign.targetProfile = this.targetProfiles.find(
this.args.campaign.targetProfile = this.args.targetProfiles.find(
(targetProfile) => targetProfile.id === targetProfileId,
);
}
Expand Down
5 changes: 3 additions & 2 deletions orga/app/routes/authenticated/campaigns/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Route from '@ember/routing/route';
import { service } from '@ember/service';
import pick from 'lodash/pick';
import RSVP from 'rsvp';

export default class NewRoute extends Route {
@service currentUser;
Expand Down Expand Up @@ -45,15 +46,15 @@ export default class NewRoute extends Route {
}
}

return {
return RSVP.hash({
campaign: this.store.createRecord('campaign', {
organization,
ownerId: this.currentUser.prescriber.id,
...(campaignAttributes ?? campaignAttributes),
}),
targetProfiles: organization.targetProfiles,
membersSortedByFullName,
};
});
}

resetController(controller, isExiting) {
Expand Down
2 changes: 2 additions & 0 deletions orga/tests/unit/routes/authenticated/campaigns/new_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ module('Unit | Route | authenticated/campaigns/new', function (hooks) {

const organization = EmberObject.create({
id: 12345,
targetProfiles: new Promise((resolve) => resolve([])),
});

class CurrentUserStub extends Service {
Expand Down Expand Up @@ -142,6 +143,7 @@ module('Unit | Route | authenticated/campaigns/new', function (hooks) {

assert.strictEqual(await model.campaign, duplicatedCampaignRecord);
sinon.assert.calledWithExactly(createRecordStub, 'campaign', expectedCampaignAttributes);
assert.false(model.targetProfiles instanceof Promise);
});
});

Expand Down

0 comments on commit 766dbb4

Please sign in to comment.