@@ -10,18 +10,75 @@ export class LeadNoteModalComponent implements OnInit {
1010 @Input ( ) scan : any ;
1111 @Input ( ) note : string ;
1212
13- constructor ( private modalCtrl : ModalController ) { }
13+ interestLevel : string = '' ;
14+ freeformNote : string = '' ;
15+ followUpActions = [
16+ { label : 'Send info' , emoji : '📧' , checked : false } ,
17+ { label : 'Demo' , emoji : '🎯' , checked : false } ,
18+ { label : 'Newsletter' , emoji : '📰' , checked : false } ,
19+ { label : 'Hiring' , emoji : '💼' , checked : false } ,
20+ { label : 'Partner' , emoji : '🤝' , checked : false } ,
21+ ] ;
22+
23+ constructor ( private modalCtrl : ModalController ) { }
24+
25+ ngOnInit ( ) : void {
26+ this . parseNote ( this . note || '' ) ;
27+ }
1428
1529 cancel ( ) {
16- return this . modalCtrl . dismiss ( { note : null } , 'cancel' ) ;
30+ return this . modalCtrl . dismiss ( { note : null } , 'cancel' ) ;
1731 }
1832
1933 confirm ( ) {
20- this . modalCtrl . dismiss ( { note : this . note } , 'save' ) ;
34+ const composed = this . composeNote ( ) ;
35+ this . modalCtrl . dismiss ( { note : composed } , 'save' ) ;
2136 }
2237
23- ngOnInit ( ) : void {
24- console . log ( this . scan , this . note ) ;
38+ /** Parse an existing note back into structured fields */
39+ private parseNote ( raw : string ) {
40+ if ( ! raw ) return ;
41+
42+ // Try to parse structured format
43+ const interestMatch = raw . match ( / I n t e r e s t : ( h o t | w a r m | c o l d ) / i) ;
44+ if ( interestMatch ) {
45+ this . interestLevel = interestMatch [ 1 ] . toLowerCase ( ) ;
46+ }
47+
48+ const followUpMatch = raw . match ( / F o l l o w - u p : ( .+ ) / i) ;
49+ if ( followUpMatch ) {
50+ const actions = followUpMatch [ 1 ] . split ( ', ' ) . map ( a => a . trim ( ) . toLowerCase ( ) ) ;
51+ this . followUpActions . forEach ( a => {
52+ a . checked = actions . includes ( a . label . toLowerCase ( ) ) ;
53+ } ) ;
54+ }
55+
56+ const notesMatch = raw . match ( / N o t e s : ( [ \s \S ] * ?) $ / m) ;
57+ if ( notesMatch ) {
58+ this . freeformNote = notesMatch [ 1 ] . trim ( ) ;
59+ } else if ( ! interestMatch && ! followUpMatch ) {
60+ // Legacy plain text note — put it all in freeform
61+ this . freeformNote = raw ;
62+ }
2563 }
2664
65+ /** Compose structured fields into a single note string */
66+ private composeNote ( ) : string {
67+ const parts : string [ ] = [ ] ;
68+
69+ if ( this . interestLevel ) {
70+ parts . push ( `Interest: ${ this . interestLevel } ` ) ;
71+ }
72+
73+ const selectedActions = this . followUpActions . filter ( a => a . checked ) . map ( a => a . label ) ;
74+ if ( selectedActions . length > 0 ) {
75+ parts . push ( `Follow-up: ${ selectedActions . join ( ', ' ) } ` ) ;
76+ }
77+
78+ if ( this . freeformNote ?. trim ( ) ) {
79+ parts . push ( `Notes: ${ this . freeformNote . trim ( ) } ` ) ;
80+ }
81+
82+ return parts . join ( '\n' ) ;
83+ }
2784}
0 commit comments