feat(ideas): add idea creator, grant calls and applications
Implement the idea creator and application generator: idea status workflow, social canvas card, grant call windows with 409 when closed, and an LLM-backed idea assistant with offline fallback.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
namespace TarninaHub.Domain.Rules;
|
||||
|
||||
public static class ApplicationWindow
|
||||
{
|
||||
public const string Open = "open";
|
||||
|
||||
/// <summary>
|
||||
/// Applications are only allowed while the call is open and the current
|
||||
/// moment is within [opensAt, closesAt].
|
||||
/// </summary>
|
||||
public static bool IsOpen(string status, DateTimeOffset opensAt, DateTimeOffset closesAt, DateTimeOffset now) =>
|
||||
string.Equals(status, Open, StringComparison.Ordinal) && now >= opensAt && now <= closesAt;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using TarninaHub.Domain.Enums;
|
||||
|
||||
namespace TarninaHub.Domain.Rules;
|
||||
|
||||
public static class IdeaWorkflow
|
||||
{
|
||||
private static readonly IReadOnlyDictionary<IdeaStatus, IdeaStatus[]> Transitions =
|
||||
new Dictionary<IdeaStatus, IdeaStatus[]>
|
||||
{
|
||||
[IdeaStatus.Draft] = [IdeaStatus.Submitted],
|
||||
[IdeaStatus.Submitted] = [IdeaStatus.InReview],
|
||||
[IdeaStatus.InReview] = [IdeaStatus.Accepted, IdeaStatus.Rejected],
|
||||
[IdeaStatus.Accepted] = [],
|
||||
[IdeaStatus.Rejected] = [],
|
||||
};
|
||||
|
||||
public static bool CanTransition(IdeaStatus from, IdeaStatus to) =>
|
||||
from == to || Transitions[from].Contains(to);
|
||||
|
||||
public static bool IsTerminal(IdeaStatus status) =>
|
||||
Transitions[status].Length == 0;
|
||||
}
|
||||
Reference in New Issue
Block a user