Skip to content

Commit 0aabf42

Browse files
authored
Merge pull request #24 from GGrouppFoundation/feature/improve-date-step
Feature/improve date step
2 parents 1870ef1 + eebf5b8 commit 0aabf42

File tree

19 files changed

+156
-62
lines changed

19 files changed

+156
-62
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.1</Version>
11+
<Version>1.5.1-preview.2</Version>
1212
</PropertyGroup>
1313

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

src/DateTimesheet.Get/DateTimesheet.Get.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="EarlyFuncPack.Core.AsyncPipeline" Version="0.1.0" />
15-
<PackageReference Include="GGroupp.Infra.Bot.Builder.ChatFlow.Step.Date" Version="2.3.0" />
16-
<PackageReference Include="GGroupp.Infra.Bot.Builder.TurnContext.Extensions" Version="1.1.1" />
1715
<PackageReference Include="GGroupp.Internal.Timesheet.TimesheetSet.Get.InOut" Version="1.0.1" />
1816
<PackageReference Include="PrimeFuncPack.Core.Failure" Version="2.0.1" />
1917
<PackageReference Include="PrimeFuncPack.Primitives.Pipeline" Version="2.0.1" />
2018
</ItemGroup>
2119

20+
<ItemGroup>
21+
<ProjectReference Include="..\Utility.Date.Get\Utility.Date.Get.csproj" />
22+
</ItemGroup>
23+
2224
</Project>

src/DateTimesheet.Get/Step.Date.Get/DateGetFlowStep.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ internal static class DateGetFlowStep
88
internal static ChatFlow<DateTimesheetFlowState> GetDate(
99
this ChatFlow<DateTimesheetFlowState> chatFlow)
1010
=>
11-
chatFlow.AwaitDate(
12-
static _ => new(
13-
text: "Введите дату списания",
14-
confirmButtonText: "Выбрать",
15-
invalidDateText: "Не удалось распознать дату",
16-
DateOnly.FromDateTime(DateTime.Now)),
17-
static (context, date) => $"Дата: {context.EncodeTextWithStyle(date.ToStringRussianCulture(), BotTextStyle.Bold)}",
18-
static (state, date) => state with
19-
{
20-
Date = date
21-
});
11+
chatFlow.AwaitTimesheetDate("Дата", WithDate);
12+
13+
private static DateTimesheetFlowState WithDate(DateTimesheetFlowState state, DateOnly date)
14+
=>
15+
state with
16+
{
17+
Date = date
18+
};
2219
}

src/DateTimesheet.Get/Step.TimesheetSet.Get/TimesheetSetGetActivity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal static IActivity CreateActivity(IChatFlowContext<DateTimesheetFlowState
2222
{
2323
if (context.FlowState.Timesheets?.Count is not > 0)
2424
{
25-
return MessageFactory.Text("Нет списаний времени на указанную дату");
25+
return MessageFactory.Text($"Нет списаний времени на {context.FlowState.Date.ToStringRussianCulture()}");
2626
}
2727

2828
if (context.IsCardSupported())

src/DateTimesheet.Get/UITextHelper/UITextHelper.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
using System;
2-
using System.Globalization;
1+
using System.Globalization;
32

43
namespace GGroupp.Internal.Timesheet;
5-
4+
65
internal static class UITextHelper
76
{
87
private const char HourSymbol = 'ч';
@@ -13,10 +12,6 @@ static UITextHelper()
1312
=>
1413
RussianCultureInfo = CultureInfo.GetCultureInfo("ru-RU");
1514

16-
internal static string ToStringRussianCulture(this DateOnly date)
17-
=>
18-
date.ToString("d MMMM yyyy", RussianCultureInfo);
19-
2015
internal static string ToDurationStringRussianCulture(this decimal value, bool fixWidth = false)
2116
=>
2217
fixWidth

src/Timesheet.Create/Flow/Flow.CreateTimesheet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal static ChatFlow<Unit> CreateTimesheet(
1717
ITimesheetCreateFunc timesheetCreateFunc)
1818
=>
1919
chatFlow.Start(
20-
static () => new TimesheetCreateFlowStateJson())
20+
static () => new TimesheetCreateFlowState())
2121
.FindProject(
2222
botUserProvider,
2323
favoriteProjectSetGetFunc,

src/Timesheet.Create/FlowState/TimesheetCreateFlowStateJson.cs renamed to src/Timesheet.Create/FlowState/TimesheetCreateFlowState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace GGroupp.Internal.Timesheet;
66

7-
internal sealed record class TimesheetCreateFlowStateJson
7+
internal sealed record class TimesheetCreateFlowState
88
{
99
[JsonProperty("projectId")]
1010
public Guid ProjectId { get; init; }

src/Timesheet.Create/Step.Date.Get/DateGetFlowStep.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ namespace GGroupp.Internal.Timesheet;
55

66
internal static class DateGetFlowStep
77
{
8-
internal static ChatFlow<TimesheetCreateFlowStateJson> GetDate(
9-
this ChatFlow<TimesheetCreateFlowStateJson> chatFlow)
8+
internal static ChatFlow<TimesheetCreateFlowState> GetDate(
9+
this ChatFlow<TimesheetCreateFlowState> chatFlow)
1010
=>
11-
chatFlow.AwaitDate(
12-
static _ => new(
13-
text: "Введите дату списания",
14-
confirmButtonText: "Выбрать",
15-
invalidDateText: "Не удалось распознать дату",
16-
DateOnly.FromDateTime(DateTime.Now)),
17-
static (context, date) => $"Дата списания: {context.EncodeTextWithStyle(date.ToStringRussianCulture(), BotTextStyle.Bold)}",
18-
static (state, date) => state with
19-
{
20-
Date = date
21-
});
11+
chatFlow.AwaitTimesheetDate("Дата списания", WithDate);
12+
13+
private static TimesheetCreateFlowState WithDate(TimesheetCreateFlowState state, DateOnly date)
14+
=>
15+
state with
16+
{
17+
Date = date
18+
};
2219
}

src/Timesheet.Create/Step.Description.Get/DescriptionGetFlowStep.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using GGroupp.Infra.Bot.Builder;
33

44
namespace GGroupp.Internal.Timesheet;
@@ -7,15 +7,15 @@ internal static class DescriptionGetFlowStep
77
{
88
private const string SkipText = "Пропустить";
99

10-
internal static ChatFlow<TimesheetCreateFlowStateJson> GetDescription(
11-
this ChatFlow<TimesheetCreateFlowStateJson> chatFlow)
10+
internal static ChatFlow<TimesheetCreateFlowState> GetDescription(
11+
this ChatFlow<TimesheetCreateFlowState> chatFlow)
1212
=>
1313
chatFlow.AwaitText(
1414
GetStepOption,
1515
static (context, suggestion) => $"Описание: {context.EncodeTextWithStyle(suggestion, BotTextStyle.Bold)}",
1616
BindWithDescription);
1717

18-
private static ValueStepOption GetStepOption(IChatFlowContext<TimesheetCreateFlowStateJson> _)
18+
private static ValueStepOption GetStepOption(IChatFlowContext<TimesheetCreateFlowState> _)
1919
=>
2020
new(
2121
messageText: "Введите описание. Этот шаг можно пропустить",
@@ -27,7 +27,7 @@ private static ValueStepOption GetStepOption(IChatFlowContext<TimesheetCreateFlo
2727
}
2828
});
2929

30-
private static TimesheetCreateFlowStateJson BindWithDescription(TimesheetCreateFlowStateJson state, string description)
30+
private static TimesheetCreateFlowState BindWithDescription(TimesheetCreateFlowState state, string description)
3131
{
3232
if (string.Equals(description, SkipText, StringComparison.InvariantCultureIgnoreCase))
3333
{

src/Timesheet.Create/Step.HourValue.Get/HourValueGetFlowStep.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ internal static class HourValueGetFlowStep
99
{
1010
private const int MaxValue = 24;
1111

12-
internal static ChatFlow<TimesheetCreateFlowStateJson> GetHourValue(
13-
this ChatFlow<TimesheetCreateFlowStateJson> chatFlow)
12+
internal static ChatFlow<TimesheetCreateFlowState> GetHourValue(
13+
this ChatFlow<TimesheetCreateFlowState> chatFlow)
1414
=>
1515
chatFlow.AwaitValue(
1616
GetStepOption,
@@ -21,7 +21,7 @@ internal static ChatFlow<TimesheetCreateFlowStateJson> GetHourValue(
2121
ValueHours = value
2222
});
2323

24-
private static ValueStepOption GetStepOption(IChatFlowContext<TimesheetCreateFlowStateJson> context)
24+
private static ValueStepOption GetStepOption(IChatFlowContext<TimesheetCreateFlowState> context)
2525
=>
2626
new(
2727
messageText: "Введите время работы в часах",

0 commit comments

Comments
 (0)