@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,44 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core';
|
|
2
|
+
import { email, form, FormField, required, submit } from '@angular/forms/signals';
|
|
3
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
4
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
5
|
+
import { MatInputModule } from '@angular/material/input';
|
|
6
|
+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
7
|
+
import { Router } from '@angular/router';
|
|
3
8
|
import { AuthStore } from 'src/app/core/store/auth/auth.store';
|
|
9
|
+
import { TimeAnalyticsService } from 'src/app/core/analytics/time-analytics.service';
|
|
4
10
|
|
|
5
11
|
@Component({
|
|
6
12
|
selector: 'app-login',
|
|
7
13
|
templateUrl: './login.component.html',
|
|
8
14
|
styleUrl: './login.component.scss',
|
|
9
15
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
16
|
+
imports: [FormField, MatButtonModule, MatFormFieldModule, MatInputModule, MatProgressSpinnerModule],
|
|
10
17
|
})
|
|
11
|
-
export class LoginComponent
|
|
12
|
-
authStore = inject(AuthStore);
|
|
18
|
+
export class LoginComponent {
|
|
19
|
+
readonly authStore = inject(AuthStore);
|
|
20
|
+
private readonly router = inject(Router);
|
|
21
|
+
private readonly analytics = inject(TimeAnalyticsService);
|
|
22
|
+
readonly message = signal<string | null>(null);
|
|
23
|
+
readonly sentEmail = signal(false);
|
|
24
|
+
readonly isSendingMagicLink = signal(false);
|
|
25
|
+
readonly isSigningInGoogle = signal(false);
|
|
26
|
+
readonly isLoading = computed(
|
|
27
|
+
() =>
|
|
28
|
+
this.isSendingMagicLink() ||
|
|
29
|
+
this.isSigningInGoogle() ||
|
|
30
|
+
this.authStore.isLoadingLogin(),
|
|
31
|
+
);
|
|
32
|
+
readonly loginModel = signal({ email: '' });
|
|
33
|
+
readonly form = form(this.loginModel, (schema) => {
|
|
34
|
+
required(schema.email, { message: 'Email is required' });
|
|
35
|
+
email(schema.email, { message: 'Please enter a valid email address' });
|
|
36
|
+
});
|
|
13
37
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
async sendMagicLink(): Promise<void> {
|
|
39
|
+
if (this.isLoading()) return;
|
|
40
|
+
await submit(this.form, async () => {
|
|
41
|
+
this.message.set(null);
|
|
42
|
+
this.isSendingMagicLink.set(true);
|
|
43
|
+
this.analytics.trackInteraction('onboarding', 'auth_attempt', {
|
|
44
|
+
method: 'email_link',
|
|
45
|
+
});
|
|
46
|
+
try {
|
|
47
|
+
await this.authStore.sendEmailSignInLink(this.loginModel().email);
|
|
48
|
+
this.analytics.trackInteraction('onboarding', 'auth_result', {
|
|
49
|
+
method: 'email_link',
|
|
50
|
+
outcome: 'link_sent',
|
|
51
|
+
});
|
|
52
|
+
this.sentEmail.set(true);
|
|
53
|
+
} catch {
|
|
54
|
+
this.analytics.trackInteraction('onboarding', 'auth_result', {
|
|
55
|
+
method: 'email_link',
|
|
56
|
+
outcome: 'error',
|
|
57
|
+
});
|
|
58
|
+
this.message.set('We could not send a sign-in link. Please try again.');
|
|
59
|
+
} finally {
|
|
60
|
+
this.isSendingMagicLink.set(false);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
28
63
|
}
|
|
29
64
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
65
|
+
async signInWithGoogle(): Promise<void> {
|
|
66
|
+
if (this.isLoading()) return;
|
|
67
|
+
this.message.set(null);
|
|
68
|
+
this.isSigningInGoogle.set(true);
|
|
69
|
+
this.analytics.trackInteraction('onboarding', 'auth_attempt', {
|
|
70
|
+
method: 'google',
|
|
71
|
+
});
|
|
72
|
+
try {
|
|
73
|
+
await this.authStore.signInWithGoogle();
|
|
74
|
+
this.analytics.trackInteraction('onboarding', 'auth_result', {
|
|
75
|
+
method: 'google',
|
|
76
|
+
outcome: 'success',
|
|
77
|
+
authenticatedUserId: this.authStore.user()?.__id,
|
|
78
|
+
accessState: this.authStore.user()?.accessState,
|
|
79
|
+
});
|
|
80
|
+
await this.router.navigate(['/home']);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
const code = (error as { code?: string }).code;
|
|
83
|
+
this.analytics.trackInteraction('onboarding', 'auth_result', {
|
|
84
|
+
method: 'google',
|
|
85
|
+
outcome: code === 'auth/popup-closed-by-user' ? 'cancelled' : 'error',
|
|
86
|
+
});
|
|
87
|
+
if (code === 'auth/account-exists-with-different-credential') {
|
|
88
|
+
this.message.set(
|
|
89
|
+
'Sign in with an email link first, then use Link Google from your account page.',
|
|
90
|
+
);
|
|
91
|
+
} else if (code !== 'auth/popup-closed-by-user') {
|
|
92
|
+
this.message.set('Google sign-in did not complete. Please try again.');
|
|
93
|
+
}
|
|
94
|
+
} finally {
|
|
95
|
+
this.isSigningInGoogle.set(false);
|
|
96
|
+
}
|
|
43
97
|
}
|
|
44
98
|
}
|
package/src/ng-add/files/src/app/first-time/onboarding/onboarding.component.spec.ts.template
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import { provideAppMocks } from 'src/app/core/testing/app-mocks';
|
|
1
2
|
import { render } from '@testing-library/angular';
|
|
2
3
|
import { Provider } from '@angular/core';
|
|
3
4
|
|
|
4
5
|
import { OnboardingComponent } from './onboarding.component';
|
|
5
6
|
import { AuthStore } from 'src/app/core/store/auth/auth.store';
|
|
6
7
|
import { AuthLoggedInMockDB } from 'src/app/core/store/auth/auth.mock';
|
|
7
|
-
import { BATCH_WRITE_SERVICE } from '
|
|
8
|
-
import { BatchWriteMockService } from '
|
|
8
|
+
import { BATCH_WRITE_SERVICE } from '@tech4good/platform-data';
|
|
9
|
+
import { BatchWriteMockService } from '@tech4good/platform-data/testing';
|
|
9
10
|
|
|
10
11
|
/** Sets up the testing environment for OnboardingComponent using render. */
|
|
11
12
|
async function setup(providers: Provider[] = []) {
|
|
12
13
|
const view = await render(OnboardingComponent, {
|
|
13
14
|
imports: [],
|
|
14
15
|
providers: [
|
|
16
|
+
...provideAppMocks({ disableLatency: true }),
|
|
15
17
|
{ provide: AuthStore, useClass: AuthLoggedInMockDB },
|
|
16
18
|
{ provide: BATCH_WRITE_SERVICE, useClass: BatchWriteMockService },
|
|
17
19
|
...providers,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component, OnInit, ChangeDetectionStrategy, input, output, inject, WritableSignal, Signal, signal, computed, Inject, Injector } from '@angular/core';
|
|
2
2
|
import { User } from 'src/app/core/store/user/user.model';
|
|
3
3
|
import { AuthStore } from 'src/app/core/store/auth/auth.store';
|
|
4
|
-
import { BatchWriteService, BATCH_WRITE_SERVICE } from '
|
|
4
|
+
import { BatchWriteService, BATCH_WRITE_SERVICE } from '@tech4good/platform-data';
|
|
5
5
|
|
|
6
6
|
@Component({
|
|
7
7
|
selector: 'app-onboarding',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<app-navbar />
|
|
2
|
+
|
|
3
|
+
<main class="profile-container animate-fade-in">
|
|
4
|
+
<header class="profile-header">
|
|
5
|
+
<h1>Profile & Account Settings</h1>
|
|
6
|
+
<p>Manage your profile details, display name, and connected sign-in methods.</p>
|
|
7
|
+
</header>
|
|
8
|
+
|
|
9
|
+
<app-profile-details-card />
|
|
10
|
+
<app-sign-in-methods-card #signInMethodsCard />
|
|
11
|
+
<app-delete-guest-card (saveProgressRequested)="signInMethodsCard.focusGuestEmail()" />
|
|
12
|
+
</main>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@use 'variables' as *;
|
|
2
|
+
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
min-height: 100vh;
|
|
6
|
+
background: $bg-primary;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.profile-container {
|
|
10
|
+
max-width: 680px;
|
|
11
|
+
margin: 0 auto;
|
|
12
|
+
padding: 40px 24px 60px;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.profile-header {
|
|
17
|
+
margin-bottom: 28px;
|
|
18
|
+
|
|
19
|
+
h1 {
|
|
20
|
+
margin: 0 0 8px;
|
|
21
|
+
color: #1e1b4b;
|
|
22
|
+
font-size: 2.2rem;
|
|
23
|
+
font-weight: 800;
|
|
24
|
+
letter-spacing: -0.025em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
p {
|
|
28
|
+
margin: 0;
|
|
29
|
+
color: #475569;
|
|
30
|
+
font-size: 1rem;
|
|
31
|
+
line-height: 1.5;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@media (max-width: 640px) {
|
|
36
|
+
.profile-container {
|
|
37
|
+
padding: 24px 16px 40px;
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/ng-add/files/src/app/main/account-profile/account-profile.component.spec.ts.template
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Injectable, signal } from '@angular/core';
|
|
2
|
+
import { MatDialog } from '@angular/material/dialog';
|
|
3
|
+
import { provideRouter } from '@angular/router';
|
|
4
|
+
import { render, screen } from '@testing-library/angular';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
import { of } from 'rxjs';
|
|
7
|
+
import { provideAppMocks } from 'src/app/core/testing/app-mocks';
|
|
8
|
+
import { AuthLoggedInMockDB } from 'src/app/core/store/auth/auth.mock';
|
|
9
|
+
import { AuthStore } from 'src/app/core/store/auth/auth.store';
|
|
10
|
+
import { USER_DB } from 'src/app/core/store/user/user.mock';
|
|
11
|
+
import { AccountProfileComponent } from './account-profile.component';
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
class GuestAuthMockDB extends AuthLoggedInMockDB {
|
|
15
|
+
override afUser = signal({
|
|
16
|
+
uid: USER_DB[0].__id,
|
|
17
|
+
email: null,
|
|
18
|
+
displayName: 'Guest',
|
|
19
|
+
photoURL: null,
|
|
20
|
+
isAnonymous: true,
|
|
21
|
+
emailVerified: false,
|
|
22
|
+
emailLinkEnabled: false,
|
|
23
|
+
providerIds: [],
|
|
24
|
+
});
|
|
25
|
+
override user = signal({ ...USER_DB[0], name: 'Guest' });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function setup(options: { guest?: boolean; dialogResult?: unknown } = {}) {
|
|
29
|
+
const user = userEvent.setup();
|
|
30
|
+
const dialog = {
|
|
31
|
+
open: jest.fn().mockReturnValue({ afterClosed: () => of(options.dialogResult) }),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
await render(AccountProfileComponent, {
|
|
35
|
+
providers: [
|
|
36
|
+
provideRouter([]),
|
|
37
|
+
{
|
|
38
|
+
provide: AuthStore,
|
|
39
|
+
useClass: options.guest ? GuestAuthMockDB : AuthLoggedInMockDB,
|
|
40
|
+
},
|
|
41
|
+
{ provide: MatDialog, useValue: dialog },
|
|
42
|
+
...provideAppMocks({ disableLatency: true }),
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return { user, dialog };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
describe('AccountProfileComponent', () => {
|
|
50
|
+
it('renders the page shell and all applicable account cards', async () => {
|
|
51
|
+
await setup();
|
|
52
|
+
|
|
53
|
+
expect(screen.getByText('<%= classify(project) %>')).toBeVisible();
|
|
54
|
+
expect(screen.getByRole('heading', { name: /Profile & Account Settings/i })).toBeVisible();
|
|
55
|
+
expect(screen.getByRole('heading', { name: /Profile Details/i })).toBeVisible();
|
|
56
|
+
expect(screen.getByRole('heading', { name: /Sign-In Methods/i })).toBeVisible();
|
|
57
|
+
expect(screen.queryByRole('heading', { name: /Delete Guest Account/i })).not.toBeInTheDocument();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('coordinates Save progress by focusing the sign-in card email field', async () => {
|
|
61
|
+
const { user } = await setup({ guest: true, dialogResult: 'save' });
|
|
62
|
+
const emailInput = screen.getByRole('textbox', { name: /Email Address/i });
|
|
63
|
+
|
|
64
|
+
await user.click(screen.getByRole('button', { name: /Delete guest account/i }));
|
|
65
|
+
|
|
66
|
+
expect(emailInput).toHaveFocus();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { NavbarComponent } from 'src/app/shared/navbar/navbar.component';
|
|
3
|
+
import { DeleteGuestCardComponent } from './delete-guest-card/delete-guest-card.component';
|
|
4
|
+
import { ProfileDetailsCardComponent } from './profile-details-card/profile-details-card.component';
|
|
5
|
+
import { SignInMethodsCardComponent } from './sign-in-methods-card/sign-in-methods-card.component';
|
|
6
|
+
|
|
7
|
+
/** Route-level shell for the profile and account settings cards. */
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'app-account-profile',
|
|
10
|
+
templateUrl: './account-profile.component.html',
|
|
11
|
+
styleUrl: './account-profile.component.scss',
|
|
12
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
13
|
+
imports: [
|
|
14
|
+
NavbarComponent,
|
|
15
|
+
ProfileDetailsCardComponent,
|
|
16
|
+
SignInMethodsCardComponent,
|
|
17
|
+
DeleteGuestCardComponent,
|
|
18
|
+
],
|
|
19
|
+
})
|
|
20
|
+
export class AccountProfileComponent {}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@if (session()?.isAnonymous) {
|
|
2
|
+
<section class="card-section danger-zone" aria-labelledby="delete-guest-heading">
|
|
3
|
+
<h2 id="delete-guest-heading">Delete Guest Account</h2>
|
|
4
|
+
<p>Guest progress cannot be recovered after deletion.</p>
|
|
5
|
+
<button
|
|
6
|
+
mat-button
|
|
7
|
+
color="warn"
|
|
8
|
+
type="button"
|
|
9
|
+
[disabled]="isDeleting()"
|
|
10
|
+
(click)="deleteGuest()"
|
|
11
|
+
>
|
|
12
|
+
@if (isDeleting()) {
|
|
13
|
+
<mat-spinner diameter="18" class="button-spinner" />
|
|
14
|
+
<span>Deleting guest account…</span>
|
|
15
|
+
} @else {
|
|
16
|
+
<span>Delete guest account</span>
|
|
17
|
+
}
|
|
18
|
+
</button>
|
|
19
|
+
|
|
20
|
+
@if (errorMessage()) {
|
|
21
|
+
<div class="error-message" role="alert" aria-live="assertive">{{ errorMessage() }}</div>
|
|
22
|
+
}
|
|
23
|
+
</section>
|
|
24
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: contents;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.card-section {
|
|
6
|
+
margin-bottom: 24px;
|
|
7
|
+
padding: 28px 32px;
|
|
8
|
+
border: 1px solid #fecaca;
|
|
9
|
+
border-radius: 20px;
|
|
10
|
+
background: #fff5f5;
|
|
11
|
+
box-shadow:
|
|
12
|
+
0 10px 30px -10px rgba(79, 70, 229, 0.1),
|
|
13
|
+
0 4px 12px rgba(0, 0, 0, 0.03);
|
|
14
|
+
|
|
15
|
+
h2 {
|
|
16
|
+
margin: 0 0 20px;
|
|
17
|
+
color: #991b1b;
|
|
18
|
+
font-size: 1.25rem;
|
|
19
|
+
font-weight: 700;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
p {
|
|
23
|
+
margin: 0 0 16px;
|
|
24
|
+
color: #7f1d1d;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
button {
|
|
29
|
+
mat-spinner {
|
|
30
|
+
display: inline-block;
|
|
31
|
+
margin-right: 8px;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.error-message {
|
|
36
|
+
margin-top: 16px;
|
|
37
|
+
padding: 12px 14px;
|
|
38
|
+
border: 1px solid #fca5a5;
|
|
39
|
+
border-radius: 12px;
|
|
40
|
+
background: #fef2f2;
|
|
41
|
+
color: #b91c1c;
|
|
42
|
+
font-size: 0.9rem;
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@media (max-width: 640px) {
|
|
47
|
+
.card-section {
|
|
48
|
+
padding: 20px;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Injectable, signal } from '@angular/core';
|
|
2
|
+
import { MatDialog } from '@angular/material/dialog';
|
|
3
|
+
import { render, screen } from '@testing-library/angular';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import { of } from 'rxjs';
|
|
6
|
+
import { provideAppMocks } from 'src/app/core/testing/app-mocks';
|
|
7
|
+
import { AuthLoggedInMockDB } from 'src/app/core/store/auth/auth.mock';
|
|
8
|
+
import { AuthStore } from 'src/app/core/store/auth/auth.store';
|
|
9
|
+
import { USER_DB } from 'src/app/core/store/user/user.mock';
|
|
10
|
+
import { DeleteGuestCardComponent } from './delete-guest-card.component';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
class GuestAuthMockDB extends AuthLoggedInMockDB {
|
|
14
|
+
override afUser = signal({
|
|
15
|
+
uid: USER_DB[0].__id,
|
|
16
|
+
email: null,
|
|
17
|
+
displayName: 'Guest',
|
|
18
|
+
photoURL: null,
|
|
19
|
+
isAnonymous: true,
|
|
20
|
+
emailVerified: false,
|
|
21
|
+
emailLinkEnabled: false,
|
|
22
|
+
providerIds: [],
|
|
23
|
+
});
|
|
24
|
+
override user = signal({ ...USER_DB[0], name: 'Guest' });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function setup(dialogResult: unknown, onSaveProgress = jest.fn()) {
|
|
28
|
+
const user = userEvent.setup();
|
|
29
|
+
const dialog = {
|
|
30
|
+
open: jest.fn().mockReturnValue({ afterClosed: () => of(dialogResult) }),
|
|
31
|
+
};
|
|
32
|
+
const view = await render(DeleteGuestCardComponent, {
|
|
33
|
+
providers: [
|
|
34
|
+
{ provide: AuthStore, useClass: GuestAuthMockDB },
|
|
35
|
+
{ provide: MatDialog, useValue: dialog },
|
|
36
|
+
...provideAppMocks({ disableLatency: true }),
|
|
37
|
+
],
|
|
38
|
+
on: { saveProgressRequested: onSaveProgress },
|
|
39
|
+
});
|
|
40
|
+
const auth = view.fixture.debugElement.injector.get(AuthStore);
|
|
41
|
+
|
|
42
|
+
return { user, auth, dialog, onSaveProgress };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
describe('DeleteGuestCardComponent', () => {
|
|
46
|
+
it('emits a save-progress request without deleting the account', async () => {
|
|
47
|
+
const { user, auth, onSaveProgress } = await setup('save');
|
|
48
|
+
const deleteSpy = jest.spyOn(auth, 'deleteAnonymousAccount');
|
|
49
|
+
|
|
50
|
+
await user.click(screen.getByRole('button', { name: /Delete guest account/i }));
|
|
51
|
+
|
|
52
|
+
expect(onSaveProgress).toHaveBeenCalled();
|
|
53
|
+
expect(deleteSpy).not.toHaveBeenCalled();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('shows a retryable error when account deletion fails', async () => {
|
|
57
|
+
const { user, auth } = await setup(true);
|
|
58
|
+
jest.spyOn(auth, 'deleteAnonymousAccount').mockRejectedValue(new Error('delete failed'));
|
|
59
|
+
|
|
60
|
+
await user.click(screen.getByRole('button', { name: /Delete guest account/i }));
|
|
61
|
+
|
|
62
|
+
expect(await screen.findByRole('alert')).toHaveTextContent(/could not delete the guest account/i);
|
|
63
|
+
expect(screen.getByRole('button', { name: /Delete guest account/i })).toBeEnabled();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject, output, signal } from '@angular/core';
|
|
2
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
3
|
+
import { MatDialog } from '@angular/material/dialog';
|
|
4
|
+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
5
|
+
import { firstValueFrom } from 'rxjs';
|
|
6
|
+
import { AuthStore } from 'src/app/core/store/auth/auth.store';
|
|
7
|
+
import { GuestDeletionDialogComponent } from '../guest-deletion-dialog.component';
|
|
8
|
+
|
|
9
|
+
/** Owns the anonymous-account deletion confirmation and failure state. */
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'app-delete-guest-card',
|
|
12
|
+
templateUrl: './delete-guest-card.component.html',
|
|
13
|
+
styleUrl: './delete-guest-card.component.scss',
|
|
14
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
15
|
+
imports: [MatButtonModule, MatProgressSpinnerModule],
|
|
16
|
+
})
|
|
17
|
+
export class DeleteGuestCardComponent {
|
|
18
|
+
private readonly authStore = inject(AuthStore);
|
|
19
|
+
private readonly dialog = inject(MatDialog);
|
|
20
|
+
|
|
21
|
+
// --------------- INPUTS AND OUTPUTS ------------------
|
|
22
|
+
|
|
23
|
+
readonly saveProgressRequested = output<void>();
|
|
24
|
+
|
|
25
|
+
// --------------- LOCAL UI STATE ----------------------
|
|
26
|
+
|
|
27
|
+
readonly isDeleting = signal(false);
|
|
28
|
+
readonly errorMessage = signal<string | null>(null);
|
|
29
|
+
|
|
30
|
+
// --------------- COMPUTED DATA -----------------------
|
|
31
|
+
|
|
32
|
+
readonly session = this.authStore.afUser;
|
|
33
|
+
|
|
34
|
+
// --------------- EVENT HANDLING ----------------------
|
|
35
|
+
|
|
36
|
+
async deleteGuest(): Promise<void> {
|
|
37
|
+
if (this.isDeleting()) return;
|
|
38
|
+
|
|
39
|
+
const result = await firstValueFrom(
|
|
40
|
+
this.dialog.open(GuestDeletionDialogComponent).afterClosed(),
|
|
41
|
+
);
|
|
42
|
+
if (result === 'save') {
|
|
43
|
+
this.saveProgressRequested.emit();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!result) return;
|
|
47
|
+
|
|
48
|
+
this.isDeleting.set(true);
|
|
49
|
+
this.errorMessage.set(null);
|
|
50
|
+
try {
|
|
51
|
+
await this.authStore.deleteAnonymousAccount();
|
|
52
|
+
} catch {
|
|
53
|
+
this.errorMessage.set(
|
|
54
|
+
'We could not delete the guest account. Nothing was signed out; please try again.',
|
|
55
|
+
);
|
|
56
|
+
this.isDeleting.set(false);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
package/src/ng-add/files/src/app/main/account-profile/guest-deletion-dialog.component.ts.template
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
3
|
+
import { MatDialogModule } from '@angular/material/dialog';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Confirmation dialog presented to anonymous/guest users before account deletion.
|
|
7
|
+
*
|
|
8
|
+
* Offers three actions:
|
|
9
|
+
* - `false`: Cancel deletion.
|
|
10
|
+
* - `true`: Proceed with permanent backend deletion of guest data and auth user.
|
|
11
|
+
* - `'save'`: Divert to linking Google or Email magic link to preserve progress.
|
|
12
|
+
*/
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'app-guest-deletion-dialog',
|
|
15
|
+
template: `
|
|
16
|
+
<h2 mat-dialog-title>Delete guest account?</h2>
|
|
17
|
+
<mat-dialog-content>
|
|
18
|
+
All guest progress will be permanently deleted and cannot be recovered. You can link Google or an email address to save your progress instead.
|
|
19
|
+
</mat-dialog-content>
|
|
20
|
+
<mat-dialog-actions align="end">
|
|
21
|
+
<button mat-button class="btn-cancel" [mat-dialog-close]="false">Cancel</button>
|
|
22
|
+
<button mat-flat-button class="btn-delete" [mat-dialog-close]="true">Delete account</button>
|
|
23
|
+
<button mat-flat-button class="btn-save" [mat-dialog-close]="'save'">Save progress</button>
|
|
24
|
+
</mat-dialog-actions>
|
|
25
|
+
`,
|
|
26
|
+
styles: [`
|
|
27
|
+
.btn-delete {
|
|
28
|
+
background-color: #dc2626 !important;
|
|
29
|
+
color: #ffffff !important;
|
|
30
|
+
font-weight: 600 !important;
|
|
31
|
+
border-radius: 12px !important;
|
|
32
|
+
margin-right: 8px;
|
|
33
|
+
}
|
|
34
|
+
.btn-delete:hover {
|
|
35
|
+
background-color: #b91c1c !important;
|
|
36
|
+
}
|
|
37
|
+
.btn-save {
|
|
38
|
+
background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
|
|
39
|
+
color: #ffffff !important;
|
|
40
|
+
font-weight: 600 !important;
|
|
41
|
+
border-radius: 12px !important;
|
|
42
|
+
}
|
|
43
|
+
.btn-cancel {
|
|
44
|
+
border-radius: 12px !important;
|
|
45
|
+
font-weight: 600 !important;
|
|
46
|
+
}
|
|
47
|
+
`],
|
|
48
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
49
|
+
imports: [MatButtonModule, MatDialogModule],
|
|
50
|
+
})
|
|
51
|
+
export class GuestDeletionDialogComponent {}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<section class="card-section" aria-labelledby="profile-details-heading">
|
|
2
|
+
<h2 id="profile-details-heading">Profile Details</h2>
|
|
3
|
+
|
|
4
|
+
<form (submit)="updateProfile(); $event.preventDefault()">
|
|
5
|
+
<div class="avatar-preview-container">
|
|
6
|
+
@if (currentUser()?.photoURL) {
|
|
7
|
+
<img [src]="currentUser()?.photoURL" alt="Profile avatar" class="avatar-img" />
|
|
8
|
+
} @else {
|
|
9
|
+
<div class="avatar-placeholder" aria-hidden="true">
|
|
10
|
+
{{ (currentUser()?.name || 'P').charAt(0).toUpperCase() }}
|
|
11
|
+
</div>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
<div class="avatar-info">
|
|
15
|
+
<span class="user-name-text">{{ currentUser()?.name || 'Guest User' }}</span>
|
|
16
|
+
@if (session()?.email) {
|
|
17
|
+
<span class="user-email-subtext">{{ session()?.email }}</span>
|
|
18
|
+
} @else if (session()?.isAnonymous) {
|
|
19
|
+
<span class="user-email-subtext">Guest Account</span>
|
|
20
|
+
}
|
|
21
|
+
@if (currentUser()?.isAdmin) {
|
|
22
|
+
<span class="user-role-badge">Admin</span>
|
|
23
|
+
}
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<mat-form-field appearance="outline" class="full-width">
|
|
28
|
+
<mat-label>Display Name</mat-label>
|
|
29
|
+
<input matInput [formField]="profileForm.name" placeholder="Your display name" />
|
|
30
|
+
@if (profileForm.name().touched() && profileForm.name().invalid()) {
|
|
31
|
+
<mat-error>Name is required.</mat-error>
|
|
32
|
+
}
|
|
33
|
+
</mat-form-field>
|
|
34
|
+
|
|
35
|
+
<button mat-flat-button class="save-btn" type="submit" [disabled]="isSaving()">
|
|
36
|
+
{{ isSaving() ? 'Saving profile…' : 'Save profile' }}
|
|
37
|
+
</button>
|
|
38
|
+
</form>
|
|
39
|
+
|
|
40
|
+
@if (message(); as message) {
|
|
41
|
+
<div
|
|
42
|
+
class="message-banner"
|
|
43
|
+
[class.message-error]="message.isError"
|
|
44
|
+
[attr.role]="message.isError ? 'alert' : 'status'"
|
|
45
|
+
aria-live="polite"
|
|
46
|
+
>
|
|
47
|
+
{{ message.text }}
|
|
48
|
+
</div>
|
|
49
|
+
}
|
|
50
|
+
</section>
|