@tech4good/angular-schematics 17.0.4 → 18.0.1

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.
Files changed (223) hide show
  1. package/README.md +8 -0
  2. package/package.json +4 -4
  3. package/src/collection.json +0 -16
  4. package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +22 -8
  5. package/src/component/index.js +2 -45
  6. package/src/component/index.js.map +1 -1
  7. package/src/component/schema.json +0 -5
  8. package/src/entity/files/__name@dasherize__/__name@dasherize__.mock.ts.template +12 -0
  9. package/src/entity/files/__name@dasherize__/__name@dasherize__.model.ts.template +1 -0
  10. package/src/entity/files/__name@dasherize__/__name@dasherize__.store.ts.template +41 -0
  11. package/src/entity/index.js +29 -50
  12. package/src/entity/index.js.map +1 -1
  13. package/src/init/files/.eslintrc.json.template +1 -1
  14. package/src/init/files/.firebaserc.template +8 -0
  15. package/src/init/files/.github/workflows/angular-github-ci.yml.template +1 -1
  16. package/src/init/files/README.md.template +13 -10
  17. package/src/init/files/angular.json.template +18 -11
  18. package/src/init/files/package.json.template +29 -30
  19. package/src/init/files/src/app/admin/{waitlist/waitlist.animations.ts.template → admin-panel/admin-panel.animations.ts.template} +1 -1
  20. package/src/init/files/src/app/admin/{waitlist/waitlist.component.html.template → admin-panel/admin-panel.component.html.template} +3 -3
  21. package/src/init/files/src/app/admin/{waitlist/waitlist.component.scss.template → admin-panel/admin-panel.component.scss.template} +1 -1
  22. package/src/init/files/src/app/admin/admin-panel/admin-panel.component.spec.ts.template +25 -0
  23. package/src/init/files/src/app/admin/admin-panel/admin-panel.component.ts.template +99 -0
  24. package/src/init/files/src/app/app.component.ts.template +12 -8
  25. package/src/init/files/src/app/app.config.ts.template +65 -0
  26. package/src/init/files/src/app/app.routes.ts.template +32 -0
  27. package/src/init/files/src/app/core/analytics/log.service.ts.template +122 -89
  28. package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +9 -17
  29. package/src/init/files/src/app/core/auth/auth.guard.ts.template +26 -23
  30. package/src/init/files/src/app/core/firebase/cached-listeners.service.ts.template +291 -0
  31. package/src/init/files/src/app/core/firebase/database.service.ts.template +56 -0
  32. package/src/init/files/src/app/core/firebase/firebase.mock.service.ts.template +276 -0
  33. package/src/init/files/src/app/core/firebase/firebase.service.ts.template +265 -215
  34. package/src/init/files/src/app/core/local-storage/session.service.ts.template +3 -4
  35. package/src/init/files/src/app/core/store/app.model.ts.template +19 -0
  36. package/src/init/files/src/app/core/store/app.store.ts.template +1074 -0
  37. package/src/init/files/src/app/core/store/auth/auth.mock.ts.template +20 -0
  38. package/src/init/files/src/app/core/store/auth/auth.store.ts.template +136 -0
  39. package/src/init/files/src/app/core/store/batch-write.firebase.service.ts.template +58 -0
  40. package/src/init/files/src/app/core/store/batch-write.mock.service.ts.template +105 -0
  41. package/src/init/files/src/app/core/store/batch-write.service.ts.template +126 -0
  42. package/src/init/files/src/app/core/store/user/user.mock.ts.template +24 -0
  43. package/src/init/files/src/app/core/store/user/user.model.ts.template +3 -6
  44. package/src/init/files/src/app/core/store/user/user.store.ts.template +41 -0
  45. package/src/init/files/src/app/core/store/user-context/user-context.mock.ts.template +24 -0
  46. package/src/init/files/src/app/core/store/user-context/user-context.model.ts.template +1 -0
  47. package/src/init/files/src/app/core/store/user-context/user-context.store.ts.template +41 -0
  48. package/src/init/files/src/app/core/utils/rand.utils.ts.template +13 -0
  49. package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.html.template +10 -14
  50. package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.scss.template +2 -2
  51. package/src/init/files/src/app/first-time/consent/consent.component.ts.template +95 -0
  52. package/src/init/files/src/app/first-time/early-access/early-access.animations.ts.template +4 -0
  53. package/src/init/files/src/app/first-time/early-access/early-access.component.html.template +65 -0
  54. package/src/init/files/src/app/{onboarding/waiting/waiting.component.scss.template → first-time/early-access/early-access.component.scss.template} +10 -3
  55. package/src/init/files/src/app/first-time/early-access/early-access.component.spec.ts.template +25 -0
  56. package/src/init/files/src/app/first-time/early-access/early-access.component.ts.template +254 -0
  57. package/src/init/files/src/app/first-time/early-access/early-access.model.ts.template +7 -0
  58. package/src/init/files/src/app/{general → first-time}/landing/landing.component.html.template +1 -1
  59. package/src/init/files/src/app/first-time/landing/landing.component.ts.template +44 -0
  60. package/src/init/files/src/app/first-time/login/login.component.html.template +10 -0
  61. package/src/init/files/src/app/first-time/login/login.component.ts.template +45 -0
  62. package/src/init/files/src/app/first-time/onboarding/onboarding.animations.ts.template +4 -0
  63. package/src/init/files/src/app/first-time/onboarding/onboarding.component.html.template +2 -0
  64. package/src/init/files/src/app/first-time/onboarding/onboarding.component.scss.template +5 -0
  65. package/src/init/files/src/app/{admin/waitlist/waitlist.component.spec.ts.template → first-time/onboarding/onboarding.component.spec.ts.template} +6 -6
  66. package/src/init/files/src/app/first-time/onboarding/onboarding.component.ts.template +41 -0
  67. package/src/init/files/src/app/main/home/home.component.html.template +6 -0
  68. package/src/init/files/src/app/{general → main}/home/home.component.scss.template +1 -0
  69. package/src/init/files/src/app/main/home/home.component.ts.template +55 -0
  70. package/src/init/files/src/app/shared/navbar/navbar.component.html.template +15 -0
  71. package/src/init/files/src/app/shared/navbar/navbar.component.scss.template +41 -0
  72. package/src/init/files/src/app/shared/navbar/navbar.component.spec.ts.template +25 -0
  73. package/src/init/files/src/app/shared/navbar/navbar.component.ts.template +40 -0
  74. package/src/init/files/src/app/shared/redeployment-warning/redeployment-warning.component.html.template +9 -0
  75. package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.ts.template +17 -6
  76. package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.service.ts.template +2 -2
  77. package/src/init/files/src/assets/images/close-x.svg +3 -0
  78. package/src/init/files/src/environments/environment.prod.ts.template +6 -2
  79. package/src/init/files/src/environments/environment.ts.template +4 -2
  80. package/src/init/files/src/index.html.template +1 -1
  81. package/src/init/files/src/styles.scss.template +4 -0
  82. package/src/init/files/tsconfig.json.template +0 -1
  83. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +0 -26
  84. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +0 -48
  85. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.model.ts.template +0 -0
  86. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +0 -20
  87. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.state.ts.template +0 -13
  88. package/src/container/files/__name@dasherize__/__name@dasherize__.animations.ts.template +0 -4
  89. package/src/container/files/__name@dasherize__/__name@dasherize__.component.html.template +0 -3
  90. package/src/container/files/__name@dasherize__/__name@dasherize__.component.scss.template +0 -5
  91. package/src/container/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +0 -25
  92. package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +0 -90
  93. package/src/container/index.d.ts +0 -2
  94. package/src/container/index.js +0 -127
  95. package/src/container/index.js.map +0 -1
  96. package/src/container/index_spec.d.ts +0 -1
  97. package/src/container/index_spec.js +0 -23
  98. package/src/container/index_spec.js.map +0 -1
  99. package/src/container/schema.json +0 -50
  100. package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -249
  101. package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
  102. package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
  103. package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
  104. package/src/entity/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
  105. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -270
  106. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
  107. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.model.ts.template +0 -3
  108. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
  109. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
  110. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
  111. package/src/entity-in-example/index.d.ts +0 -2
  112. package/src/entity-in-example/index.js +0 -141
  113. package/src/entity-in-example/index.js.map +0 -1
  114. package/src/entity-in-example/index_spec.d.ts +0 -1
  115. package/src/entity-in-example/index_spec.js +0 -23
  116. package/src/entity-in-example/index_spec.js.map +0 -1
  117. package/src/entity-in-example/schema.json +0 -45
  118. package/src/init/files/CHANGELOG.md.template +0 -10
  119. package/src/init/files/src/app/admin/admin-routing.module.ts.template +0 -17
  120. package/src/init/files/src/app/admin/admin.module.spec.ts.template +0 -13
  121. package/src/init/files/src/app/admin/admin.module.ts.template +0 -28
  122. package/src/init/files/src/app/admin/waitlist/+state/waitlist.actions.ts.template +0 -23
  123. package/src/init/files/src/app/admin/waitlist/+state/waitlist.effects.ts.template +0 -50
  124. package/src/init/files/src/app/admin/waitlist/+state/waitlist.model.ts.template +0 -0
  125. package/src/init/files/src/app/admin/waitlist/+state/waitlist.selectors.ts.template +0 -39
  126. package/src/init/files/src/app/admin/waitlist/+state/waitlist.state.ts.template +0 -13
  127. package/src/init/files/src/app/admin/waitlist/waitlist.component.ts.template +0 -141
  128. package/src/init/files/src/app/app-routing.module.ts.template +0 -26
  129. package/src/init/files/src/app/app.module.ts.template +0 -34
  130. package/src/init/files/src/app/core/core.module.ts.template +0 -75
  131. package/src/init/files/src/app/core/setup/firebase-setup.ts.template +0 -25
  132. package/src/init/files/src/app/core/setup/module-import-guard.ts.template +0 -5
  133. package/src/init/files/src/app/core/snackbar/snackbar.actions.ts.template +0 -24
  134. package/src/init/files/src/app/core/snackbar/snackbar.effects.ts.template +0 -41
  135. package/src/init/files/src/app/core/store/app-state/app-state.actions.ts.template +0 -249
  136. package/src/init/files/src/app/core/store/app-state/app-state.effects.ts.template +0 -131
  137. package/src/init/files/src/app/core/store/app-state/app-state.model.ts.template +0 -8
  138. package/src/init/files/src/app/core/store/app-state/app-state.reducer.spec.ts.template +0 -13
  139. package/src/init/files/src/app/core/store/app-state/app-state.reducer.ts.template +0 -51
  140. package/src/init/files/src/app/core/store/app-state/app-state.service.ts.template +0 -50
  141. package/src/init/files/src/app/core/store/app.actions.ts.template +0 -92
  142. package/src/init/files/src/app/core/store/app.effects.ts.template +0 -175
  143. package/src/init/files/src/app/core/store/app.reducer.ts.template +0 -36
  144. package/src/init/files/src/app/core/store/app.selectors.ts.template +0 -42
  145. package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +0 -77
  146. package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +0 -163
  147. package/src/init/files/src/app/core/store/auth/auth.reducer.spec.ts.template +0 -13
  148. package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +0 -26
  149. package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +0 -25
  150. package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +0 -405
  151. package/src/init/files/src/app/core/store/cached-selectors.service.ts.template +0 -376
  152. package/src/init/files/src/app/core/store/effects.helpers.ts.template +0 -66
  153. package/src/init/files/src/app/core/store/user/user.actions.ts.template +0 -248
  154. package/src/init/files/src/app/core/store/user/user.effects.ts.template +0 -148
  155. package/src/init/files/src/app/core/store/user/user.reducer.spec.ts.template +0 -13
  156. package/src/init/files/src/app/core/store/user/user.reducer.ts.template +0 -50
  157. package/src/init/files/src/app/core/store/user/user.service.ts.template +0 -50
  158. package/src/init/files/src/app/core/store/user-context/user-context.actions.ts.template +0 -248
  159. package/src/init/files/src/app/core/store/user-context/user-context.effects.ts.template +0 -131
  160. package/src/init/files/src/app/core/store/user-context/user-context.reducer.spec.ts.template +0 -13
  161. package/src/init/files/src/app/core/store/user-context/user-context.reducer.ts.template +0 -51
  162. package/src/init/files/src/app/core/store/user-context/user-context.service.ts.template +0 -50
  163. package/src/init/files/src/app/core/utils/string-case.utils.ts.template +0 -96
  164. package/src/init/files/src/app/general/general-routing.module.ts.template +0 -25
  165. package/src/init/files/src/app/general/general.module.spec.ts.template +0 -13
  166. package/src/init/files/src/app/general/general.module.ts.template +0 -36
  167. package/src/init/files/src/app/general/home/+state/home.actions.ts.template +0 -26
  168. package/src/init/files/src/app/general/home/+state/home.effects.ts.template +0 -48
  169. package/src/init/files/src/app/general/home/+state/home.model.ts.template +0 -0
  170. package/src/init/files/src/app/general/home/+state/home.selectors.ts.template +0 -20
  171. package/src/init/files/src/app/general/home/+state/home.state.ts.template +0 -13
  172. package/src/init/files/src/app/general/home/home.component.html.template +0 -5
  173. package/src/init/files/src/app/general/home/home.component.ts.template +0 -88
  174. package/src/init/files/src/app/general/landing/+state/landing.actions.ts.template +0 -26
  175. package/src/init/files/src/app/general/landing/+state/landing.effects.ts.template +0 -48
  176. package/src/init/files/src/app/general/landing/+state/landing.model.ts.template +0 -0
  177. package/src/init/files/src/app/general/landing/+state/landing.selectors.ts.template +0 -20
  178. package/src/init/files/src/app/general/landing/+state/landing.state.ts.template +0 -13
  179. package/src/init/files/src/app/general/landing/landing.component.ts.template +0 -98
  180. package/src/init/files/src/app/general/login/login.component.html.template +0 -11
  181. package/src/init/files/src/app/general/login/login.component.ts.template +0 -80
  182. package/src/init/files/src/app/onboarding/consent/+state/consent.actions.ts.template +0 -23
  183. package/src/init/files/src/app/onboarding/consent/+state/consent.effects.ts.template +0 -47
  184. package/src/init/files/src/app/onboarding/consent/+state/consent.model.ts.template +0 -0
  185. package/src/init/files/src/app/onboarding/consent/+state/consent.selectors.ts.template +0 -20
  186. package/src/init/files/src/app/onboarding/consent/+state/consent.state.ts.template +0 -13
  187. package/src/init/files/src/app/onboarding/consent/consent.component.ts.template +0 -151
  188. package/src/init/files/src/app/onboarding/onboarding-routing.module.ts.template +0 -19
  189. package/src/init/files/src/app/onboarding/onboarding.module.spec.ts.template +0 -13
  190. package/src/init/files/src/app/onboarding/onboarding.module.ts.template +0 -32
  191. package/src/init/files/src/app/onboarding/waiting/+state/waiting.actions.ts.template +0 -26
  192. package/src/init/files/src/app/onboarding/waiting/+state/waiting.effects.ts.template +0 -52
  193. package/src/init/files/src/app/onboarding/waiting/+state/waiting.model.ts.template +0 -9
  194. package/src/init/files/src/app/onboarding/waiting/+state/waiting.selectors.ts.template +0 -42
  195. package/src/init/files/src/app/onboarding/waiting/+state/waiting.state.ts.template +0 -13
  196. package/src/init/files/src/app/onboarding/waiting/waiting.animations.ts.template +0 -4
  197. package/src/init/files/src/app/onboarding/waiting/waiting.component.html.template +0 -57
  198. package/src/init/files/src/app/onboarding/waiting/waiting.component.spec.ts.template +0 -25
  199. package/src/init/files/src/app/onboarding/waiting/waiting.component.ts.template +0 -281
  200. package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.component.html.template +0 -10
  201. package/src/init/files/src/app/shared/shared.module.ts.template +0 -87
  202. package/src/init/files/src/main.ts.template +0 -12
  203. package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +0 -15
  204. package/src/module/files/__name@dasherize__/__name@dasherize__.module.spec.ts.template +0 -13
  205. package/src/module/files/__name@dasherize__/__name@dasherize__.module.ts.template +0 -24
  206. package/src/module/index.d.ts +0 -2
  207. package/src/module/index.js +0 -97
  208. package/src/module/index.js.map +0 -1
  209. package/src/module/index_spec.d.ts +0 -1
  210. package/src/module/index_spec.js +0 -23
  211. package/src/module/index_spec.js.map +0 -1
  212. package/src/module/schema.json +0 -38
  213. /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.animations.ts.template +0 -0
  214. /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.spec.ts.template +0 -0
  215. /package/src/init/files/src/app/{general → first-time}/landing/landing.animations.ts.template +0 -0
  216. /package/src/init/files/src/app/{general → first-time}/landing/landing.component.scss.template +0 -0
  217. /package/src/init/files/src/app/{general → first-time}/landing/landing.component.spec.ts.template +0 -0
  218. /package/src/init/files/src/app/{general → first-time}/login/login.component.scss.template +0 -0
  219. /package/src/init/files/src/app/{general → first-time}/login/login.component.spec.ts.template +0 -0
  220. /package/src/init/files/src/app/{general → main}/home/home.animations.ts.template +0 -0
  221. /package/src/init/files/src/app/{general → main}/home/home.component.spec.ts.template +0 -0
  222. /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.scss.template +0 -0
  223. /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.spec.ts.template +0 -0
@@ -0,0 +1,95 @@
1
+ import { Component, OnInit, ChangeDetectionStrategy, input, output, inject, WritableSignal, Signal, signal, computed, Inject, Injector } from '@angular/core';
2
+ import { ConsentAnimations } from './consent.animations';
3
+ import { Router } from '@angular/router';
4
+ import { User, AccessState } from 'src/app/core/store/user/user.model';
5
+ import { Location } from '@angular/common';
6
+ import { AuthStore } from 'src/app/core/store/auth/auth.store';
7
+ import { UserStore } from 'src/app/core/store/user/user.store';
8
+ import { MatSnackBar } from '@angular/material/snack-bar';
9
+ import { MatCheckbox } from '@angular/material/checkbox';
10
+ import { FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
11
+ import { BatchWriteService, BATCH_WRITE_SERVICE } from 'src/app/core/store/batch-write.service';
12
+ import { NavbarComponent } from 'src/app/shared/navbar/navbar.component';
13
+
14
+ @Component({
15
+ selector: 'app-consent',
16
+ templateUrl: './consent.component.html',
17
+ styleUrls: ['./consent.component.scss'],
18
+ changeDetection: ChangeDetectionStrategy.OnPush,
19
+ animations: ConsentAnimations,
20
+ standalone: true,
21
+ imports: [
22
+ ReactiveFormsModule,
23
+ NavbarComponent,
24
+ MatCheckbox,
25
+ ],
26
+ })
27
+ export class ConsentComponent implements OnInit {
28
+ readonly authStore = inject(AuthStore);
29
+ readonly userStore = inject(UserStore);
30
+
31
+ // --------------- INPUTS AND OUTPUTS ------------------
32
+
33
+ /** The current signed in user. */
34
+ currentUser: Signal<User> = this.authStore.user;
35
+
36
+ // --------------- LOCAL UI STATE ----------------------
37
+
38
+ /** Constants for onboarding templates. */
39
+ appName = 'APP_NAME [Causeway]';
40
+ shortProdDesc = 'PROD_DESC [provides users with opportunities to learn coding in real-world settings while contributing to non-profit causes]';
41
+ shortResearchDesc = 'RESEARCH_DESC [how to scale opportunities for experiential learning and support collaboration around social causes]';
42
+ authAppName = 'AUTH_APP_NAME [Google]';
43
+ protocolNumber = 'PROTOCOL_NO [HS-FY2022-254]';
44
+ protocolTitle = 'PROTOCOL_TITLE [Scaling Experiential Learning of Web Development]';
45
+ usageDataProductDesc = 'USAGE_DATA_PROD [help users learn and contribute to projects they are participating in. When you participate in a project, your task information, status, and code will be shared with the project team]';
46
+ usageDataResearchDesc = 'USAGE_DATA_RESEARCH [how to better support experiential learning online]';
47
+ studyDoingDesc = 'STUDY_DOING [When you participate in our study, you will use our platform to learn web development and contribute code to a platform. You will also fill out a survey on your experience, and optionally, participate in a follow-up interview]';
48
+ benefitsDesc = 'STUDY_BENEFITS [to learn web development and contribute to a project you care about]';
49
+ investigatorInfo = 'INVESTIGATOR_INFO [FirstName LastName, co-Principal Investigator, email@ucsc.edu]';
50
+ facultyInfo = 'FACULTY_INFO [David T. Lee, dlee105@ucsc.edu]';
51
+
52
+ /** Checkbox state used in form. */
53
+ checkForm = this.form.group({
54
+ checked: [false, Validators.requiredTrue],
55
+ });
56
+
57
+ /** Consent url. */
58
+ consentUrl: string;
59
+
60
+ // --------------- COMPUTED DATA -----------------------
61
+
62
+ // --------------- EVENT HANDLING ----------------------
63
+
64
+ /** Submit the consent form. */
65
+ async submit() {
66
+ try {
67
+ await this.userStore.update(this.currentUser().__id, {
68
+ accessState: AccessState.SUBMIT_INTEREST,
69
+ consented: true,
70
+ });
71
+ this.router.navigate(['/early-access']);
72
+ } catch (e) {
73
+ console.error(e);
74
+ this.snackBar.open('Failed to update consent status', '', { duration: 3000 });
75
+ }
76
+ }
77
+
78
+ // --------------- OTHER -------------------------------
79
+
80
+ constructor(
81
+ private router: Router,
82
+ private form: FormBuilder,
83
+ private snackBar: MatSnackBar,
84
+ private location: Location,
85
+ @Inject(BATCH_WRITE_SERVICE) private batch: BatchWriteService,
86
+ private injector: Injector,
87
+ ) {
88
+ }
89
+
90
+ // --------------- LOAD AND CLEANUP --------------------
91
+
92
+ ngOnInit() {
93
+ this.consentUrl = location.origin + '/' + this.location.prepareExternalUrl('consent');
94
+ }
95
+ }
@@ -0,0 +1,4 @@
1
+ import { trigger, group, query, animateChild, state, style, animate, transition } from '@angular/animations';
2
+
3
+ export const EarlyAccessAnimations = [
4
+ ];
@@ -0,0 +1,65 @@
1
+ <app-navbar></app-navbar>
2
+ @if (waitlistData(); as data) {
3
+ <div class="early-access-container">
4
+ <!-- Core questions on motivation and desired value -->
5
+ @if (data.currentUser.accessState === AccessState.SUBMIT_INTEREST && !loading()) {
6
+ <h1>Hello and Welcome!</h1>
7
+ <form [formGroup]="backgroundForm" (ngSubmit)="submitInterest()">
8
+ <div class="form-field-group">
9
+ <mat-label class="question">
10
+ Which of the following best describe your background and interest in {{ appName }}?
11
+ @if (backgroundForm.hasError('noneChecked') && (backgroundForm.touched || backgroundForm.dirty)) {
12
+ <mat-error class="checkbox-error">Please select one to help us understand your background</mat-error>
13
+ }
14
+ </mat-label>
15
+ <div class="checkbox-group" formArrayName="backgroundSelections">
16
+ @for (item of backgroundSelections.controls; track item.value.fieldName; let i = $index) {
17
+ <ng-container [formGroupName]="i">
18
+ <mat-checkbox formControlName="checked" [aria-label]="item.value.ariaLabel" (click)="check(item)">{{ item.value.label }}</mat-checkbox>
19
+ </ng-container>
20
+ }
21
+ </div>
22
+ </div>
23
+ @if (backgroundForm.contains('backgroundOther')) {
24
+ <div class="form-field-group">
25
+ <mat-label class="question">How would you describe your background and interest in {{ appName }}?</mat-label>
26
+ <mat-form-field class="background-other" appearance="fill">
27
+ <mat-label>Your background and interest</mat-label>
28
+ <input matInput name="backgroundOther" formControlName="backgroundOther" required>
29
+ @if (backgroundForm.hasError('needsOtherText') && (backgroundForm.touched || backgroundForm.dirty)) {
30
+ <mat-error>Can you elaborate on your selection of 'Other'?</mat-error>
31
+ }
32
+ </mat-form-field>
33
+ </div>
34
+ }
35
+ <div class="form-field-group">
36
+ <mat-label class="question">What do you hope to experience or get out of an application for {{ appArea }}?</mat-label>
37
+ <mat-form-field class="desired-value" appearance="fill">
38
+ <mat-label>Your ideal experience or outcomes</mat-label>
39
+ <textarea #text matInput formControlName="desiredValue" name="desiredValue" required></textarea>
40
+ @if (text.value?.length < 50) {
41
+ <mat-hint>You've shared {{text.value?.length || 0}} of 50 characters. If you could say a little more about your goals or why you decided to try it out, that'd help us! 🙏</mat-hint>
42
+ } @else {
43
+ <mat-hint>You're at {{text.value?.length}} characters! Telling us about your goals or why you decided to try it out helps us design the experience to better support you! 🙏</mat-hint>
44
+ }
45
+ </mat-form-field>
46
+ </div>
47
+ <button type="submit" class="btn continue-btn" [disabled]="backgroundForm.invalid">
48
+ Submit and Continue
49
+ <img src="https://icongr.am/feather/arrow-right.svg?size=20&color=B2B6C7">
50
+ </button>
51
+ </form>
52
+ } @else if (data.currentUser.accessState === AccessState.WAITING && !loading()) {
53
+ <!-- Waiting list position and path for going getting access early -->
54
+ @let position = positionText$ | async;
55
+ @let total = totalWaiting$ | async;
56
+ <h1>You are <span class="your-position">{{ position }}</span> of {{ total }} on the waitlist</h1>
57
+ <p>Thanks for signing up! We're hand-reviewing your response and personally onboarding our first 100 users to ensure that we can give you a delightful experience. We'll be in touch soon 😊</p>
58
+ <p>Also, we haven't had the chance to implement a formal referral system yet, but if you would love to get off the waitlist faster and can help us reach others, email {{ outreachLeadName }} at <a [href]="'mailto:' + outreachLeadEmail">{{ outreachLeadEmail }}</a> and let's talk about getting you early access!</p>
59
+ } @else if (loading()) {
60
+ <div class="loading-container">
61
+ Submitting... <mat-spinner [diameter]="20" [strokeWidth]="2"></mat-spinner>
62
+ </div>
63
+ }
64
+ </div>
65
+ }
@@ -1,7 +1,7 @@
1
- .waiting-container {
1
+ .early-access-container {
2
2
  align-items: stretch;
3
3
  width: 100%;
4
- height: 100%;
4
+ height: calc(100% - 70px);
5
5
  padding: 50px 100px;
6
6
  overflow-y: auto;
7
7
  color: #303030;
@@ -73,13 +73,19 @@
73
73
  flex-direction: column;
74
74
  align-items: flex-start;
75
75
 
76
+ .checkbox-error {
77
+ font-size: 0.75rem;
78
+ font-weight: 400;
79
+ }
80
+
76
81
  .form-field-group {
77
82
  display: flex;
78
83
  flex-direction: column;
84
+ width: 100%;
85
+ margin-bottom: 20px;
79
86
  .checkbox-group {
80
87
  display: flex;
81
88
  flex-direction: column;
82
- margin-bottom: 20px;
83
89
  }
84
90
 
85
91
  .question {
@@ -90,6 +96,7 @@
90
96
 
91
97
  button {
92
98
  cursor: pointer;
99
+ margin-top: 30px;
93
100
  }
94
101
  }
95
102
 
@@ -0,0 +1,25 @@
1
+ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { EarlyAccessComponent } from './early-access.component';
4
+
5
+ describe('EarlyAccessComponent', () => {
6
+ let component: EarlyAccessComponent;
7
+ let fixture: ComponentFixture<EarlyAccessComponent>;
8
+
9
+ beforeEach(waitForAsync(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [EarlyAccessComponent],
12
+ })
13
+ .compileComponents();
14
+ }));
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(EarlyAccessComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,254 @@
1
+ import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, computed, Inject, input, output, inject, signal, WritableSignal, Signal, Injector } from '@angular/core';
2
+ import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
3
+ import { Observable } from 'rxjs';
4
+ import { filter, mergeMap } from 'rxjs/operators';
5
+ import { EarlyAccessAnimations } from './early-access.animations';
6
+ import { WaitlistData } from './early-access.model';
7
+ import { User, AccessState } from 'src/app/core/store/user/user.model';
8
+ import { UserContext } from 'src/app/core/store/user-context/user-context.model';
9
+ import { Timestamp, serverTimestamp } from 'firebase/firestore';
10
+ import { FormBuilder, Validators, ValidatorFn, ValidationErrors, AbstractControl, FormGroup, FormArray, FormsModule, ReactiveFormsModule } from '@angular/forms';
11
+ import { MatSnackBar } from '@angular/material/snack-bar';
12
+ import { AuthStore } from 'src/app/core/store/auth/auth.store';
13
+ import { UserStore } from 'src/app/core/store/user/user.store';
14
+ import { UserContextStore } from 'src/app/core/store/user-context/user-context.store';
15
+ import { MatProgressSpinner } from '@angular/material/progress-spinner';
16
+ import { MatInput } from '@angular/material/input';
17
+ import { MatCheckbox } from '@angular/material/checkbox';
18
+ import { NgFor, AsyncPipe } from '@angular/common';
19
+ import { MatLabel, MatFormField, MatError, MatHint } from '@angular/material/form-field';
20
+ import { BatchWriteService, BATCH_WRITE_SERVICE } from 'src/app/core/store/batch-write.service';
21
+ import { NavbarComponent } from 'src/app/shared/navbar/navbar.component';
22
+
23
+ @Component({
24
+ selector: 'app-early-access',
25
+ templateUrl: './early-access.component.html',
26
+ styleUrls: ['./early-access.component.scss'],
27
+ changeDetection: ChangeDetectionStrategy.OnPush,
28
+ animations: EarlyAccessAnimations,
29
+ standalone: true,
30
+ imports: [
31
+ NavbarComponent,
32
+ FormsModule,
33
+ MatLabel,
34
+ ReactiveFormsModule,
35
+ NgFor,
36
+ MatCheckbox,
37
+ MatFormField,
38
+ MatInput,
39
+ MatHint,
40
+ MatError,
41
+ MatProgressSpinner,
42
+ AsyncPipe,
43
+ ],
44
+ })
45
+ export class EarlyAccessComponent implements OnInit {
46
+ readonly authStore = inject(AuthStore);
47
+ readonly userStore = inject(UserStore);
48
+ readonly userContextStore = inject(UserContextStore);
49
+
50
+ // --------------- INPUTS AND OUTPUTS ------------------
51
+
52
+ /** The current signed in user. */
53
+ currentUser: Signal<User> = this.authStore.user;
54
+
55
+ // --------------- LOCAL UI STATE ----------------------
56
+
57
+ /** Loading indicator. */
58
+ loading: WritableSignal<boolean> = signal(false);
59
+
60
+ // this allows the template to use the enum
61
+ AccessState = AccessState;
62
+
63
+ // Template constants
64
+ appName = 'APP_NAME [Causeway]';
65
+ appArea = 'APP_AREA [learning web development]';
66
+ outreachLeadName = 'OUTREACH_LEAD_NAME [FirstName LastName]';
67
+ outreachLeadEmail = 'OUTREACH_LEAD_EMAIL [email@ucsc.edu]';
68
+
69
+ /** One checkbox must be selected. If other is selected, the text needs to be filled out */
70
+ oneCheckedValidator: ValidatorFn = (
71
+ form: FormGroup,
72
+ ): ValidationErrors | null => {
73
+ const otherText = form.get('backgroundOther').value;
74
+ const selectionsArray = form.get('backgroundSelections') as FormArray;
75
+ const selected = selectionsArray.controls
76
+ .filter((item) => item.value.checked);
77
+
78
+ const needsOtherText = selectionsArray.controls.filter((item) => item.value.fieldName === 'other' && item.value.checked).length > 0 && otherText.trim().length === 0;
79
+
80
+ return selected.length === 0 || needsOtherText ? {
81
+ ...(selected.length === 0 ? { noneChecked: true } : {}),
82
+ ...(needsOtherText ? { needsOtherText } : {}),
83
+ }: null;
84
+ };
85
+
86
+ /** Form controls for early access survey. */
87
+ backgroundForm = this.form.group({
88
+ desiredValue: ['', Validators.minLength(50)],
89
+ backgroundOther: [{ value: '', disabled: true }, Validators.required],
90
+ backgroundSelections: this.form.array([
91
+ this.form.group({
92
+ fieldName: 'option1',
93
+ label: 'OPTION_1 [Student trying to get hands-on experience]',
94
+ ariaLabel: 'OPTION_1_AREA',
95
+ checked: false,
96
+ }),
97
+ this.form.group({
98
+ fieldName: 'option2',
99
+ label: 'OPTION_2 [Educator exploring new ways to teach]',
100
+ ariaLabel: 'OPTION_2_ARIA',
101
+ checked: false,
102
+ }),
103
+ this.form.group({
104
+ fieldName: 'option3',
105
+ label: 'OPTION_3 [Professional wanting to contribute to a cause]',
106
+ ariaLabel: 'OPTION_3_ARIA',
107
+ checked: false,
108
+ }),
109
+ this.form.group({
110
+ fieldName: 'other',
111
+ label: 'Other (none are a perfect fit)',
112
+ ariaLabel: 'Other',
113
+ checked: false,
114
+ })
115
+ ])
116
+ }, { validators: this.oneCheckedValidator });
117
+
118
+ /** Convenience getter for desiredValue. */
119
+ get desiredValue() {
120
+ return this.backgroundForm.get('desiredValue');
121
+ }
122
+
123
+ /** Convenience getter for backgroundOther. */
124
+ get backgroundOther() {
125
+ return this.backgroundForm.get('backgroundOther');
126
+ }
127
+
128
+ /** Getter for backgroundSelections form array with a type for use of controls. */
129
+ get backgroundSelections() {
130
+ return this.backgroundForm.get('backgroundSelections') as FormArray;
131
+ }
132
+
133
+ // --------------- COMPUTED DATA -----------------------
134
+
135
+ /** Waitlist data from app-state, user, and user-context. */
136
+ waitlistData: Signal<WaitlistData> = computed(() => {
137
+ const userContext = this.userContextStore.selectFirst([['__userId', '==', this.currentUser().__id]], {});
138
+ return { currentUser: this.currentUser(), userContext };
139
+ });
140
+
141
+ /** Waiting position number. */
142
+ positionText$: Observable<string> = toObservable(this.currentUser).pipe(
143
+ filter((user: User) => !!user.joinedWaitlistAt),
144
+ mergeMap(async (user) => {
145
+ const posNum = await this.userStore.count([
146
+ ['joinedWaitlistAt', '<=', user.joinedWaitlistAt],
147
+ ['accessState', '<', AccessState.DONE],
148
+ ], {});
149
+ return this.nth(posNum);
150
+ }),
151
+ );
152
+
153
+ /** Waiting position number. */
154
+ totalWaiting$: Observable<string> = toObservable(this.currentUser).pipe(
155
+ filter((user: User) => !!user.joinedWaitlistAt),
156
+ mergeMap(async (user) => {
157
+ const total = await this.userStore.count([
158
+ ['accessState', '<', AccessState.DONE],
159
+ ], {});
160
+ return `${total}`;
161
+ }),
162
+ );
163
+
164
+ /** Function for adding the appropriate suffix. */
165
+ nth(n: number): string {
166
+ switch (n % 10) {
167
+ case 1: return `${n}st`;
168
+ case 2: return `${n}nd`;
169
+ case 3: return `${n}rd`;
170
+ default: return `${n}th`;
171
+ }
172
+ }
173
+
174
+ /** Get all options that were selected. */
175
+ getSelections(): string[] {
176
+ return this.backgroundSelections.controls
177
+ .filter((item) => item.value.checked)
178
+ .map((item) => item.value.fieldName);
179
+ }
180
+
181
+ // --------------- EVENT HANDLING ----------------------
182
+
183
+ /**
184
+ * Enable and disable the backgroundOther text input depending on if other is checked.
185
+ * It is important that the form model is the source of truth not the template, so if we want
186
+ * the validation to go away when the input is no longer needed, it needs to be disabled on the model
187
+ * rather than just hidden from the view.
188
+ */
189
+ check(item) {
190
+ if (item.value.fieldName === 'other' && item.value.checked) {
191
+ this.backgroundForm.controls.backgroundOther.enable();
192
+ } else if (item.value.fieldName === 'other' && !item.value.checked) {
193
+ this.backgroundForm.controls.backgroundOther.disable();
194
+ }
195
+ }
196
+
197
+ /** Submit background and interests. */
198
+ async submitInterest() {
199
+ try {
200
+ await this.batch.batchWrite(async (batchConfig) => {
201
+ await this.userStore.update(this.waitlistData().currentUser.__id, {
202
+ accessState: AccessState.WAITING,
203
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
204
+ joinedWaitlistAt: Timestamp.now(),
205
+ }, { batchConfig });
206
+
207
+ if (this.waitlistData().userContext) {
208
+ this.userContextStore.update(this.waitlistData().userContext.__id, {
209
+ background: {
210
+ selections: this.getSelections(),
211
+ ...(this.backgroundOther.value ? { other: this.backgroundOther.value } : { }),
212
+ },
213
+ desiredValue: this.desiredValue.value,
214
+ }, { batchConfig });
215
+ } else {
216
+ this.userContextStore.add({
217
+ __userId: this.waitlistData().currentUser.__id,
218
+ background: {
219
+ selections: this.getSelections(),
220
+ ...(this.backgroundOther.value ? { other: this.backgroundOther.value } : { }),
221
+ },
222
+ desiredValue: this.desiredValue.value,
223
+ }, { batchConfig });
224
+ }
225
+ }, {
226
+ loading: this.loading,
227
+ snackBarConfig: {
228
+ successMessage: 'Submitted interest form!',
229
+ failureMessage: 'Failed to submit response',
230
+ undoOnAction: true,
231
+ config: { duration: 3000 },
232
+ },
233
+ });
234
+ } catch (e) {
235
+ console.error(e);
236
+ }
237
+ }
238
+
239
+ // --------------- OTHER -------------------------------
240
+
241
+ constructor(
242
+ private snackBar: MatSnackBar,
243
+ private form: FormBuilder,
244
+ @Inject(BATCH_WRITE_SERVICE) private batch: BatchWriteService,
245
+ private injector: Injector,
246
+ ) {
247
+ }
248
+
249
+ // --------------- LOAD AND CLEANUP --------------------
250
+
251
+ ngOnInit() {
252
+ this.userContextStore.load([['__userId', '==', this.currentUser().__id]], {});
253
+ }
254
+ }
@@ -0,0 +1,7 @@
1
+ import { User } from 'src/app/core/store/user/user.model';
2
+ import { UserContext } from 'src/app/core/store/user-context/user-context.model';
3
+
4
+ export interface WaitlistData {
5
+ currentUser: User;
6
+ userContext: UserContext;
7
+ }
@@ -1,3 +1,3 @@
1
1
  <div class="landing-container">
2
- <input type="submit" value="Sign up for early access" (click)="login$.next()">
2
+ <input type="submit" value="Sign up for early access" (click)="login()">
3
3
  </div>
@@ -0,0 +1,44 @@
1
+ import { Component, OnInit, ChangeDetectionStrategy, inject, Signal, Injector } from '@angular/core';
2
+ import { LandingAnimations } from './landing.animations';
3
+ import { User } from 'src/app/core/store/user/user.model';
4
+ import { AuthStore } from 'src/app/core/store/auth/auth.store';
5
+
6
+ @Component({
7
+ selector: 'app-landing',
8
+ templateUrl: './landing.component.html',
9
+ styleUrls: ['./landing.component.scss'],
10
+ changeDetection: ChangeDetectionStrategy.OnPush,
11
+ animations: LandingAnimations,
12
+ standalone: true,
13
+ })
14
+ export class LandingComponent implements OnInit {
15
+ readonly authStore = inject(AuthStore);
16
+
17
+ // --------------- INPUTS AND OUTPUTS ------------------
18
+
19
+ /** The current signed in user. */
20
+ currentUser: Signal<User> = this.authStore.user;
21
+
22
+ // --------------- LOCAL UI STATE ----------------------
23
+
24
+ // --------------- COMPUTED DATA -----------------------
25
+
26
+ // --------------- EVENT HANDLING ----------------------
27
+
28
+ /** Login the user. */
29
+ login() {
30
+ this.authStore.login('google.com');
31
+ }
32
+
33
+ // --------------- OTHER -------------------------------
34
+
35
+ constructor(
36
+ private injector: Injector,
37
+ ) {
38
+ }
39
+
40
+ // --------------- LOAD AND CLEANUP --------------------
41
+
42
+ ngOnInit() {
43
+ }
44
+ }
@@ -0,0 +1,10 @@
1
+ <div class="login-container">
2
+ @if (currentUser()) {
3
+ <img class="profile" [src]="currentUser().photoURL" referrerpolicy="no-referrer"/>
4
+ <h2>Hello {{currentUser().name}}!</h2>
5
+ <input type="submit" value="Logout" (click)="logout()">
6
+ } @else {
7
+ <h2>Hello!</h2>
8
+ <input type="submit" value="Login" (click)="login()">
9
+ }
10
+ </div>
@@ -0,0 +1,45 @@
1
+ import { inject, effect, Component, OnInit, ChangeDetectionStrategy, Signal } from '@angular/core';
2
+ import { User } from 'src/app/core/store/user/user.model';
3
+ import { AuthStore } from 'src/app/core/store/auth/auth.store';
4
+
5
+ @Component({
6
+ selector: 'app-login',
7
+ templateUrl: './login.component.html',
8
+ styleUrls: ['./login.component.scss'],
9
+ changeDetection: ChangeDetectionStrategy.OnPush,
10
+ standalone: true,
11
+ })
12
+ export class LoginComponent implements OnInit {
13
+ authStore = inject(AuthStore);
14
+
15
+ // --------------- INPUTS AND OUTPUTS ------------------
16
+
17
+ /** The current signed in user. */
18
+ currentUser: Signal<User> = this.authStore.user;
19
+
20
+ // --------------- LOCAL UI STATE ----------------------
21
+
22
+ // --------------- COMPUTED DATA -----------------------
23
+
24
+ // --------------- EVENT HANDLING ----------------------
25
+
26
+ /** Login the user. */
27
+ login() {
28
+ this.authStore.login('google.com', { doNotRoute: true });
29
+ }
30
+
31
+ /** Logout the user. */
32
+ logout() {
33
+ this.authStore.logout({ doNotRoute: true });
34
+ }
35
+
36
+ // --------------- OTHER -------------------------------
37
+
38
+ constructor() {
39
+ }
40
+
41
+ // --------------- LOAD AND CLEANUP --------------------
42
+
43
+ ngOnInit() {
44
+ }
45
+ }
@@ -0,0 +1,4 @@
1
+ import { trigger, group, query, animateChild, state, style, animate, transition } from '@angular/animations';
2
+
3
+ export const OnboardingAnimations = [
4
+ ];
@@ -0,0 +1,2 @@
1
+ <div class="onboarding-container">
2
+ </div>
@@ -0,0 +1,5 @@
1
+ :host {
2
+ display: block;
3
+ .onboarding-container {
4
+ }
5
+ }
@@ -1,20 +1,20 @@
1
1
  import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2
2
 
3
- import { WaitlistComponent } from './waitlist.component';
3
+ import { OnboardingComponent } from './onboarding.component';
4
4
 
5
- describe('WaitlistComponent', () => {
6
- let component: WaitlistComponent;
7
- let fixture: ComponentFixture<WaitlistComponent>;
5
+ describe('OnboardingComponent', () => {
6
+ let component: OnboardingComponent;
7
+ let fixture: ComponentFixture<OnboardingComponent>;
8
8
 
9
9
  beforeEach(waitForAsync(() => {
10
10
  TestBed.configureTestingModule({
11
- declarations: [WaitlistComponent],
11
+ declarations: [OnboardingComponent],
12
12
  })
13
13
  .compileComponents();
14
14
  }));
15
15
 
16
16
  beforeEach(() => {
17
- fixture = TestBed.createComponent(WaitlistComponent);
17
+ fixture = TestBed.createComponent(OnboardingComponent);
18
18
  component = fixture.componentInstance;
19
19
  fixture.detectChanges();
20
20
  });