@@ -35,14 +35,21 @@ export type User = {
3535export class GridLiteDataService {
3636 private counter = 0 ;
3737
38- private firstNames = [ 'John' , 'Jane' , ' Bob', 'Alice ' , 'Charlie ' , 'Diana ' , 'Eve ' , 'Frank ' , 'Grace ' , 'Henry' ,
39- 'Ivy ', 'Jack ' , 'Kate ' , 'Liam ' , 'Mia ' , 'Noah ' , 'Olivia ' , 'Peter ' , 'Quinn' , 'Rachel' ] ;
38+ private maleFirstNames = [ 'John' , 'Bob' , 'Charlie ' , 'Frank ' , 'Henry ' , 'Jack ' , 'Liam ' , 'Noah ' , 'Peter' ] ;
39+ private femaleFirstNames = [ 'Jane ', 'Alice ' , 'Diana ' , 'Eve ' , 'Grace ' , 'Ivy ' , 'Kate ' , 'Mia' , 'Olivia ', 'Quinn' , 'Rachel' ] ;
4040 private lastNames = [ 'Smith' , 'Johnson' , 'Williams' , 'Brown' , 'Jones' , 'Garcia' , 'Miller' , 'Davis' ,
4141 'Rodriguez' , 'Martinez' , 'Wilson' , 'Anderson' , 'Taylor' , 'Thomas' , 'Moore' , 'Jackson' , 'White' , 'Harris' ] ;
4242 private productNames = [ 'Widget' , 'Gadget' , 'Doohickey' , 'Thingamajig' , 'Gizmo' , 'Contraption' ,
4343 'Device' , 'Tool' , 'Apparatus' , 'Instrument' , 'Machine' , 'Equipment' ] ;
4444 private priorities : ( 'Low' | 'Standard' | 'High' ) [ ] = [ 'Low' , 'Standard' , 'High' ] ;
4545
46+ private randomFirstName ( ) : { name : string ; gender : 'men' | 'women' } {
47+ const isMale = this . randomBoolean ( ) ;
48+ return isMale
49+ ? { name : this . randomElement ( this . maleFirstNames ) , gender : 'men' }
50+ : { name : this . randomElement ( this . femaleFirstNames ) , gender : 'women' } ;
51+ }
52+
4653 private randomInt ( min : number , max : number ) : number {
4754 return Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ;
4855 }
@@ -86,7 +93,7 @@ export class GridLiteDataService {
8693 }
8794
8895 createUserSimple ( ) : UserSimple {
89- const firstName = this . randomElement ( this . firstNames ) ;
96+ const { name : firstName } = this . randomFirstName ( ) ;
9097 const lastName = this . randomElement ( this . lastNames ) ;
9198 return {
9299 id : this . generateId ( ) ,
@@ -97,7 +104,7 @@ export class GridLiteDataService {
97104 }
98105
99106 createUser ( ) : User {
100- const firstName = this . randomElement ( this . firstNames ) ;
107+ const { name : firstName , gender } = this . randomFirstName ( ) ;
101108 const lastName = this . randomElement ( this . lastNames ) ;
102109 const email = `${ firstName . toLowerCase ( ) } .${ lastName . toLowerCase ( ) } @example.com` ;
103110
@@ -107,7 +114,7 @@ export class GridLiteDataService {
107114 lastName,
108115 age : this . randomInt ( 18 , 90 ) ,
109116 email,
110- avatar : `https://i.pravatar.cc/150?img= ${ this . randomInt ( 1 , 70 ) } ` ,
117+ avatar : `assets/images/ ${ gender } / ${ this . randomInt ( 1 , 70 ) } .jpg ` ,
111118 active : this . randomBoolean ( ) ,
112119 priority : this . randomElement ( this . priorities ) ,
113120 satisfaction : this . randomInt ( 0 , 5 ) ,
0 commit comments