-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Utiliser PixCode dans la vérification des certificats sur Pix App (PIX-16429). #11343
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import PixBackgroundHeader from '@1024pix/pix-ui/components/pix-background-header'; | ||
import PixBlock from '@1024pix/pix-ui/components/pix-block'; | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import PixCode from '@1024pix/pix-ui/components/pix-code'; | ||
import PixNotificationAlert from '@1024pix/pix-ui/components/pix-notification-alert'; | ||
import { on } from '@ember/modifier'; | ||
import { action } from '@ember/object'; | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { t } from 'ember-intl'; | ||
|
||
export default class CertificationVerificationCodeForm extends Component { | ||
@service intl; | ||
|
||
@tracked certificateVerificationCode = null; | ||
@tracked errorMessage = null; | ||
@tracked status = 'default'; | ||
|
||
codeRegex = /^P-[0-9A-Z]{8}$/i; | ||
|
||
@action | ||
handleVerificationCodeInput(event) { | ||
this.certificateVerificationCode = event.target.value; | ||
} | ||
|
||
@action | ||
clearErrors() { | ||
this.errorMessage = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion lorsque le champ a le focus et qu'on valide avec "entrée" le message d'erreur apparait brievement et disparait. on pourrait rajouter un check sur le There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. au alors rajouter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oups, je viens de vérifier, le problème était la avant |
||
this.status = 'default'; | ||
this.args.clearErrors(); | ||
} | ||
|
||
get isVerificationCodeValid() { | ||
return this.codeRegex.test(this.certificateVerificationCode); | ||
} | ||
|
||
@action | ||
async checkCertificate(event) { | ||
event.preventDefault(); | ||
this.clearErrors(); | ||
|
||
if (!this.certificateVerificationCode) { | ||
this.errorMessage = this.intl.t('pages.fill-in-certificate-verification-code.errors.missing-code'); | ||
this.status = 'error'; | ||
return; | ||
} | ||
|
||
if (!this.isVerificationCodeValid) { | ||
this.errorMessage = this.intl.t('pages.fill-in-certificate-verification-code.errors.wrong-format'); | ||
this.status = 'error'; | ||
return; | ||
} | ||
|
||
this.args.checkCertificate(this.certificateVerificationCode); | ||
} | ||
|
||
<template> | ||
<PixBackgroundHeader id="main"> | ||
<PixBlock class="fill-in-certificate-verification-code"> | ||
<h1 class="fill-in-certificate-verification-code__title"> | ||
{{t "pages.fill-in-certificate-verification-code.first-title"}} | ||
</h1> | ||
|
||
<p class="fill-in-certificate-verification-code__description"> | ||
{{t "pages.fill-in-certificate-verification-code.description"}} | ||
</p> | ||
|
||
<form class="fill-in-certificate-verification-code__form" autocomplete="off"> | ||
<PixCode | ||
@length="10" | ||
@requiredLabel={{t "common.forms.mandatory"}} | ||
@subLabel={{t "pages.fill-in-certificate-verification-code.sub-label"}} | ||
@value={{this.certificateVerificationCode}} | ||
@validationStatus={{this.status}} | ||
@errorMessage={{this.errorMessage}} | ||
{{on "keyup" this.clearErrors}} | ||
{{on "input" this.handleVerificationCodeInput}} | ||
> | ||
<:label>{{t "pages.fill-in-certificate-verification-code.label"}}</:label> | ||
</PixCode> | ||
|
||
<PixButton @type="submit" @triggerAction={{this.checkCertificate}} class="form__actions"> | ||
{{t "pages.fill-in-certificate-verification-code.verify"}} | ||
</PixButton> | ||
|
||
{{#if @apiErrorMessage}} | ||
AndreiaPena marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<PixNotificationAlert @type="error" @withIcon={{true}}> | ||
{{@apiErrorMessage}} | ||
</PixNotificationAlert> | ||
{{/if}} | ||
</form> | ||
</PixBlock> | ||
</PixBackgroundHeader> | ||
</template> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A gérer coté PixUI : le liseré rouge en cas d'erreur n'apparaît pas.