11import * as admin from 'firebase-admin' ;
2- import { v4 as uuid } from 'uuid' ;
32
43import {
54 Account ,
@@ -54,19 +53,21 @@ export type UserTag =
5453
5554export type UserHitTag =
5655 | UserTag
57- | 'not-mentor'
58- | 'not-mentee'
5956 | 'not-tutor'
6057 | 'not-tutee'
58+ | 'not-mentor'
59+ | 'not-mentee'
60+ | 'not-parent'
6161 | 'not-vetted'
6262 | 'not-matched'
6363 | 'not-meeting' ;
6464
6565export const USER_TAGS : UserTag [ ] = [
66- 'mentor' ,
67- 'mentee' ,
6866 'tutor' ,
6967 'tutee' ,
68+ 'mentor' ,
69+ 'mentee' ,
70+ 'parent' ,
7071 'vetted' ,
7172 'matched' ,
7273 'meeting' ,
@@ -98,6 +99,7 @@ export function isSubjects(json: unknown): json is Subjects {
9899 * A user object (that is stored in their Firestore profile document by uID).
99100 * @typedef {Object } UserInterface
100101 * @extends AccountInterface
102+ * @property [age] - The user's age (mostly used for students).
101103 * @property orgs - An array of the IDs of the orgs this user belongs to.
102104 * @property zooms - An array of Zoom user accounts. These are used when
103105 * creating Zoom meetings for a match. Each TB user can have multiple Zoom user
@@ -122,6 +124,7 @@ export function isSubjects(json: unknown): json is Subjects {
122124 * meetings).
123125 */
124126export interface UserInterface extends AccountInterface {
127+ age ?: number ;
125128 orgs : string [ ] ;
126129 zooms : ZoomUser [ ] ;
127130 availability : Availability ;
@@ -174,6 +177,7 @@ export type UserSearchHit = Omit<
174177export function isUserJSON ( json : unknown ) : json is UserJSON {
175178 if ( ! isAccountJSON ( json ) ) return false ;
176179 if ( ! isJSON ( json ) ) return false ;
180+ if ( json . age && typeof json . age !== 'number' ) return false ;
177181 if ( ! isStringArray ( json . orgs ) ) return false ;
178182 if ( ! isArray ( json . zooms , isZoomUserJSON ) ) return false ;
179183 if ( ! isAvailabilityJSON ( json . availability ) ) return false ;
@@ -198,6 +202,8 @@ export function isUserJSON(json: unknown): json is UserJSON {
198202 * @see {@link https://stackoverflow.com/a/54857125/10023158 }
199203 */
200204export class User extends Account implements UserInterface {
205+ public age ?: number ;
206+
201207 public orgs : string [ ] = [ ] ;
202208
203209 public zooms : ZoomUser [ ] = [ ] ;
@@ -259,13 +265,17 @@ export class User extends Account implements UserInterface {
259265 return parts [ parts . length - 1 ] ;
260266 }
261267
268+ public get subjects ( ) : string [ ] {
269+ const subjects = this . tutoring . subjects . concat ( this . mentoring . subjects ) ;
270+ return [ ...new Set < string > ( subjects ) ] ;
271+ }
272+
262273 public toPerson ( ) : Person {
263274 return {
264275 id : this . id ,
265276 name : this . name ,
266277 photo : this . photo ,
267278 roles : this . roles ,
268- handle : uuid ( ) ,
269279 } ;
270280 }
271281
0 commit comments