Add recent receiver suggestions to wizard
Introduced a feature to display and apply recent receiver suggestions in the `CreateEnvelopeWizardPopup` component. Added a new section in step 2 to show recently used receivers, with loading and state management logic. Updated the `ReceiverService` to fetch suggestions from the backend API. Enhanced the UI with new styles for the suggestions section and improved localization support. Refactored state management to handle loading, resetting, and applying suggestions. Minor cleanup and adjustments to ensure proper state transitions.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using EnvelopeGenerator.Application.Common.Dto.Receiver;
|
||||
|
||||
namespace EnvelopeGenerator.Server.Client.Services;
|
||||
|
||||
@@ -26,4 +27,21 @@ public class ReceiverService(IHttpClientFactory httpClientFactory)
|
||||
var emails = await response.Content.ReadFromJsonAsync<List<string>>(JsonOptions, cancel);
|
||||
return emails ?? [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches recent receiver suggestions for the authenticated sender.
|
||||
/// Calls GET /api/EnvelopeReceiver/recent-suggestions?take={take}.
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<RecentReceiverSuggestionDto>> GetRecentReceiverSuggestionsAsync(int take = 5, CancellationToken cancel = default)
|
||||
{
|
||||
using var http = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||
var url = $"/api/EnvelopeReceiver/recent-suggestions?take={take}";
|
||||
var response = await http.GetAsync(url, cancel);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return [];
|
||||
|
||||
var suggestions = await response.Content.ReadFromJsonAsync<List<RecentReceiverSuggestionDto>>(JsonOptions, cancel);
|
||||
return suggestions ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user