Introduced a new feature to allow users to reject envelopes with an optional reason. Added a `RejectAsync` method in `AnnotationService` to handle rejection requests. Updated `ReceiverPage.razor` to include a "Reject" button in the PDF toolbar and a rejection popup for user input. Implemented state management for the rejection popup, including visibility, submission status, and validation messages. Updated `AnnotationController` to accept `envelopeKey` as a route parameter for the rejection endpoint. Modified `ReceiverClaimExtensions` to support multiple email claim types. Added new CSS styles for the "Reject" button, including hover effects and dark theme support. Enhanced error handling and logging for the rejection process.
50 lines
1.8 KiB
C#
50 lines
1.8 KiB
C#
using System.Net.Http;
|
|
using System.Net.Http.Json;
|
|
using System.Text.Json;
|
|
using EnvelopeGenerator.Server.Client.Models;
|
|
|
|
namespace EnvelopeGenerator.Server.Client.Services;
|
|
|
|
/// <summary>
|
|
/// Retrieves annotation positions from the API.
|
|
/// Uses relative paths (/api/Annotation/{envelopeKey}).
|
|
/// </summary>
|
|
[Obsolete("Use SignatureService.")]
|
|
public class AnnotationService(IHttpClientFactory httpClientFactory)
|
|
{
|
|
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
|
|
|
|
public async Task<IReadOnlyList<AnnotationDto>> GetAnnotationsAsync(string envelopeKey, CancellationToken cancel = default)
|
|
{
|
|
using var http = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
|
var url = $"/api/Annotation/{Uri.EscapeDataString(envelopeKey)}";
|
|
var response = await http.GetAsync(url, cancel);
|
|
|
|
if (!response.IsSuccessStatusCode)
|
|
return [];
|
|
|
|
var result = await response.Content.ReadFromJsonAsync<List<AnnotationDto>>(_jsonOptions, cancel);
|
|
return result ?? [];
|
|
}
|
|
|
|
public async Task RejectAsync(string envelopeKey, string? reason, CancellationToken cancel = default)
|
|
{
|
|
using var http = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
|
|
|
var response = await http.PostAsJsonAsync(
|
|
$"/api/Annotation/reject/{Uri.EscapeDataString(envelopeKey)}",
|
|
reason,
|
|
_jsonOptions,
|
|
cancel);
|
|
|
|
if (!response.IsSuccessStatusCode)
|
|
{
|
|
var body = await response.Content.ReadAsStringAsync(cancel);
|
|
throw new HttpRequestException(
|
|
$"Failed to reject envelope {envelopeKey}: {(int)response.StatusCode} {response.StatusCode} - {body}",
|
|
null,
|
|
response.StatusCode);
|
|
}
|
|
}
|
|
}
|