Skip to content

Commit

Permalink
🚧 (mon-pix): wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiaPena committed Jul 3, 2024
1 parent c31f59e commit f75dd8c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
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;
}
}
13 changes: 7 additions & 6 deletions mon-pix/app/routes/authenticated/certifications/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ 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 = 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>

0 comments on commit f75dd8c

Please sign in to comment.