@@ -9,6 +9,8 @@ namespace GGroupp.Internal.Timesheet;
9
9
10
10
public static class TimesheetDateGetFlowStep
11
11
{
12
+ private const int DaySuggestionsCount = 7 ;
13
+
12
14
public static ChatFlow < TFlowState > AwaitTimesheetDate < TFlowState > (
13
15
this ChatFlow < TFlowState > chatFlow , string propertyDisplayName , Func < TFlowState , DateOnly , TFlowState > mapFlowState )
14
16
{
@@ -30,7 +32,7 @@ private static DateStepOption InnerCreateOptions<TFlowState>(IChatFlowContext<TF
30
32
invalidDateText : "Не удалось распознать дату" ,
31
33
DateOnly . FromDateTime ( DateTime . Now ) ,
32
34
placeholder : "дд.мм.гг" ,
33
- suggestions : context . CreateSuggestions ( 7 ) ) ;
35
+ suggestions : context . CreateSuggestions ( DaySuggestionsCount ) ) ;
34
36
35
37
private static string GetDateText ( ITurnContext context )
36
38
{
@@ -43,10 +45,15 @@ private static string GetDateText(ITurnContext context)
43
45
44
46
if ( context . IsTelegramChannel ( ) )
45
47
{
46
- textBuilder . Append ( ' ' ) . Append ( "или выберите день недели" ) ;
48
+ var lastDay = DateOnly . FromDateTime ( DateTime . Now ) ;
49
+ var firstDay = lastDay . AddDays ( 1 - DaySuggestionsCount ) ;
50
+
51
+ textBuilder . Append ( ' ' ) . Append ( $ "или выберите день недели с { ToString ( firstDay ) } по { ToString ( lastDay ) } ") ;
47
52
}
48
53
49
54
return textBuilder . ToString ( ) ;
55
+
56
+ static string ToString ( DateOnly date ) => date . ToStringRussianCulture ( "dd.MM" ) ;
50
57
}
51
58
52
59
private static IReadOnlyCollection < KeyValuePair < string , DateOnly > > CreateSuggestions ( this ITurnContext context , int count )
@@ -61,6 +68,6 @@ private static IReadOnlyCollection<KeyValuePair<string, DateOnly>> CreateSuggest
61
68
62
69
static KeyValuePair < string , DateOnly > CreateSuggestion ( DateOnly date )
63
70
=>
64
- new ( date . GetRussianCultureDayOfWeekName ( ) , date ) ;
71
+ new ( date . ToStringRussianCulture ( "ddd" ) , date ) ;
65
72
}
66
73
}
0 commit comments