Introduce a 4-step modal wizard on SenderPage for creating envelopes. Validate required fields, support optional skip, receiver management, PDF upload, and keyboard shortcuts. Persist wizard payload in sessionStorage via token-based bootstrap service and navigate to editor with bootstrapToken. Register bootstrap storage service in both client and server DI containers and add dedicated sender wizard styling.
55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using System.Text.Json;
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace EnvelopeGenerator.Server.Client.Services;
|
|
|
|
public sealed class CreateEnvelopeBootstrapStorageService(IJSRuntime jsRuntime)
|
|
{
|
|
private const string StorageKeyPrefix = "sender.createEnvelope.bootstrap.";
|
|
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
|
|
|
|
public async Task<string> StoreAsync(CreateEnvelopeBootstrapPayload payload)
|
|
{
|
|
var token = Guid.NewGuid().ToString("N");
|
|
var key = BuildStorageKey(token);
|
|
var json = JsonSerializer.Serialize(payload, JsonOptions);
|
|
await jsRuntime.InvokeVoidAsync("sessionStorage.setItem", key, json);
|
|
return token;
|
|
}
|
|
|
|
public async Task<CreateEnvelopeBootstrapPayload?> ConsumeAsync(string? token)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(token))
|
|
return null;
|
|
|
|
var key = BuildStorageKey(token);
|
|
var raw = await jsRuntime.InvokeAsync<string?>("sessionStorage.getItem", key);
|
|
await jsRuntime.InvokeVoidAsync("sessionStorage.removeItem", key);
|
|
|
|
if (string.IsNullOrWhiteSpace(raw))
|
|
return null;
|
|
|
|
try
|
|
{
|
|
return JsonSerializer.Deserialize<CreateEnvelopeBootstrapPayload>(raw, JsonOptions);
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static string BuildStorageKey(string token) => $"{StorageKeyPrefix}{token}";
|
|
}
|
|
|
|
public sealed record CreateEnvelopeBootstrapPayload(
|
|
string Title,
|
|
string Message,
|
|
int? EnvelopeTypeId,
|
|
string Language,
|
|
IReadOnlyList<CreateEnvelopeBootstrapReceiver> Receivers,
|
|
byte[]? DocumentBytes,
|
|
string? DocumentFileName);
|
|
|
|
public sealed record CreateEnvelopeBootstrapReceiver(string FullName, string EmailAddress);
|