From 1db88bc7a4b6e748b4a21a92acbb6b7017e0d9dd Mon Sep 17 00:00:00 2001 From: Toby Burns Date: Sat, 31 Aug 2024 22:28:33 -0400 Subject: [PATCH 1/2] Fixed loading bar for multiple screen sizes and clear form on succesful send --- Client/Pages/Contact.razor | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Client/Pages/Contact.razor b/Client/Pages/Contact.razor index 86bed01..3e9b24a 100644 --- a/Client/Pages/Contact.razor +++ b/Client/Pages/Contact.razor @@ -21,14 +21,24 @@ Validation="@(new EmailAddressAttribute() {ErrorMessage = "The email address is invalid"})" /> -
- +
+ @if (isSending) + { + +
+ +
+
+ } + + @if (isSending) { - + } - Send Email - + + + Send Email
@@ -40,7 +50,7 @@ -@code{ +@code{ bool isFormValid; bool isSending; string[] errors = { }; @@ -49,7 +59,6 @@ protected async Task SendCommunication() { - isSending = true; if (!isFormValid) { @@ -62,6 +71,10 @@ var severity = (((int)result.ResponseCode >= 200) && ((int)result.ResponseCode <= 299)) ? Severity.Success : Severity.Error; Snackbar.Add(result.Response, severity); + if (form!=null && (int)result.ResponseCode >= 200 && (int)result.ResponseCode <= 299) + { + await form.ResetAsync(); + } isSending = false; } } \ No newline at end of file From 636c6dc7dbdcb4d6dadf3841c2ff2df32b6959dd Mon Sep 17 00:00:00 2001 From: Toby Burns Date: Mon, 9 Sep 2024 17:14:38 -0400 Subject: [PATCH 2/2] Fix name of sender --- Shared/Contact/EmailSender.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Shared/Contact/EmailSender.cs b/Shared/Contact/EmailSender.cs index 46ed29f..e49ccaa 100644 --- a/Shared/Contact/EmailSender.cs +++ b/Shared/Contact/EmailSender.cs @@ -17,6 +17,7 @@ public class EmailSenderOptions [Required] [EmailAddress(ErrorMessage = "Invalid Email Address")] public string? ToAddress { get; set; } + public string? ToDisplayName { get; set; } public string? NoReplyAddress { get; set; } } @@ -29,7 +30,7 @@ public class EmailSender : ICommunicationSender public EmailSender(SmtpClient smtpClient, IOptions options) { _smtpClient = smtpClient; - _toAddress = new MailAddress(options.Value.ToAddress ?? ""); + _toAddress = new MailAddress(options.Value.ToAddress ?? "", options.Value.ToDisplayName ?? "TheToby"); _noReplyAddress = string.IsNullOrEmpty(options.Value.NoReplyAddress) ? _toAddress : new MailAddress(options.Value.NoReplyAddress); @@ -63,7 +64,7 @@ public async Task SendAsync(ContactRequest request) await _smtpClient.SendMailAsync(messageTo); var confirmationContent = $"This message is to confirm that an email has been sent to " + - $"{_toAddress.User} with the following content:\n\n{request.Content}"; + $"{_toAddress.DisplayName} with the following content:\n\n{request.Content}"; using MailMessage messageConfirmation = new(_noReplyAddress, fromAddress) { Subject = request.Subject,