From bdd7c6e75438b0902b1389b183de12a9b95c03be Mon Sep 17 00:00:00 2001 From: joelmeaders Date: Mon, 9 Dec 2024 19:04:25 -0500 Subject: [PATCH] feat(app): Functionality to disable new account creation visually (#122) --- .../app/core/services/app-state.service.ts | 5 ++++ .../app/features/v2/sign-in/sign-in.page.html | 2 ++ .../app/features/v2/sign-in/sign-in.page.ts | 25 ++++++++----------- .../app/features/v2/sign-up/sign-up.page.html | 10 ++++++++ .../app/features/v2/sign-up/sign-up.page.ts | 3 +++ santashop-app/src/app/home/home.page.html | 8 ++++++ santashop-app/src/app/home/home.page.ts | 13 +++++++++- santashop-app/src/assets/i18n/en.json | 1 + santashop-app/src/assets/i18n/es.json | 1 + santashop-app/src/global.scss | 13 ++++++++++ santashop-models/src/lib/parameters.ts | 1 + 11 files changed, 66 insertions(+), 16 deletions(-) diff --git a/santashop-app/src/app/core/services/app-state.service.ts b/santashop-app/src/app/core/services/app-state.service.ts index 368bf67b..619300ab 100644 --- a/santashop-app/src/app/core/services/app-state.service.ts +++ b/santashop-app/src/app/core/services/app-state.service.ts @@ -79,6 +79,11 @@ export class AppStateService implements OnDestroy { takeUntil(this.destroy$), ); + public readonly createAccountEnabled$ = this.publicDoc$.pipe( + map((value) => value.createAccountEnabled), + takeUntil(this.destroy$), + ); + public readonly appClosureSubscription = combineLatest([ this.isMaintenanceModeEnabled$, this.shopClosedWeather$, diff --git a/santashop-app/src/app/features/v2/sign-in/sign-in.page.html b/santashop-app/src/app/features/v2/sign-in/sign-in.page.html index 8e782b65..381cffc9 100644 --- a/santashop-app/src/app/features/v2/sign-in/sign-in.page.html +++ b/santashop-app/src/app/features/v2/sign-in/sign-in.page.html @@ -69,6 +69,7 @@
+ @if ((createAccountEnabled$ | async) === true) {
+ } + @if ((createAccountEnabled$ | async) === true) { @@ -238,5 +239,14 @@ + } @else { + + +
+

{{ "SIGNUP.CREATE_ACCOUNT_DISABLED" | translate }}

+
+
+
+ }
diff --git a/santashop-app/src/app/features/v2/sign-up/sign-up.page.ts b/santashop-app/src/app/features/v2/sign-up/sign-up.page.ts index 713c3a6e..130a1294 100644 --- a/santashop-app/src/app/features/v2/sign-up/sign-up.page.ts +++ b/santashop-app/src/app/features/v2/sign-up/sign-up.page.ts @@ -78,6 +78,9 @@ export class SignUpPage { @ViewChild('firstName') private readonly firstName?: HTMLIonInputElement; + public readonly createAccountEnabled$ = + this.appStateService.createAccountEnabled$; + protected readonly closedSubscription = this.appStateService.isRegistrationEnabled$ .pipe( diff --git a/santashop-app/src/app/home/home.page.html b/santashop-app/src/app/home/home.page.html index a7266c8d..ab33fde6 100644 --- a/santashop-app/src/app/home/home.page.html +++ b/santashop-app/src/app/home/home.page.html @@ -24,6 +24,7 @@

+ @if (createAccountEnabled$ | async) {

{{ "SIGNUP.NEW_ACCOUNT_NOTICE" | translate }}

{{ "HOME.CREATE_ACCOUNT" | translate }}
+ } @else { + +
+

{{ "SIGNUP.CREATE_ACCOUNT_DISABLED" | translate }}

+
+
+ }

{{ "HOME.SIGN_IN_INST" | translate }}

diff --git a/santashop-app/src/app/home/home.page.ts b/santashop-app/src/app/home/home.page.ts index 00103451..f75b1637 100644 --- a/santashop-app/src/app/home/home.page.ts +++ b/santashop-app/src/app/home/home.page.ts @@ -1,4 +1,9 @@ -import { ChangeDetectionStrategy, Component, OnDestroy } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + inject, + OnDestroy, +} from '@angular/core'; import { Subject } from 'rxjs'; import { environment } from '../../environments/environment'; @@ -16,6 +21,8 @@ import { } from '@ionic/angular/standalone'; import { addIcons } from 'ionicons'; import { logoFacebook, logoInstagram } from 'ionicons/icons'; +import { AppStateService } from '../core'; +import { AsyncPipe } from '@angular/common'; @Component({ selector: 'app-home', @@ -24,6 +31,7 @@ import { logoFacebook, logoInstagram } from 'ionicons/icons'; changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [ + AsyncPipe, IonContent, IonGrid, IonRow, @@ -44,11 +52,14 @@ import { logoFacebook, logoInstagram } from 'ionicons/icons'; ], }) export class HomePage implements OnDestroy { + private readonly appState = inject(AppStateService); private readonly destroy$ = new Subject(); public readonly environmentName = `${environment.name}_${environment.label}`; public readonly environmentVersion = environment.version; + public readonly createAccountEnabled$ = this.appState.createAccountEnabled$; + constructor() { addIcons({ logoFacebook, logoInstagram }); } diff --git a/santashop-app/src/assets/i18n/en.json b/santashop-app/src/assets/i18n/en.json index da5a2d16..65a9f0b3 100644 --- a/santashop-app/src/assets/i18n/en.json +++ b/santashop-app/src/assets/i18n/en.json @@ -50,6 +50,7 @@ "SIGNING_IN": "Signing in..." }, "SIGNUP": { + "CREATE_ACCOUNT_DISABLED": "We're full and cannot accept any more sign-ups right now. Please check our Facebook page for updates if any spots open up.", "NEW_ACCOUNT_NOTICE": "All shoppers must create a new account for 2024, even if you have shopped with us in the past.", "HAVE_ACCOUNT": "Already have an account?", "TITLE1": "Set up your account", diff --git a/santashop-app/src/assets/i18n/es.json b/santashop-app/src/assets/i18n/es.json index 70861fb0..d46882d9 100644 --- a/santashop-app/src/assets/i18n/es.json +++ b/santashop-app/src/assets/i18n/es.json @@ -50,6 +50,7 @@ "SIGNING_IN": "Iniciar sesión..." }, "SIGNUP": { + "CREATE_ACCOUNT_DISABLED": "Estamos llenos y no podemos aceptar más inscripciones en este momento. Consulte nuestra página de Facebook para obtener actualizaciones si se abren lugares.", "NEW_ACCOUNT_NOTICE": "Todos los compradores deben crear una nueva cuenta para 2024, incluso si han comprado con nosotros en el pasado.", "HAVE_ACCOUNT": "¿Ya tienes una cuenta?", "TITLE1": "Configura tu cuenta", diff --git a/santashop-app/src/global.scss b/santashop-app/src/global.scss index 62d5d910..6e7134c5 100644 --- a/santashop-app/src/global.scss +++ b/santashop-app/src/global.scss @@ -260,3 +260,16 @@ $es-direction-definitions: (top, bottom, right, left) !default; box-shadow: rgb(255, 172, 94) 0px 20px 30px -10px; } } + +.alert { + border-radius: 12px; + padding-inline: 16px; + padding-block: 12px; + width: auto; + max-width: 600px; + justify-self: center; + background-color: rgba(var(--ion-color-warning-rgb), 0.25); + border-color: var(--ion-color-warning); + border-width: 1px; + border-style: solid; +} diff --git a/santashop-models/src/lib/parameters.ts b/santashop-models/src/lib/parameters.ts index 4db36fcc..cf483fcb 100644 --- a/santashop-models/src/lib/parameters.ts +++ b/santashop-models/src/lib/parameters.ts @@ -4,6 +4,7 @@ export interface PublicParameters { registrationEnabled: boolean; maintenanceModeEnabled: boolean; weatherModeEnabled: boolean; + createAccountEnabled: boolean; messageEn: string; messageEs: string; admin: {