@tech4good/angular-schematics 21.5.0 → 21.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +266 -1
- package/package.json +34 -7
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +4 -5
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +1 -1
- package/src/entity/files/__name@dasherize__/__name@dasherize__.mock.ts.template +16 -7
- package/src/entity/files/__name@dasherize__/__name@dasherize__.model.ts.template +13 -6
- package/src/entity/files/__name@dasherize__/__name@dasherize__.store.ts.template +18 -10
- package/src/entity/index.js +61 -49
- package/src/entity/index.js.map +1 -1
- package/src/entity/schema.json +4 -0
- package/src/guard/files/__name@dasherize__.guard.spec.ts.template +0 -1
- package/src/ng-add/files/.github/workflows/angular-github-ci.yml.template +3 -0
- package/src/ng-add/files/.gitignore.template +5 -0
- package/src/ng-add/files/analytics/datasets.js.template +206 -0
- package/src/ng-add/files/analytics/entity_sources.js.template +58 -0
- package/src/ng-add/files/analytics/entity_sources.test.js.template +57 -0
- package/src/ng-add/files/analytics/lib/api_query.js.template +87 -0
- package/src/ng-add/files/analytics/lib/api_query.test.js.template +84 -0
- package/src/ng-add/files/analytics/lib/bigquery_query_compatibility.test.js.template +53 -0
- package/src/ng-add/files/analytics/lib/dataset_schema.js.template +53 -0
- package/src/ng-add/files/analytics/lib/dataset_schema.test.js.template +34 -0
- package/src/ng-add/files/analytics/lib/entity_sync.js.template +397 -0
- package/src/ng-add/files/analytics/lib/entity_sync.test.js.template +212 -0
- package/src/ng-add/files/analytics/lib/identifier_salt.js.template +57 -0
- package/src/ng-add/files/analytics/lib/identifier_salt.test.js.template +36 -0
- package/src/ng-add/files/analytics/lib/snapshot_files.js.template +46 -0
- package/src/ng-add/files/analytics/lib/snapshot_files.test.js.template +67 -0
- package/src/ng-add/files/analytics/lib/sqlite.js.template +92 -0
- package/src/ng-add/files/analytics/lib/upload_entities.js.template +81 -0
- package/src/ng-add/files/analytics/lib/upload_entities.test.js.template +86 -0
- package/src/ng-add/files/analytics/proxy.conf.json.template +7 -0
- package/src/ng-add/files/analytics/scripts/refresh_snapshot.js.template +518 -0
- package/src/ng-add/files/analytics/scripts/start.js.template +88 -0
- package/src/ng-add/files/analytics/server/server.js.template +212 -0
- package/src/ng-add/files/angular.json.template +80 -1
- package/src/ng-add/files/bigquery/queries/active_time_by_route.sql.template +27 -8
- package/src/ng-add/files/bigquery/queries/active_user_windows.sql.template +67 -0
- package/src/ng-add/files/bigquery/queries/dashboard_route_visits.sql.template +47 -0
- package/src/ng-add/files/bigquery/queries/data_quality.sql.template +323 -0
- package/src/ng-add/files/bigquery/queries/onboarding_funnel.sql.template +512 -0
- package/src/ng-add/files/bigquery/queries/onboarding_stage_observations.sql.template +134 -0
- package/src/ng-add/files/bigquery/queries/weekly_retention_cohorts.sql.template +90 -0
- package/src/ng-add/files/bigquery/scripts/export_entities.js.template +120 -0
- package/src/ng-add/files/bigquery/scripts/init_views.js.template +57 -0
- package/src/ng-add/files/bigquery/scripts/run_query.js.template +141 -0
- package/src/ng-add/files/bigquery/views/events_flat.sql.template +27 -12
- package/src/ng-add/files/bigquery/views/logs_latest.sql.template +16 -3
- package/src/ng-add/files/docs-infra/analytics-guide.md.template +270 -25
- package/src/ng-add/files/docs-infra/analytics-workbench-guide.md.template +307 -0
- package/src/ng-add/files/docs-infra/authentication-architecture.md.template +300 -0
- package/src/ng-add/files/docs-infra/email-infrastructure.md.template +43 -0
- package/src/ng-add/files/docs-infra/firestore-index-checker.md.template +87 -0
- package/src/ng-add/files/docs-infra/infrastructure-guide.md.template +123 -38
- package/src/ng-add/files/docs-infra/load-system-architecture.md.template +15 -1
- package/src/ng-add/files/docs-infra/querying-strategy.md.template +14 -0
- package/src/ng-add/files/docs-infra/stream-system-architecture.md.template +21 -7
- package/src/ng-add/files/eslint.config.js.template +22 -3
- package/src/ng-add/files/firebase.json.template +6 -0
- package/src/ng-add/files/firestore.indexes.json.template +23 -0
- package/src/ng-add/files/firestore.rules.spec.ts.template +84 -15
- package/src/ng-add/files/firestore.rules.template +29 -17
- package/src/ng-add/files/functions/.gitignore.template +3 -0
- package/src/ng-add/files/functions/package.json.template +13 -0
- package/src/ng-add/files/functions/src/email.ts.template +23 -0
- package/src/ng-add/files/functions/src/index.ts.template +44 -0
- package/src/ng-add/files/functions/tsconfig.json.template +13 -0
- package/src/ng-add/files/jest.config.ts.template +3 -2
- package/src/ng-add/files/package.json.template +41 -16
- package/src/ng-add/files/projects/analytics/src/app/analytics-api.service.ts.template +130 -0
- package/src/ng-add/files/projects/analytics/src/app/app.component.html.template +77 -0
- package/src/ng-add/files/projects/analytics/src/app/app.component.scss.template +240 -0
- package/src/ng-add/files/projects/analytics/src/app/app.component.ts.template +96 -0
- package/src/ng-add/files/projects/analytics/src/app/app.routes.ts.template +11 -0
- package/src/ng-add/files/projects/analytics/src/app/dashboard-pages.spec.ts.template +151 -0
- package/src/ng-add/files/projects/analytics/src/app/data-quality/data-quality-page/data-quality-page.component.html.template +39 -0
- package/src/ng-add/files/projects/analytics/src/app/data-quality/data-quality-page/data-quality-page.component.scss.template +1 -0
- package/src/ng-add/files/projects/analytics/src/app/data-quality/data-quality-page/data-quality-page.component.ts.template +95 -0
- package/src/ng-add/files/projects/analytics/src/app/engagement/engagement-page/engagement-page.component.html.template +47 -0
- package/src/ng-add/files/projects/analytics/src/app/engagement/engagement-page/engagement-page.component.scss.template +1 -0
- package/src/ng-add/files/projects/analytics/src/app/engagement/engagement-page/engagement-page.component.ts.template +120 -0
- package/src/ng-add/files/projects/analytics/src/app/onboarding/onboarding-page/onboarding-page.component.html.template +40 -0
- package/src/ng-add/files/projects/analytics/src/app/onboarding/onboarding-page/onboarding-page.component.scss.template +1 -0
- package/src/ng-add/files/projects/analytics/src/app/onboarding/onboarding-page/onboarding-page.component.ts.template +98 -0
- package/src/ng-add/files/projects/analytics/src/app/overview/overview-page/overview-page.component.html.template +35 -0
- package/src/ng-add/files/projects/analytics/src/app/overview/overview-page/overview-page.component.scss.template +1 -0
- package/src/ng-add/files/projects/analytics/src/app/overview/overview-page/overview-page.component.ts.template +84 -0
- package/src/ng-add/files/projects/analytics/src/app/routes/routes-page/routes-page.component.html.template +42 -0
- package/src/ng-add/files/projects/analytics/src/app/routes/routes-page/routes-page.component.scss.template +1 -0
- package/src/ng-add/files/projects/analytics/src/app/routes/routes-page/routes-page.component.ts.template +110 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/analytics-utils.ts.template +43 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/chart-theme.ts.template +42 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-layout.scss.template +239 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.html.template +76 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.scss.template +128 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.spec.ts.template +31 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.ts.template +153 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/funnel-chart/funnel-chart.component.html.template +16 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/funnel-chart/funnel-chart.component.scss.template +63 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/funnel-chart/funnel-chart.component.ts.template +52 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.html.template +5 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.scss.template +56 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.spec.ts.template +30 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.ts.template +15 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/quality-chart/quality-chart.component.html.template +9 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/quality-chart/quality-chart.component.scss.template +43 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/quality-chart/quality-chart.component.ts.template +62 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-distribution-chart/route-distribution-chart.component.html.template +9 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-distribution-chart/route-distribution-chart.component.scss.template +33 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-distribution-chart/route-distribution-chart.component.ts.template +82 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-traffic-chart/route-traffic-chart.component.html.template +15 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-traffic-chart/route-traffic-chart.component.scss.template +45 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-traffic-chart/route-traffic-chart.component.ts.template +55 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/status-message/status-message.component.html.template +18 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/status-message/status-message.component.scss.template +45 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/status-message/status-message.component.ts.template +15 -0
- package/src/ng-add/files/projects/analytics/src/app/vega-chart/vega-chart.component.ts.template +121 -0
- package/src/ng-add/files/projects/analytics/src/index.html.template +19 -0
- package/src/ng-add/files/projects/analytics/src/main.ts.template +16 -0
- package/src/ng-add/files/projects/analytics/src/styles.scss.template +28 -0
- package/src/ng-add/files/projects/analytics/tsconfig.app.json.template +13 -0
- package/src/ng-add/files/projects/analytics/tsconfig.spec.json.template +15 -0
- package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.html.template +3 -1
- package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.spec.ts.template +10 -13
- package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.ts.template +2 -0
- package/src/ng-add/files/src/app/admin/admin-panel/admin-settings/admin-settings.component.spec.ts.template +4 -5
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.spec.ts.template +11 -12
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.ts.template +7 -7
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.spec.ts.template +8 -10
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.ts.template +3 -2
- package/src/ng-add/files/src/app/app.component.html.template +3 -3
- package/src/ng-add/files/src/app/app.component.scss.template +1 -1
- package/src/ng-add/files/src/app/app.component.spec.ts.template +4 -5
- package/src/ng-add/files/src/app/app.component.ts.template +3 -2
- package/src/ng-add/files/src/app/app.config.ts.template +21 -15
- package/src/ng-add/files/src/app/app.routes.ts.template +6 -0
- package/src/ng-add/files/src/app/auth-routing.spec.ts.template +13 -9
- package/src/ng-add/files/src/app/core/analytics/time-analytics.service.spec.ts.template +46 -29
- package/src/ng-add/files/src/app/core/analytics/time-analytics.service.ts.template +27 -18
- package/src/ng-add/files/src/app/core/auth/auth.providers.spec.ts.template +112 -0
- package/src/ng-add/files/src/app/core/auth/auth.providers.ts.template +48 -0
- package/src/ng-add/files/src/app/core/auth/auth.service.ts.template +14 -23
- package/src/ng-add/files/src/app/core/auth/guards/require-admin.guard.spec.ts.template +27 -0
- package/src/ng-add/files/src/app/core/auth/guards/require-admin.guard.ts.template +3 -2
- package/src/ng-add/files/src/app/core/auth/guards/require-auth-and-consent.guard.ts.template +7 -2
- package/src/ng-add/files/src/app/core/firebase/data.providers.prod.ts.template +21 -0
- package/src/ng-add/files/src/app/core/firebase/data.providers.ts.template +13 -0
- package/src/ng-add/files/src/app/core/local-storage/session.service.spec.ts.template +43 -0
- package/src/ng-add/files/src/app/core/local-storage/session.service.ts.template +7 -0
- package/src/ng-add/files/src/app/core/store/app-data.spec.ts.template +76 -0
- package/src/ng-add/files/src/app/core/store/auth/auth.mock.ts.template +20 -82
- package/src/ng-add/files/src/app/core/store/auth/auth.store.spec.ts.template +217 -0
- package/src/ng-add/files/src/app/core/store/auth/auth.store.ts.template +36 -172
- package/src/ng-add/files/src/app/core/store/user/user.mock.ts.template +18 -15
- package/src/ng-add/files/src/app/core/store/user/user.model.ts.template +7 -8
- package/src/ng-add/files/src/app/core/store/user/user.store.ts.template +14 -10
- package/src/ng-add/files/src/app/core/store/user-context/user-context.mock.ts.template +20 -8
- package/src/ng-add/files/src/app/core/store/user-context/user-context.model.ts.template +5 -6
- package/src/ng-add/files/src/app/core/store/user-context/user-context.store.ts.template +14 -10
- package/src/ng-add/files/src/app/core/store/user-private/user-private.mock.ts.template +20 -7
- package/src/ng-add/files/src/app/core/store/user-private/user-private.model.ts.template +6 -6
- package/src/ng-add/files/src/app/core/store/user-private/user-private.store.ts.template +14 -10
- package/src/ng-add/files/src/app/core/testing/app-mocks.ts.template +42 -0
- package/src/ng-add/files/src/app/first-time/auth-action/auth-action.component.html.template +4 -0
- package/src/ng-add/files/src/app/first-time/auth-action/auth-action.component.scss.template +1 -0
- package/src/ng-add/files/src/app/first-time/auth-action/auth-action.component.ts.template +38 -0
- package/src/ng-add/files/src/app/first-time/consent/consent.component.html.template +2 -1
- package/src/ng-add/files/src/app/first-time/consent/consent.component.scss.template +7 -3
- package/src/ng-add/files/src/app/first-time/consent/consent.component.spec.ts.template +31 -11
- package/src/ng-add/files/src/app/first-time/consent/consent.component.ts.template +16 -1
- package/src/ng-add/files/src/app/first-time/consent/consent.guard.ts.template +5 -1
- package/src/ng-add/files/src/app/first-time/early-access/early-access.component.spec.ts.template +27 -16
- package/src/ng-add/files/src/app/first-time/early-access/early-access.component.ts.template +102 -49
- package/src/ng-add/files/src/app/first-time/early-access/early-access.guard.ts.template +5 -1
- package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.html.template +2 -1
- package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.scss.template +7 -3
- package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.spec.ts.template +20 -6
- package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.ts.template +2 -0
- package/src/ng-add/files/src/app/first-time/early-access/waitlist-view/waitlist-view.component.spec.ts.template +4 -5
- package/src/ng-add/files/src/app/first-time/email-link/email-link.component.html.template +18 -0
- package/src/ng-add/files/src/app/first-time/email-link/email-link.component.scss.template +2 -0
- package/src/ng-add/files/src/app/first-time/email-link/email-link.component.spec.ts.template +56 -0
- package/src/ng-add/files/src/app/first-time/email-link/email-link.component.ts.template +91 -0
- package/src/ng-add/files/src/app/first-time/first-time-routing.spec.ts.template +11 -7
- package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.html.template +19 -7
- package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.scss.template +51 -0
- package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.ts.template +44 -5
- package/src/ng-add/files/src/app/first-time/landing/landing.component.html.template +2 -1
- package/src/ng-add/files/src/app/first-time/landing/landing.component.scss.template +12 -8
- package/src/ng-add/files/src/app/first-time/landing/landing.component.spec.ts.template +33 -10
- package/src/ng-add/files/src/app/first-time/landing/landing.component.ts.template +6 -19
- package/src/ng-add/files/src/app/first-time/login/login.component.html.template +58 -6
- package/src/ng-add/files/src/app/first-time/login/login.component.scss.template +151 -22
- package/src/ng-add/files/src/app/first-time/login/login.component.spec.ts.template +30 -32
- package/src/ng-add/files/src/app/first-time/login/login.component.ts.template +85 -31
- package/src/ng-add/files/src/app/first-time/onboarding/onboarding.component.spec.ts.template +4 -2
- package/src/ng-add/files/src/app/first-time/onboarding/onboarding.component.ts.template +1 -1
- package/src/ng-add/files/src/app/main/account-profile/account-profile.component.html.template +12 -0
- package/src/ng-add/files/src/app/main/account-profile/account-profile.component.scss.template +39 -0
- package/src/ng-add/files/src/app/main/account-profile/account-profile.component.spec.ts.template +68 -0
- package/src/ng-add/files/src/app/main/account-profile/account-profile.component.ts.template +20 -0
- package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.html.template +24 -0
- package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.scss.template +50 -0
- package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.spec.ts.template +65 -0
- package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.ts.template +59 -0
- package/src/ng-add/files/src/app/main/account-profile/guest-deletion-dialog.component.ts.template +51 -0
- package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.html.template +50 -0
- package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.scss.template +137 -0
- package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.spec.ts.template +57 -0
- package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.ts.template +59 -0
- package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.html.template +133 -0
- package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.scss.template +207 -0
- package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.spec.ts.template +74 -0
- package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.ts.template +130 -0
- package/src/ng-add/files/src/app/main/home/home.component.spec.ts.template +4 -5
- package/src/ng-add/files/src/app/main/home/home.component.ts.template +1 -6
- package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.html.template +15 -0
- package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.scss.template +79 -0
- package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.spec.ts.template +59 -0
- package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.ts.template +44 -0
- package/src/ng-add/files/src/app/shared/navbar/navbar.component.html.template +45 -15
- package/src/ng-add/files/src/app/shared/navbar/navbar.component.scss.template +103 -19
- package/src/ng-add/files/src/app/shared/navbar/navbar.component.spec.ts.template +73 -9
- package/src/ng-add/files/src/app/shared/navbar/navbar.component.ts.template +46 -18
- package/src/ng-add/files/src/environments/environment.prod.ts.template +1 -0
- package/src/ng-add/files/src/environments/environment.test.ts.template +1 -0
- package/src/ng-add/files/src/environments/environment.ts.template +1 -1
- package/src/ng-add/files/tsconfig.spec.json.template +3 -1
- package/src/ng-add/index.js +7 -0
- package/src/ng-add/index.js.map +1 -1
- package/src/shared/entity-registry.d.ts +8 -0
- package/src/shared/entity-registry.js +28 -0
- package/src/shared/entity-registry.js.map +1 -0
- package/tsconfig.json +2 -2
- package/.agents/skills/publish-npm/SKILL.md +0 -37
- package/.agents/skills/publish-npm/eval.yaml +0 -32
- package/.agents/skills/publish-npm/fixtures/package-v21.json.template +0 -8
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.t4g/agent-memory.db +0 -0
- package/src/component/index_spec.d.ts +0 -1
- package/src/component/index_spec.js +0 -68
- package/src/component/index_spec.js.map +0 -1
- package/src/entity/index_spec.d.ts +0 -1
- package/src/entity/index_spec.js +0 -153
- package/src/entity/index_spec.js.map +0 -1
- package/src/guard/index_spec.d.ts +0 -1
- package/src/guard/index_spec.js +0 -64
- package/src/guard/index_spec.js.map +0 -1
- package/src/ng-add/files/bigquery/scripts/export_entities.py.template +0 -143
- package/src/ng-add/files/bigquery/scripts/run_query.py.template +0 -167
- package/src/ng-add/files/src/app/core/firebase/cached-listeners.service.ts.template +0 -494
- package/src/ng-add/files/src/app/core/firebase/database.service.ts.template +0 -56
- package/src/ng-add/files/src/app/core/firebase/firebase.mock.service.ts.template +0 -366
- package/src/ng-add/files/src/app/core/firebase/firebase.service.ts.template +0 -342
- package/src/ng-add/files/src/app/core/firebase/simulate-load.spec.ts.template +0 -104
- package/src/ng-add/files/src/app/core/firebase/simulate-stream.spec.ts.template +0 -127
- package/src/ng-add/files/src/app/core/firebase/simulation.mock.ts.template +0 -38
- package/src/ng-add/files/src/app/core/firebase/stream-multiplexer.ts.template +0 -445
- package/src/ng-add/files/src/app/core/logging/logging.service.spec.ts.template +0 -118
- package/src/ng-add/files/src/app/core/logging/logging.service.ts.template +0 -168
- package/src/ng-add/files/src/app/core/store/app.model.ts.template +0 -21
- package/src/ng-add/files/src/app/core/store/app.store.spec.ts.template +0 -920
- package/src/ng-add/files/src/app/core/store/app.store.ts.template +0 -1317
- package/src/ng-add/files/src/app/core/store/batch-write.firebase.service.ts.template +0 -58
- package/src/ng-add/files/src/app/core/store/batch-write.mock.service.ts.template +0 -105
- package/src/ng-add/files/src/app/core/store/batch-write.service.ts.template +0 -126
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.html.template +0 -9
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.scss.template +0 -46
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.spec.ts.template +0 -69
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.ts.template +0 -39
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.spec.ts.template +0 -122
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.ts.template +0 -88
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
OnInit,
|
|
4
|
+
OnDestroy,
|
|
5
|
+
ChangeDetectionStrategy,
|
|
6
|
+
computed,
|
|
7
|
+
Inject,
|
|
8
|
+
input,
|
|
9
|
+
output,
|
|
10
|
+
inject,
|
|
11
|
+
signal,
|
|
12
|
+
WritableSignal,
|
|
13
|
+
Signal,
|
|
14
|
+
Injector,
|
|
15
|
+
effect,
|
|
16
|
+
} from '@angular/core';
|
|
2
17
|
import { toObservable } from '@angular/core/rxjs-interop';
|
|
3
18
|
import { Observable } from 'rxjs';
|
|
4
19
|
import { filter, mergeMap } from 'rxjs/operators';
|
|
@@ -8,8 +23,7 @@ import { WaitlistData, SurveyData } from './early-access.model';
|
|
|
8
23
|
import { User, AccessState } from 'src/app/core/store/user/user.model';
|
|
9
24
|
import { handleAccess } from './early-access.guard';
|
|
10
25
|
import { UserContext } from 'src/app/core/store/user-context/user-context.model';
|
|
11
|
-
import {
|
|
12
|
-
import { BatchWriteService, BATCH_WRITE_SERVICE } from 'src/app/core/store/batch-write.service';
|
|
26
|
+
import { BatchWriteService, BATCH_WRITE_SERVICE, dataTimestampNow } from '@tech4good/platform-data';
|
|
13
27
|
import { NavbarComponent } from 'src/app/shared/navbar/navbar.component';
|
|
14
28
|
import { SurveyFormComponent } from './survey-form/survey-form.component';
|
|
15
29
|
import { WaitlistViewComponent } from './waitlist-view/waitlist-view.component';
|
|
@@ -17,23 +31,21 @@ import { MatSnackBar } from '@angular/material/snack-bar';
|
|
|
17
31
|
import { AuthStore } from 'src/app/core/store/auth/auth.store';
|
|
18
32
|
import { UserStore } from 'src/app/core/store/user/user.store';
|
|
19
33
|
import { UserContextStore } from 'src/app/core/store/user-context/user-context.store';
|
|
34
|
+
import { environment } from 'src/environments/environment';
|
|
35
|
+
import { TimeAnalyticsService } from 'src/app/core/analytics/time-analytics.service';
|
|
20
36
|
|
|
21
37
|
@Component({
|
|
22
38
|
selector: 'app-early-access',
|
|
23
39
|
templateUrl: './early-access.component.html',
|
|
24
40
|
styleUrl: './early-access.component.scss',
|
|
25
41
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
26
|
-
imports: [
|
|
27
|
-
NavbarComponent,
|
|
28
|
-
AsyncPipe,
|
|
29
|
-
SurveyFormComponent,
|
|
30
|
-
WaitlistViewComponent,
|
|
31
|
-
],
|
|
42
|
+
imports: [NavbarComponent, AsyncPipe, SurveyFormComponent, WaitlistViewComponent],
|
|
32
43
|
})
|
|
33
44
|
export class EarlyAccessComponent implements OnInit {
|
|
34
45
|
readonly authStore = inject(AuthStore);
|
|
35
46
|
readonly userStore = inject(UserStore);
|
|
36
47
|
readonly userContextStore = inject(UserContextStore);
|
|
48
|
+
private readonly analytics = inject(TimeAnalyticsService);
|
|
37
49
|
|
|
38
50
|
// --------------- INPUTS AND OUTPUTS ------------------
|
|
39
51
|
|
|
@@ -54,13 +66,18 @@ export class EarlyAccessComponent implements OnInit {
|
|
|
54
66
|
outreachLeadName = 'OUTREACH_LEAD_NAME [FirstName]';
|
|
55
67
|
outreachLeadEmail = 'OUTREACH_LEAD_EMAIL [email@ucsc.edu]';
|
|
56
68
|
|
|
57
|
-
|
|
58
69
|
// --------------- COMPUTED DATA -----------------------
|
|
59
70
|
|
|
60
71
|
/** Waitlist data from app-state, user, and user-context. */
|
|
61
|
-
waitlistData: Signal<WaitlistData> = computed(() => {
|
|
62
|
-
const
|
|
63
|
-
|
|
72
|
+
waitlistData: Signal<WaitlistData | null> = computed(() => {
|
|
73
|
+
const currentUser = this.currentUser();
|
|
74
|
+
if (!currentUser) return null;
|
|
75
|
+
|
|
76
|
+
const userContext = this.userContextStore.selectFirst(
|
|
77
|
+
[['__userId', '==', currentUser.__id]],
|
|
78
|
+
{},
|
|
79
|
+
);
|
|
80
|
+
return { currentUser, userContext };
|
|
64
81
|
});
|
|
65
82
|
|
|
66
83
|
/** Waiting position number. */
|
|
@@ -71,10 +88,13 @@ export class EarlyAccessComponent implements OnInit {
|
|
|
71
88
|
const compareDate = user.joinedWaitlistAt || user._createdAt;
|
|
72
89
|
if (!compareDate) return '';
|
|
73
90
|
|
|
74
|
-
const posNum = await this.userStore.count(
|
|
75
|
-
[
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
const posNum = await this.userStore.count(
|
|
92
|
+
[
|
|
93
|
+
['joinedWaitlistAt', '<=', compareDate],
|
|
94
|
+
['accessState', '==', AccessState.WAITING],
|
|
95
|
+
],
|
|
96
|
+
{},
|
|
97
|
+
);
|
|
78
98
|
return this.nth(posNum === 0 ? 1 : posNum);
|
|
79
99
|
} catch (e) {
|
|
80
100
|
console.error('Error calculating position:', e);
|
|
@@ -88,9 +108,7 @@ export class EarlyAccessComponent implements OnInit {
|
|
|
88
108
|
filter((user: User) => !!user),
|
|
89
109
|
mergeMap(async (user) => {
|
|
90
110
|
try {
|
|
91
|
-
const total = await this.userStore.count([
|
|
92
|
-
['accessState', '==', AccessState.WAITING],
|
|
93
|
-
], {});
|
|
111
|
+
const total = await this.userStore.count([['accessState', '==', AccessState.WAITING]], {});
|
|
94
112
|
return `${total}`;
|
|
95
113
|
} catch (e) {
|
|
96
114
|
console.error('Error calculating total:', e);
|
|
@@ -102,10 +120,14 @@ export class EarlyAccessComponent implements OnInit {
|
|
|
102
120
|
/** Function for adding the appropriate suffix. */
|
|
103
121
|
nth(n: number): string {
|
|
104
122
|
switch (n % 10) {
|
|
105
|
-
case 1:
|
|
106
|
-
|
|
107
|
-
case
|
|
108
|
-
|
|
123
|
+
case 1:
|
|
124
|
+
return `${n}st`;
|
|
125
|
+
case 2:
|
|
126
|
+
return `${n}nd`;
|
|
127
|
+
case 3:
|
|
128
|
+
return `${n}rd`;
|
|
129
|
+
default:
|
|
130
|
+
return `${n}th`;
|
|
109
131
|
}
|
|
110
132
|
}
|
|
111
133
|
|
|
@@ -113,36 +135,67 @@ export class EarlyAccessComponent implements OnInit {
|
|
|
113
135
|
|
|
114
136
|
/** Submit background and interests. */
|
|
115
137
|
async submitInterest(formData: SurveyData) {
|
|
138
|
+
const waitlistData = this.waitlistData();
|
|
139
|
+
if (!waitlistData) return;
|
|
140
|
+
|
|
141
|
+
this.analytics.trackInteraction('onboarding', 'interest_submit_attempt');
|
|
116
142
|
try {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
const hasWaitlist = environment.hasWaitlist;
|
|
144
|
+
const targetState = hasWaitlist ? AccessState.WAITING : AccessState.CONSENT;
|
|
145
|
+
|
|
146
|
+
await this.batch.batchWrite(
|
|
147
|
+
async (batchConfig) => {
|
|
148
|
+
await this.userStore.update(
|
|
149
|
+
waitlistData.currentUser.__id,
|
|
150
|
+
{
|
|
151
|
+
accessState: targetState,
|
|
152
|
+
joinedWaitlistAt: dataTimestampNow(),
|
|
153
|
+
},
|
|
154
|
+
{ batchConfig },
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
if (waitlistData.userContext) {
|
|
158
|
+
this.userContextStore.update(
|
|
159
|
+
waitlistData.userContext.__id,
|
|
160
|
+
{
|
|
161
|
+
questionOne: formData.questionOne ?? '',
|
|
162
|
+
questionTwo: formData.questionTwo ?? '',
|
|
163
|
+
},
|
|
164
|
+
{ batchConfig },
|
|
165
|
+
);
|
|
166
|
+
} else {
|
|
167
|
+
this.userContextStore.add(
|
|
168
|
+
{
|
|
169
|
+
__userId: waitlistData.currentUser.__id,
|
|
170
|
+
questionOne: formData.questionOne ?? '',
|
|
171
|
+
questionTwo: formData.questionTwo ?? '',
|
|
172
|
+
},
|
|
173
|
+
{ batchConfig },
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
loading: this.loading,
|
|
179
|
+
snackBarConfig: {
|
|
180
|
+
successMessage: 'Submitted interest form!',
|
|
181
|
+
failureMessage: 'Failed to submit response',
|
|
182
|
+
undoOnAction: true,
|
|
183
|
+
config: { duration: 3000 },
|
|
184
|
+
},
|
|
142
185
|
},
|
|
186
|
+
);
|
|
187
|
+
this.analytics.trackInteraction('onboarding', 'interest_submit_result', {
|
|
188
|
+
outcome: 'success',
|
|
143
189
|
});
|
|
190
|
+
|
|
191
|
+
if (!hasWaitlist) {
|
|
192
|
+
await this.router.navigate(['/consent'], { queryParams: this.route.snapshot.queryParams });
|
|
193
|
+
}
|
|
144
194
|
} catch (e) {
|
|
145
195
|
console.error(e);
|
|
196
|
+
this.analytics.trackInteraction('onboarding', 'interest_submit_result', {
|
|
197
|
+
outcome: 'error',
|
|
198
|
+
});
|
|
146
199
|
}
|
|
147
200
|
}
|
|
148
201
|
|
|
@@ -4,6 +4,7 @@ import { map } from 'rxjs/operators';
|
|
|
4
4
|
import { AuthService } from '../../core/auth/auth.service';
|
|
5
5
|
import { User, AccessState } from '../../core/store/user/user.model';
|
|
6
6
|
import { hasAdminOverride } from '../../core/auth/guards/admin-override';
|
|
7
|
+
import { environment } from 'src/environments/environment';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Ensures the user is currently on the waitlist. Users who have already
|
|
@@ -17,10 +18,13 @@ export function handleAccess(
|
|
|
17
18
|
router: Router,
|
|
18
19
|
route: ActivatedRouteSnapshot,
|
|
19
20
|
state: RouterStateSnapshot,
|
|
21
|
+
hasWaitlist: boolean = environment.hasWaitlist,
|
|
20
22
|
): boolean {
|
|
21
23
|
if (hasAdminOverride(user, state.url)) return true;
|
|
22
24
|
|
|
23
|
-
const waitingStates =
|
|
25
|
+
const waitingStates = hasWaitlist ?
|
|
26
|
+
[AccessState.SUBMIT_INTEREST, AccessState.WAITING] :
|
|
27
|
+
[AccessState.SUBMIT_INTEREST];
|
|
24
28
|
if (user && !waitingStates.includes(user.accessState)) {
|
|
25
29
|
// Fully completed onboarding → go straight to home
|
|
26
30
|
if (user.consented && user.accessState === AccessState.DONE) {
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
Submitting...
|
|
37
37
|
} @else {
|
|
38
38
|
Submit and Continue
|
|
39
|
-
|
|
39
|
+
<!-- Decorative arrow from the bundled Material Icons font (no remote image host) -->
|
|
40
|
+
<mat-icon aria-hidden="true">arrow_forward</mat-icon>
|
|
40
41
|
}
|
|
41
42
|
</button>
|
|
42
43
|
</form>
|
|
@@ -66,7 +66,11 @@
|
|
|
66
66
|
padding: 10px 22px 10px;
|
|
67
67
|
transition: color 0.8s ease, border 0.8s ease;
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
// Arrow icon: sized to match the button text and nudged right on hover
|
|
70
|
+
>mat-icon {
|
|
71
|
+
font-size: 20px;
|
|
72
|
+
width: 20px;
|
|
73
|
+
height: 20px;
|
|
70
74
|
margin: 0 3px 0 2px;
|
|
71
75
|
transition: margin 0.2s ease;
|
|
72
76
|
}
|
|
@@ -79,12 +83,12 @@
|
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
&:hover {
|
|
82
|
-
>
|
|
86
|
+
>mat-icon {
|
|
83
87
|
margin: 0 0 0 5px;
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
&[disabled] {
|
|
87
|
-
>
|
|
91
|
+
>mat-icon {
|
|
88
92
|
margin: 0 3px 0 2px;
|
|
89
93
|
}
|
|
90
94
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { render } from '@testing-library/angular';
|
|
1
|
+
import { render, screen } from '@testing-library/angular';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
|
|
4
4
|
import { SurveyFormComponent } from './survey-form.component';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { BATCH_WRITE_SERVICE } from 'src/app/core/store/batch-write.service';
|
|
5
|
+
import { provideAppMocks } from 'src/app/core/testing/app-mocks';
|
|
6
|
+
import { BatchWriteMockService } from '@tech4good/platform-data/testing';
|
|
7
|
+
import { BATCH_WRITE_SERVICE } from '@tech4good/platform-data';
|
|
9
8
|
|
|
10
9
|
/** Sets up the testing environment for SurveyFormComponent using render. */
|
|
11
10
|
async function setup() {
|
|
@@ -15,7 +14,7 @@ async function setup() {
|
|
|
15
14
|
const view = await render(SurveyFormComponent, {
|
|
16
15
|
imports: [],
|
|
17
16
|
providers: [
|
|
18
|
-
|
|
17
|
+
...provideAppMocks(),
|
|
19
18
|
{ provide: BATCH_WRITE_SERVICE, useClass: BatchWriteMockService },
|
|
20
19
|
],
|
|
21
20
|
componentInputs: { loading: false },
|
|
@@ -34,4 +33,19 @@ describe('SurveyFormComponent', () => {
|
|
|
34
33
|
const { fixture } = await setup();
|
|
35
34
|
expect(fixture.componentInstance).toBeTruthy();
|
|
36
35
|
});
|
|
36
|
+
|
|
37
|
+
it('renders the submit arrow as a bundled Material icon rather than a remote image', async () => {
|
|
38
|
+
await setup();
|
|
39
|
+
|
|
40
|
+
// The arrow is decorative, so the button's accessible name is just its label
|
|
41
|
+
const submitButton = screen.getByRole('button', { name: 'Submit and Continue' });
|
|
42
|
+
|
|
43
|
+
// Remote icon images (like the former third-party arrow SVG) break when their host goes away.
|
|
44
|
+
expect(submitButton.querySelector('img')).toBeNull();
|
|
45
|
+
|
|
46
|
+
const icon = submitButton.querySelector('mat-icon');
|
|
47
|
+
expect(icon).not.toBeNull();
|
|
48
|
+
expect(icon).toHaveTextContent('arrow_forward');
|
|
49
|
+
expect(icon).toHaveAttribute('aria-hidden', 'true');
|
|
50
|
+
});
|
|
37
51
|
});
|
|
@@ -3,6 +3,7 @@ import { form, required, minLength, FormField, FormRoot } from '@angular/forms/s
|
|
|
3
3
|
import { MatFormField, MatLabel, MatHint } from '@angular/material/form-field';
|
|
4
4
|
import { MatInput } from '@angular/material/input';
|
|
5
5
|
import { CdkTextareaAutosize } from '@angular/cdk/text-field';
|
|
6
|
+
import { MatIcon } from '@angular/material/icon';
|
|
6
7
|
import { HintVisibilityDirective } from 'src/app/shared/hint-visibility/hint-visibility.directive';
|
|
7
8
|
import { SurveyData } from '../early-access.model';
|
|
8
9
|
|
|
@@ -19,6 +20,7 @@ import { SurveyData } from '../early-access.model';
|
|
|
19
20
|
MatInput,
|
|
20
21
|
MatHint,
|
|
21
22
|
CdkTextareaAutosize,
|
|
23
|
+
MatIcon,
|
|
22
24
|
HintVisibilityDirective,
|
|
23
25
|
],
|
|
24
26
|
})
|
|
@@ -3,10 +3,9 @@ import userEvent from '@testing-library/user-event';
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
import { WaitlistViewComponent } from './waitlist-view.component';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { BATCH_WRITE_SERVICE } from 'src/app/core/store/batch-write.service';
|
|
6
|
+
import { provideAppMocks } from 'src/app/core/testing/app-mocks';
|
|
7
|
+
import { BatchWriteMockService } from '@tech4good/platform-data/testing';
|
|
8
|
+
import { BATCH_WRITE_SERVICE } from '@tech4good/platform-data';
|
|
10
9
|
|
|
11
10
|
/** Sets up the testing environment for WaitlistViewComponent using render. */
|
|
12
11
|
async function setup() {
|
|
@@ -16,7 +15,7 @@ async function setup() {
|
|
|
16
15
|
const view = await render(WaitlistViewComponent, {
|
|
17
16
|
imports: [],
|
|
18
17
|
providers: [
|
|
19
|
-
|
|
18
|
+
...provideAppMocks(),
|
|
20
19
|
{ provide: BATCH_WRITE_SERVICE, useClass: BatchWriteMockService },
|
|
21
20
|
],
|
|
22
21
|
componentInputs: {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<main class="email-link">
|
|
2
|
+
@if (isSubmitting()) {
|
|
3
|
+
<h1>Signing you in…</h1>
|
|
4
|
+
<p>Completing your secure email link.</p>
|
|
5
|
+
} @else {
|
|
6
|
+
<h1>Confirm your email</h1>
|
|
7
|
+
<p>Enter the email address where you received this link.</p>
|
|
8
|
+
<form (submit)="complete(); $event.preventDefault()">
|
|
9
|
+
<mat-form-field appearance="outline">
|
|
10
|
+
<mat-label>Email</mat-label>
|
|
11
|
+
<input matInput type="email" [formField]="form.email" autocomplete="email" />
|
|
12
|
+
@if (form.email().touched() && form.email().invalid()) { <mat-error>Enter a valid email address.</mat-error> }
|
|
13
|
+
</mat-form-field>
|
|
14
|
+
<button mat-flat-button color="primary" type="submit">Continue</button>
|
|
15
|
+
</form>
|
|
16
|
+
}
|
|
17
|
+
@if (message()) { <p role="status">{{ message() }}</p> }
|
|
18
|
+
</main>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Router } from '@angular/router';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/angular';
|
|
3
|
+
import { EmailLinkComponent } from './email-link.component';
|
|
4
|
+
import { AuthStore } from 'src/app/core/store/auth/auth.store';
|
|
5
|
+
import { TimeAnalyticsService } from 'src/app/core/analytics/time-analytics.service';
|
|
6
|
+
import { AccessState } from 'src/app/core/store/user/user.model';
|
|
7
|
+
import { createMockUser } from 'src/app/core/store/user/user.mock';
|
|
8
|
+
|
|
9
|
+
describe('EmailLinkComponent', () => {
|
|
10
|
+
it('completes automatically when the request email is stored in this browser', async () => {
|
|
11
|
+
const completeEmailSignInLink = jest.fn().mockResolvedValue({});
|
|
12
|
+
const getStoredEmailForEmailLink = jest.fn().mockReturnValue('learner@example.com');
|
|
13
|
+
const router = { navigate: jest.fn().mockResolvedValue(true) };
|
|
14
|
+
const trackInteraction = jest.fn();
|
|
15
|
+
await render(EmailLinkComponent, {
|
|
16
|
+
providers: [
|
|
17
|
+
{
|
|
18
|
+
provide: AuthStore,
|
|
19
|
+
useValue: {
|
|
20
|
+
getStoredEmailForEmailLink,
|
|
21
|
+
completeEmailSignInLink,
|
|
22
|
+
user: () => createMockUser({ __id: 'user-123', accessState: AccessState.DONE }),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{ provide: Router, useValue: router },
|
|
26
|
+
{ provide: TimeAnalyticsService, useValue: { trackInteraction } },
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
await waitFor(() => expect(completeEmailSignInLink).toHaveBeenCalledWith(window.location.href, 'learner@example.com'));
|
|
31
|
+
expect(getStoredEmailForEmailLink).toHaveBeenCalledTimes(1);
|
|
32
|
+
expect(router.navigate).toHaveBeenCalledWith(['/home']);
|
|
33
|
+
expect(trackInteraction).toHaveBeenCalledWith('onboarding', 'auth_result', {
|
|
34
|
+
method: 'email_link_complete',
|
|
35
|
+
outcome: 'success',
|
|
36
|
+
authenticatedUserId: 'user-123',
|
|
37
|
+
accessState: AccessState.DONE,
|
|
38
|
+
});
|
|
39
|
+
expect(screen.queryByLabelText('Email')).not.toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('asks for the email when the link is opened without same-browser state', async () => {
|
|
43
|
+
await render(EmailLinkComponent, {
|
|
44
|
+
providers: [
|
|
45
|
+
{
|
|
46
|
+
provide: AuthStore,
|
|
47
|
+
useValue: { getStoredEmailForEmailLink: () => null, user: () => null },
|
|
48
|
+
},
|
|
49
|
+
{ provide: Router, useValue: { navigate: jest.fn() } },
|
|
50
|
+
{ provide: TimeAnalyticsService, useValue: { trackInteraction: jest.fn() } },
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(screen.getByLabelText('Email')).toBeVisible();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject, OnInit, signal } from '@angular/core';
|
|
2
|
+
import { form, FormField, required, email, submit } from '@angular/forms/signals';
|
|
3
|
+
import { Router } from '@angular/router';
|
|
4
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
5
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
6
|
+
import { MatInputModule } from '@angular/material/input';
|
|
7
|
+
import { AuthStore } from 'src/app/core/store/auth/auth.store';
|
|
8
|
+
import { TimeAnalyticsService } from 'src/app/core/analytics/time-analytics.service';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Handles the completion phase of email magic-link authentication (`/email-link`).
|
|
12
|
+
*
|
|
13
|
+
* If the link was opened in the same browser session where it was requested, the target email
|
|
14
|
+
* is automatically retrieved from `EmailLinkContextService`. If opened in a different browser/device
|
|
15
|
+
* or if local storage was cleared, the component prompts the user to re-enter their email.
|
|
16
|
+
*/
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'app-email-link',
|
|
19
|
+
templateUrl: './email-link.component.html',
|
|
20
|
+
styleUrl: './email-link.component.scss',
|
|
21
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
22
|
+
imports: [FormField, MatButtonModule, MatFormFieldModule, MatInputModule],
|
|
23
|
+
})
|
|
24
|
+
export class EmailLinkComponent implements OnInit {
|
|
25
|
+
private readonly authStore = inject(AuthStore);
|
|
26
|
+
private readonly router = inject(Router);
|
|
27
|
+
private readonly analytics = inject(TimeAnalyticsService);
|
|
28
|
+
private readonly storedEmail = this.authStore.getStoredEmailForEmailLink();
|
|
29
|
+
|
|
30
|
+
/** User-facing status or error message. */
|
|
31
|
+
readonly message = signal<string | null>(null);
|
|
32
|
+
|
|
33
|
+
/** Whether the email link completion request is currently processing. */
|
|
34
|
+
readonly isSubmitting = signal(Boolean(this.storedEmail));
|
|
35
|
+
|
|
36
|
+
/** Signal form model for the manual email entry fallback. */
|
|
37
|
+
readonly emailModel = signal({
|
|
38
|
+
email: this.storedEmail || '',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/** Signal-based form validation schema for email input. */
|
|
42
|
+
readonly form = form(this.emailModel, (s) => {
|
|
43
|
+
required(s.email, { message: 'Email is required' });
|
|
44
|
+
email(s.email, { message: 'Enter a valid email address.' });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
async ngOnInit(): Promise<void> {
|
|
48
|
+
if (this.storedEmail) await this.completeWith(this.storedEmail);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Triggers manual completion when the user submits their email address. */
|
|
52
|
+
async complete(): Promise<void> {
|
|
53
|
+
await submit(this.form, async () => {
|
|
54
|
+
await this.completeWith(this.emailModel().email);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Verifies the email link URL and completes sign-in or account linking via AuthStore.
|
|
60
|
+
*/
|
|
61
|
+
private async completeWith(email: string): Promise<void> {
|
|
62
|
+
this.isSubmitting.set(true);
|
|
63
|
+
this.message.set(null);
|
|
64
|
+
this.analytics.trackInteraction('onboarding', 'auth_attempt', {
|
|
65
|
+
method: 'email_link_complete',
|
|
66
|
+
});
|
|
67
|
+
try {
|
|
68
|
+
await this.authStore.completeEmailSignInLink(window.location.href, email);
|
|
69
|
+
this.analytics.trackInteraction('onboarding', 'auth_result', {
|
|
70
|
+
method: 'email_link_complete',
|
|
71
|
+
outcome: 'success',
|
|
72
|
+
authenticatedUserId: this.authStore.user()?.__id,
|
|
73
|
+
accessState: this.authStore.user()?.accessState,
|
|
74
|
+
});
|
|
75
|
+
await this.router.navigate(['/home']);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
const code = (error as { code?: string }).code;
|
|
78
|
+
this.analytics.trackInteraction('onboarding', 'auth_result', {
|
|
79
|
+
method: 'email_link_complete',
|
|
80
|
+
outcome: 'error',
|
|
81
|
+
});
|
|
82
|
+
this.message.set(
|
|
83
|
+
code === 'auth/link-requires-original-session' ?
|
|
84
|
+
'Return to the browser where you started this account upgrade to save that guest progress.' :
|
|
85
|
+
'This sign-in link is invalid, expired, or for a different email. Request a new link and try again.',
|
|
86
|
+
);
|
|
87
|
+
} finally {
|
|
88
|
+
this.isSubmitting.set(false);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -5,10 +5,9 @@ import { AuthService } from '../core/auth/auth.service';
|
|
|
5
5
|
import { routes } from '../app.routes';
|
|
6
6
|
import { of } from 'rxjs';
|
|
7
7
|
import { AccessState, User } from '../core/store/user/user.model';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { BATCH_WRITE_SERVICE } from '../core/store/batch-write.service';
|
|
8
|
+
import { provideAppMocks } from 'src/app/core/testing/app-mocks';
|
|
9
|
+
import { BatchWriteMockService } from '@tech4good/platform-data/testing';
|
|
10
|
+
import { BATCH_WRITE_SERVICE } from '@tech4good/platform-data';
|
|
12
11
|
import { LOG_SERVICE, LogInDevService } from '../core/analytics/log.service';
|
|
13
12
|
import { AuthStore } from '../core/store/auth/auth.store';
|
|
14
13
|
import { signal } from '@angular/core';
|
|
@@ -18,21 +17,23 @@ import { createMockUser } from '../core/store/user/user.mock';
|
|
|
18
17
|
describe('First-Time / Onboarding Routing', () => {
|
|
19
18
|
let harness: RouterTestingHarness;
|
|
20
19
|
let router: Router;
|
|
21
|
-
let mockAuthService: { resolveUser: jest.Mock };
|
|
20
|
+
let mockAuthService: { resolveUser: jest.Mock; resolveSession: jest.Mock };
|
|
22
21
|
let mockUserSignal: any;
|
|
23
22
|
|
|
24
23
|
beforeEach(async () => {
|
|
25
24
|
mockAuthService = {
|
|
26
25
|
resolveUser: jest.fn().mockReturnValue(of(null)),
|
|
26
|
+
resolveSession: jest.fn().mockReturnValue(of(null)),
|
|
27
27
|
};
|
|
28
28
|
mockUserSignal = signal(null);
|
|
29
|
+
const mockAfUserSignal = signal(null);
|
|
29
30
|
|
|
30
31
|
await TestBed.configureTestingModule({
|
|
31
32
|
providers: [
|
|
32
33
|
provideRouter(routes),
|
|
33
34
|
{ provide: AuthService, useValue: mockAuthService },
|
|
34
|
-
{ provide: AuthStore, useValue: { user: mockUserSignal } },
|
|
35
|
-
|
|
35
|
+
{ provide: AuthStore, useValue: { user: mockUserSignal, afUser: mockAfUserSignal } },
|
|
36
|
+
...provideAppMocks(),
|
|
36
37
|
{ provide: BATCH_WRITE_SERVICE, useClass: BatchWriteMockService },
|
|
37
38
|
{ provide: LOG_SERVICE, useClass: LogInDevService },
|
|
38
39
|
],
|
|
@@ -46,6 +47,7 @@ describe('First-Time / Onboarding Routing', () => {
|
|
|
46
47
|
beforeEach(() => {
|
|
47
48
|
const u = createMockUser({ accessState: AccessState.SUBMIT_INTEREST, consented: false });
|
|
48
49
|
mockAuthService.resolveUser.mockReturnValue(of(u));
|
|
50
|
+
mockAuthService.resolveSession.mockReturnValue(of({ isAnonymous: false, emailVerified: true }));
|
|
49
51
|
mockUserSignal.set(u);
|
|
50
52
|
});
|
|
51
53
|
|
|
@@ -72,6 +74,7 @@ describe('First-Time / Onboarding Routing', () => {
|
|
|
72
74
|
beforeEach(() => {
|
|
73
75
|
const u = createMockUser({ accessState: AccessState.CONSENT, consented: false });
|
|
74
76
|
mockAuthService.resolveUser.mockReturnValue(of(u));
|
|
77
|
+
mockAuthService.resolveSession.mockReturnValue(of({ isAnonymous: false, emailVerified: true }));
|
|
75
78
|
mockUserSignal.set(u);
|
|
76
79
|
});
|
|
77
80
|
|
|
@@ -99,6 +102,7 @@ describe('First-Time / Onboarding Routing', () => {
|
|
|
99
102
|
beforeEach(() => {
|
|
100
103
|
const fullyOnboardedUser = createMockUser({ accessState: AccessState.DONE, consented: true });
|
|
101
104
|
mockAuthService.resolveUser.mockReturnValue(of(fullyOnboardedUser));
|
|
105
|
+
mockAuthService.resolveSession.mockReturnValue(of({ isAnonymous: false, emailVerified: true }));
|
|
102
106
|
mockUserSignal.set(fullyOnboardedUser);
|
|
103
107
|
});
|
|
104
108
|
|
|
@@ -4,14 +4,26 @@
|
|
|
4
4
|
<div class="hero-subtitle">
|
|
5
5
|
<app-rotating-quotes [sentences]="sentences"></app-rotating-quotes>
|
|
6
6
|
</div>
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
<div class="cta-actions">
|
|
8
|
+
<a class="cta-button" href="/login" (click)="onGetStarted($event)">Get started</a>
|
|
9
|
+
@if (showGuestLogin()) {
|
|
10
|
+
<button
|
|
11
|
+
class="try-guest"
|
|
12
|
+
type="button"
|
|
13
|
+
[disabled]="isGuestLoading()"
|
|
14
|
+
(click)="tryWithoutLoggingIn()"
|
|
15
|
+
>
|
|
16
|
+
@if (isGuestLoading()) {
|
|
17
|
+
<svg class="spinner-icon" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
18
|
+
<path d="M21 12a9 9 0 1 1-6.219-8.56"/>
|
|
19
|
+
</svg>
|
|
20
|
+
<span>Creating guest session...</span>
|
|
21
|
+
} @else {
|
|
22
|
+
<span>Try without logging in</span>
|
|
23
|
+
}
|
|
24
|
+
</button>
|
|
13
25
|
}
|
|
14
|
-
</
|
|
26
|
+
</div>
|
|
15
27
|
</div>
|
|
16
28
|
<div class="hero-visual" animate.enter="animate-fade-in-up">
|
|
17
29
|
<img src="/images/abstract.png" alt="Abstract illustration placeholder" />
|