Skip to content

Commit 7f5e0c1

Browse files
authored
Merge pull request #25 from GGrouppFoundation/feature/improve-date-steps
Feature/improve date steps
2 parents 0aabf42 + 11529be commit 7f5e0c1

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/Application/Application.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<InvariantGlobalization>false</InvariantGlobalization>
99
<RootNamespace>GGroupp.Internal.Timesheet</RootNamespace>
1010
<AssemblyName>GGroupp.Internal.Timesheet.Bot.Application</AssemblyName>
11-
<Version>1.5.1-preview.2</Version>
11+
<Version>1.5.1</Version>
1212
</PropertyGroup>
1313

1414
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Application' " />

src/Utility.Date.Get/TimesheetDateGetFlowStep.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace GGroupp.Internal.Timesheet;
99

1010
public static class TimesheetDateGetFlowStep
1111
{
12+
private const int DaySuggestionsCount = 7;
13+
1214
public static ChatFlow<TFlowState> AwaitTimesheetDate<TFlowState>(
1315
this ChatFlow<TFlowState> chatFlow, string propertyDisplayName, Func<TFlowState, DateOnly, TFlowState> mapFlowState)
1416
{
@@ -30,7 +32,7 @@ private static DateStepOption InnerCreateOptions<TFlowState>(IChatFlowContext<TF
3032
invalidDateText: "Не удалось распознать дату",
3133
DateOnly.FromDateTime(DateTime.Now),
3234
placeholder: "дд.мм.гг",
33-
suggestions: context.CreateSuggestions(7));
35+
suggestions: context.CreateSuggestions(DaySuggestionsCount));
3436

3537
private static string GetDateText(ITurnContext context)
3638
{
@@ -43,10 +45,15 @@ private static string GetDateText(ITurnContext context)
4345

4446
if (context.IsTelegramChannel())
4547
{
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)}");
4752
}
4853

4954
return textBuilder.ToString();
55+
56+
static string ToString(DateOnly date) => date.ToStringRussianCulture("dd.MM");
5057
}
5158

5259
private static IReadOnlyCollection<KeyValuePair<string, DateOnly>> CreateSuggestions(this ITurnContext context, int count)
@@ -61,6 +68,6 @@ private static IReadOnlyCollection<KeyValuePair<string, DateOnly>> CreateSuggest
6168

6269
static KeyValuePair<string, DateOnly> CreateSuggestion(DateOnly date)
6370
=>
64-
new(date.GetRussianCultureDayOfWeekName(), date);
71+
new(date.ToStringRussianCulture("ddd"), date);
6572
}
6673
}

src/Utility.Date.Get/TimesheetDateGetUIHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static string ToStringRussianCulture(this DateOnly date)
1515
=>
1616
date.ToString("d MMMM yyyy", RussianCultureInfo);
1717

18-
public static string GetRussianCultureDayOfWeekName(this DateOnly date)
18+
internal static string ToStringRussianCulture(this DateOnly date, string format)
1919
=>
20-
date.ToString("ddd", RussianCultureInfo);
20+
date.ToString(format, RussianCultureInfo);
2121
}

0 commit comments

Comments
 (0)