Skip to content
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

feat: As a customer, I want to request OTP and use it to register an account on B2C Composable Storefront #19828

Merged
merged 19 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion feature-libs/user/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

$skipComponentStyles: () !default;
$selectors: cx-address-book, cx-address-form, cx-suggested-addresses-dialog,
cx-login, cx-login-form, cx-register, cx-reset-password, cx-close-account,
cx-login, cx-login-form, cx-register, cx-otp-register-form,
cx-registration-verification-token-form, cx-reset-password, cx-close-account,
cx-close-account-modal, cx-my-account-v2-profile, cx-my-account-v2-email,
cx-my-account-v2-password, cx-otp-login-form, cx-verification-token-form,
cx-verification-token-dialog !default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"wrongEmailFormat": "This is not a valid email format."
},
"verificationTokenForm": {
"createVerificationToken": "Verification code sent to {{target}}. Please check and enter the code.",
"createVerificationToken": "Verification code has been sent to {{target}}. Please enter the code.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not modify existing one, add a new one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refer to mockup

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what grace said is always use new entry when you want to update text.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UX inform me to modify this.

Copy link
Contributor

@scarai-sap scarai-sap Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UX does't know the detail of how to make code backward compatibility....

Any text change is not allowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok got it!

"needInputCredentials": "Please enter your credentials to continue.",
"sendRateLime": "in {{waitTime}} seconds",
"resend": "Resend",
Expand Down
2 changes: 1 addition & 1 deletion feature-libs/user/account/root/model/otp-login.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export interface VerificationTokenCreation {
purpose: string;
loginId: string;
password: string;
password?: string;
}

export interface VerificationToken {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function defaultUserAccountComponentsConfig(): CmsConfig {
'ReturningCustomerRegisterComponent',
'MyAccountViewUserComponent',
'ReturningCustomerOTPLoginComponent',
'RegisterCustomerWithOTPComponent',
],
},
// by default core is bundled together with components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"termsAndConditions": "Terms & Conditions",
"signIn": "I already have an account. Sign In",
"register": "Register",
"furtherRegistration": "Continue",
"confirmNewPassword": "Confirm New Password",
"resetPassword": "Reset Password",
"createAccount": "Create an account",
Expand Down Expand Up @@ -57,7 +58,17 @@
"bothPasswordMustMatch": "Both password must match",
"titleRequired": "Title is required.",
"postRegisterMessage": "Please log in with provided credentials.",
"postRegisterSuccessMessage": "Successful Registration: Please log in with provided credentials"
"postRegisterSuccessMessage": "Your account has been successfully created! Please log in with provided credentials",
"verificationTokenForm": {
"createVerificationToken": "Verification code has been sent to {{target}}. Please enter the code.",
"sendRateLime": "in {{waitTime}} seconds",
"resend": "Resend",
"verificationCode": {
"label": "Verification Code",
"placeholder": "Enter Verification Code"
},
"back": "Back"
}
},
"forgottenPassword": {
"resetPassword": "Reset password",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

export * from './otp-login-register.component';
export * from './otp-login-register.module';
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
<section
class="cx-page-section container"
*ngIf="!(isLoading$ | async); else loading"
>
<div
*cxFeature="'!a11yRemoveStatusLoadedRole'"
role="status"
[attr.aria-label]="'common.loaded' | cxTranslate"
></div>
<div class="row justify-content-center">
<div class="col-md-6">
<div class="cx-section">
<form (ngSubmit)="submitForm()" [formGroup]="registerForm">
<div class="form-group">
<label>
<span class="label-content">{{
'register.title' | cxTranslate
}}</span>
<ng-select
[clearable]="false"
[items]="titles$ | async"
[placeholder]="'register.selectTitle' | cxTranslate"
[searchable]="false"
bindLabel="name"
bindValue="code"
formControlName="titleCode"
id="title-select"
[cxNgSelectA11y]="{}"
>
</ng-select>
</label>
</div>

<div class="form-group">
<label>
<span class="label-content"
>{{ 'register.firstName.label' | cxTranslate }}
<ng-template [ngTemplateOutlet]="requiredAsterisk"></ng-template
></span>
<input
required="true"
class="form-control"
type="text"
name="firstname"
placeholder="{{
'register.firstName.placeholder' | cxTranslate
}}"
formControlName="firstName"
/>

<!-- TODO: (CXSPA-7315) Remove feature toggle in the next major -->
<cx-form-errors
*cxFeature="'formErrorsDescriptiveMessages'"
[translationParams]="{
label: 'register.firstName.label' | cxTranslate,
}"
[control]="registerForm.get('firstName')"
></cx-form-errors>

<cx-form-errors
*cxFeature="'!formErrorsDescriptiveMessages'"
[control]="registerForm.get('firstName')"
></cx-form-errors>
</label>
</div>

<div class="form-group">
<label>
<span class="label-content"
>{{ 'register.lastName.label' | cxTranslate }}
<ng-template [ngTemplateOutlet]="requiredAsterisk"></ng-template
></span>
<input
required="true"
class="form-control"
type="text"
name="lastname"
placeholder="{{
'register.lastName.placeholder' | cxTranslate
}}"
formControlName="lastName"
/>

<!-- TODO: (CXSPA-7315) Remove feature toggle in the next major -->
<cx-form-errors
*cxFeature="'formErrorsDescriptiveMessages'"
[translationParams]="{
label: 'register.lastName.label' | cxTranslate,
}"
[control]="registerForm.get('lastName')"
></cx-form-errors>

<cx-form-errors
*cxFeature="'!formErrorsDescriptiveMessages'"
[control]="registerForm.get('lastName')"
></cx-form-errors>
</label>
</div>

<div class="form-group">
<label>
<span class="label-content"
>{{ 'register.emailAddress.label' | cxTranslate }}
<ng-template [ngTemplateOutlet]="requiredAsterisk"></ng-template
></span>
<input
required="true"
class="form-control"
type="email"
name="email"
placeholder="{{
'register.emailAddress.placeholder' | cxTranslate
}}"
formControlName="email"
/>

<!-- TODO: (CXSPA-7315) Remove feature toggle in the next major -->
<cx-form-errors
*cxFeature="'formErrorsDescriptiveMessages'"
[translationParams]="{
label: 'register.emailAddress.label' | cxTranslate,
}"
[control]="registerForm.get('email')"
></cx-form-errors>

<cx-form-errors
*cxFeature="'!formErrorsDescriptiveMessages'"
[control]="registerForm.get('email')"
></cx-form-errors>
</label>
</div>

<div class="form-group">
<div class="form-check">
<label *ngIf="anonymousConsent$ | async as anonymousConsent">
<input
type="checkbox"
name="newsletter"
class="form-check-input"
formControlName="newsletter"
[checked]="isConsentGiven(anonymousConsent.consent)"
/>
<span class="form-check-label">
{{ anonymousConsent.template }}
</span>
</label>
</div>
</div>

<div
formArrayName="additionalConsents"
class="form-group"
*ngIf="additionalRegistrationConsents as consents"
>
<div
class="form-check"
*ngFor="let control of additionalConsents.controls; let i = index"
>
<div *ngIf="consents[i]?.template?.id as id">
<label>
<input
type="checkbox"
[required]="consents[i].required"
[name]="id"
(change)="updateAdditionalConsents($any($event), i)"
[formControlName]="i"
/>
<span class="form-check-label">
{{ consents[i].template.description }}
</span>
<cx-form-errors [control]="control"></cx-form-errors>
</label>
</div>
</div>
</div>

<div class="form-group">
<div class="form-check">
<label>
<input
required="true"
type="checkbox"
name="termsandconditions"
formControlName="termsandconditions"
/>
<span class="form-check-label">
{{ 'register.confirmThatRead' | cxTranslate }}
<a
[routerLink]="{ cxRoute: 'termsAndConditions' } | cxUrl"
target="_blank"
rel="noopener noreferrer"
>
{{ 'register.termsAndConditions' | cxTranslate }}
</a>
<ng-template
[ngTemplateOutlet]="requiredAsterisk"
></ng-template>
</span>

<!-- TODO: (CXSPA-7315) Remove feature toggle in the next major -->
<cx-form-errors
*cxFeature="'formErrorsDescriptiveMessages'"
[translationParams]="{
label: 'register.termsAndConditions' | cxTranslate,
}"
[control]="registerForm.get('termsandconditions')"
></cx-form-errors>

<cx-form-errors
*cxFeature="'!formErrorsDescriptiveMessages'"
[control]="registerForm.get('termsandconditions')"
></cx-form-errors>
</label>
</div>
</div>
<cx-captcha (confirmed)="captchaConfirmed()"></cx-captcha>
<cx-form-errors
[control]="registerForm.get('captcha')"
></cx-form-errors>
<button type="submit" class="btn btn-block btn-primary">
{{ 'register.furtherRegistration' | cxTranslate }}
</button>
<a
class="cx-login-link btn-link"
[routerLink]="{ cxRoute: 'login' } | cxUrl"
>{{ 'register.signIn' | cxTranslate }}</a
>
</form>
</div>
</div>
</div>
</section>

<ng-template #requiredAsterisk>
<abbr
*cxFeature="'a11yRequiredAsterisks'"
aria-hidden="true"
class="text-decoration-none required-asterisk"
title="{{ 'common.required' | cxTranslate }}"
>*</abbr
>
</ng-template>

<ng-template #loading>
<div class="cx-spinner"><cx-spinner></cx-spinner></div>
</ng-template>
Loading
Loading