reset date to initial value when user attempts to change the date chosen

This commit is contained in:
Eugene Zadyra
2018-10-30 13:54:54 +01:00
parent bb3117250c
commit c096c8f44f

View File

@@ -147,8 +147,9 @@ class Book(val userId: UserId, bot: Bot, apiService: ApiService, dataService: Da
} onReply {
case Msg(CallbackCommand(Tags.FindTerms), _) =>
goto(requestTerm)
case Msg(CallbackCommand(Tags.ModifyDate), _) =>
goto(requestDateFrom)
case Msg(CallbackCommand(Tags.ModifyDate), bookingData) =>
goto(requestDateFrom) using bookingData.copy(dateFrom = ZonedDateTime.now(),
dateTo = ZonedDateTime.now().plusDays(1L))
}
private def requestTerm: Step =
@@ -182,8 +183,9 @@ class Book(val userId: UserId, bot: Bot, apiService: ApiService, dataService: Da
bot.sendMessage(userId.source, lang.noTermsFound, inlineKeyboard =
createInlineKeyboard(Seq(Button(lang.modifyDate, Tags.ModifyDate), Button(lang.createMonitoring, Tags.CreateMonitoring))))
} onReply {
case Msg(CallbackCommand(Tags.ModifyDate), _) =>
goto(requestDateFrom)
case Msg(CallbackCommand(Tags.ModifyDate), bookingData) =>
goto(requestDateFrom) using bookingData.copy(dateFrom = ZonedDateTime.now(),
dateTo = ZonedDateTime.now().plusDays(1L))
case Msg(CallbackCommand(Tags.CreateMonitoring), _) =>
goto(askMonitoringOptions)
}