@@ -16,24 +16,24 @@ export class YemotHandlerService extends BaseYemotHandlerService {
1616 await this . getUserByDidPhone ( ) ;
1717 this . logger . log ( `Processing call with ID: ${ this . call . callId } from phone: ${ this . call . phone } ` ) ;
1818 if ( await this . isPastReportingDeadline ( ) ) {
19- await this . hangupWithMessage ( 'המערכת סגורה. לא ניתן לדווח אחרי השעה תשע וחצי בבוקר. המשך יום טוב. ') ;
19+ await this . hangupWithMessageByKey ( 'SYSTEM.CLOSED ') ;
2020 return ;
2121 }
2222 const student = await this . getStudentByInput ( ) ;
2323 if ( ! student ) return ;
2424 const alreadyReported = await this . hasReportedToday ( student . id ) ;
2525 if ( alreadyReported ) {
26- await this . hangupWithMessage ( 'כבר דיווחת היום, לא ניתן לדווח פעמיים. ') ;
26+ await this . hangupWithMessageByKey ( 'STUDENT.ALREADY_REPORTED ') ;
2727 return ;
2828 }
2929 const transportation = await this . getTransportByInput ( ) ;
3030 if ( ! transportation ) return ;
3131 const isValid = await this . isDepartureTimeValid ( transportation ) ;
3232 if ( isValid ) {
3333 await this . createAbsenceRecord ( student , transportation ) ;
34- await this . hangupWithMessage ( 'דווח בהצלחה ') ;
34+ await this . hangupWithMessageByKey ( 'SYSTEM.REPORT_SUCCESS ') ;
3535 } else {
36- await this . hangupWithMessage ( 'יצאת מאוחר מידי המשך יום טוב ') ;
36+ await this . hangupWithMessageByKey ( 'SYSTEM.LATE_DEPARTURE ') ;
3737 }
3838 }
3939 private isPastReportingDeadline ( ) : boolean {
@@ -51,13 +51,13 @@ export class YemotHandlerService extends BaseYemotHandlerService {
5151 student = await this . getStudentByTz ( ) ;
5252
5353 if ( ! student ) {
54- await this . sendMessage ( 'מספר תעודת הזהות לא תקין נסי שוב ') ;
54+ await this . sendMessageByKey ( 'STUDENT.INVALID_TZ ') ;
5555 }
5656 }
5757 return student ;
5858 }
5959 private async getStudentByTz ( ) : Promise < Student > {
60- const tz = await this . askForInput ( 'הקישי מספר תעודת זהות ') ;
60+ const tz = await this . askForInputByKey ( 'STUDENT.TZ_PROMPT ') ;
6161 const student = await this . dataSource . getRepository ( Student ) . findOneBy ( {
6262 userId : this . user . id ,
6363 tz : tz ,
@@ -91,36 +91,24 @@ export class YemotHandlerService extends BaseYemotHandlerService {
9191 transportation = await this . getTransportByNum ( ) ;
9292
9393 if ( ! transportation ) {
94- await this . sendMessage ( ' מספר הסעה לא תקין, נסי שוב ') ;
94+ await this . sendMessageByKey ( 'TRANSPORT.INVALID_NUM ') ;
9595 }
9696 }
9797
9898 return transportation ;
9999 }
100100
101101 private async getTransportByNum ( ) : Promise < Transportation > {
102- const num = await this . askForInput ( 'הקישי מספר הסעה ') ;
102+ const num = await this . askForInputByKey ( 'TRANSPORT.NUM_PROMPT ') ;
103103 const transportation = await this . dataSource . getRepository ( Transportation ) . findOneBy ( {
104104 userId : this . user . id ,
105105 key : Number ( num ) ,
106106 } ) ;
107107 return transportation ;
108108 }
109109
110- private async isDepartureTimeValid ( transportation ) : Promise < boolean > {
111- let valid : boolean | null = null ;
112- while ( valid === null ) {
113- const message = `האם יצאת לדרך לפני השעה ${ transportation . departureTime } ? הקישי 1 - כן, 2 - לא` ;
114- const userInput = await this . askForInput ( message ) ;
115- if ( userInput === '1' ) {
116- valid = true ;
117- } else if ( userInput === '2' ) {
118- valid = false ;
119- } else {
120- await this . sendMessage ( 'הקשה לא תקינה, נא הקישי 1 או 2' ) ;
121- }
122- }
123- return valid ;
110+ private async isDepartureTimeValid ( transportation : Transportation ) : Promise < boolean > {
111+ return this . askConfirmation ( 'TRANSPORT.DEPARTURE_CONFIRM' , { departureTime : transportation . departureTime } ) ;
124112 }
125113
126114 private async createAbsenceRecord ( student : Student , transportation : Transportation ) {
@@ -130,7 +118,7 @@ export class YemotHandlerService extends BaseYemotHandlerService {
130118 studentReferenceId : student . id ,
131119 } ) ;
132120 if ( ! studentKlass ) {
133- await this . hangupWithMessage ( ' התלמידה אינה משויכת לכיתה. ') ;
121+ await this . hangupWithMessageByKey ( 'STUDENT.NO_CLASS ') ;
134122 return ;
135123 }
136124 const newAbsence = absenceRepo . create ( {
0 commit comments