Skip to content

Commit

Permalink
Reste à faire
Browse files Browse the repository at this point in the history
  • Loading branch information
P-Jeremy committed Jul 3, 2024
1 parent 99ecc0c commit 3bfeebe
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 18 deletions.
4 changes: 2 additions & 2 deletions mon-pix/app/adapters/certification-candidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export default class CertificationCandidate extends ApplicationAdapter {
urlForUpdateRecord(id, modelName, { adapterOptions }) {
const url = super.urlForUpdateRecord(...arguments);

if (adapterOptions && adapterOptions.userHasSeenCertificationInstructions) {
delete adapterOptions.userHasSeenCertificationInstructions;
if (adapterOptions && adapterOptions.hasSeenCertificationInstructions) {
delete adapterOptions.hasSeenCertificationInstructions;
return `${url}/validate-certification-instructions`;
}

Expand Down
19 changes: 13 additions & 6 deletions mon-pix/app/components/certification-instructions/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,27 @@ export default class Steps extends Component {
}

@action
nextStep() {
async nextStep() {
if (this.pageId < this.pageCount) {
this.pageId = this.pageId + 1;
}

if (this.isConfirmationCheckboxChecked) {
this.router.transitionTo('authenticated.certifications.start', this.args.candidateId, {
queryParams: {
isConfirmationCheckboxChecked: this.isConfirmationCheckboxChecked,
},
});
await this.submit();

this.router.transitionTo('authenticated.certifications.start', this.args.candidate.id);
}
}

@action
async submit() {
await this.args.candidate.save({
adapterOptions: {
hasSeenCertificationInstructions: true,
},
});
}

@action
enableNextButton(checked) {
this.isConfirmationCheckboxChecked = checked;
Expand Down
1 change: 1 addition & 0 deletions mon-pix/app/models/certification-candidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default class CertificationCandidate extends Model {
@attr('string') firstName;
@attr('string') lastName;
@attr('date-only') birthdate;
@attr('boolean') hasSeenCertificationInstructions;

// references
@attr('number') sessionId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ import { service } from '@ember/service';

export default class InformationRoute extends Route {
@service store;
@service router;

async model(params) {
return this.store.peekRecord('certification-candidate', params.certification_candidate_id);
const certificationCandidate = this.store.peekRecord('certification-candidate', params.certification_candidate_id);

if (!certificationCandidate) {
this.router.replaceWith('authenticated.certifications.join');
}

return certificationCandidate;
}
}
15 changes: 9 additions & 6 deletions mon-pix/app/routes/authenticated/certifications/start.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import Route from '@ember/routing/route';
import { service } from '@ember/service';
import isUndefined from 'lodash/isUndefined';

export default class StartRoute extends Route {
@service store;
@service router;
@service featureToggles;
hasSeenCertificationInstructions = false;

beforeModel(transition) {
this.hasSeenCertificationInstructions = transition.to.queryParams.isConfirmationCheckboxChecked;
}

async model(params) {
const certificationCandidateSubscription = await this.store.findRecord(
'certification-candidate-subscription',
params.certification_candidate_id,
);

const certificationCandidate = await this.store.peekRecord(
'certification-candidate',
params.certification_candidate_id,
);

const hasSeenCertificationInstructions = !isUndefined(certificationCandidate?.hasSeenCertificationInstructions);

if (
!this.hasSeenCertificationInstructions &&
!hasSeenCertificationInstructions &&
certificationCandidateSubscription.isSessionVersion3 &&
this.featureToggles.featureToggles.areV3InfoScreensEnabled
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<h1 class="instructions-header__title">{{t "pages.certification-instructions.title"}}</h1>
</header>
<PixBlock @shadow="heavy" class="instructions-step">
<CertificationInstructions::Steps @candidateId={{this.model.id}} />
<CertificationInstructions::Steps @candidate={{this.model}} />
</PixBlock>
</main>
4 changes: 2 additions & 2 deletions mon-pix/tests/unit/adapters/certification-candidate_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ module('Unit | Adapters | certification-candidate', function (hooks) {
});

module('#urlForUpdateRecord', function () {
module('when userHasSeenCertificationInstructions option is true', function () {
module('when hasSeenCertificationInstructions option is true', function () {
test('should redirect to session/id/certification-candidate/participation', async function (assert) {
// when
const options = { adapterOptions: { userHasSeenCertificationInstructions: true } };
const options = { adapterOptions: { hasSeenCertificationInstructions: true } };
const url = await adapter.urlForUpdateRecord(456, 'certification-candidate', options);

// then
Expand Down

0 comments on commit 3bfeebe

Please sign in to comment.