diff --git a/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor b/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor index 8a79f5a2..e7ac649a 100644 --- a/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor +++ b/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor @@ -10,27 +10,27 @@ if (RightToWorkDtos is not null && RightToWorkDtos.Length > 0) { - Right To Work supporting documentation already updated + Right To Work supporting documentation already updated - + @foreach (var c in RightToWorkDtos) { - @c.FileName + @c.FileName - } + } - + Add New } else { - + For anyone recorded on PNomis / NDelius as non-British / non-Irish, documentation is required to support their Right to Work. More information on this requirement can be found in the CFO Enrolment Guidance. @@ -38,21 +38,24 @@ To your knowledge, is any Right to Work (RTW) documentation required for the enrolment of this person? - Yes, Right to Work is required - No, Right to Work is not required + Yes, Right to Work is required + No, Right to Work is not required - + @if (_isRequired) { + - - + @bind-Date="Model.ValidFrom" Required /> + @if (_isIndefiniteRtwChecked == false) + { + + }
@@ -62,7 +65,7 @@ StartIcon="@Icons.Material.Filled.Upload"> @if (_uploading) { - + @ConstantString.Uploading } else @@ -83,14 +86,15 @@ private bool _isRequired = true; private bool _uploading = false; - + private bool _isIndefiniteRtwChecked { get; set; } = false; + [EditorRequired] [Parameter] - public AddRightToWork.Command? Model { get; set; } + public AddRightToWork.Command? Model { get; set; } [Parameter] public RightToWorkDto[]? RightToWorkDtos { get; set; } - + private MudForm? Form { get; set; } public async Task Validate() @@ -99,7 +103,7 @@ { return true; } - + await Form!.Validate(); if (Form.IsValid) @@ -132,11 +136,35 @@ await using var stream = file.OpenReadStream(maxFileSize); using var memoryStream = new MemoryStream(); await stream.CopyToAsync(memoryStream); - + Model!.UploadRequest = new UploadRequest(file.Name, UploadType.Document, memoryStream.ToArray()); _uploading = false; } } } + private void RightToWorkRequiredOnClick() + { + _isRequired = true; + + IndefiniteRtwOnValueChanged(_isIndefiniteRtwChecked); + } + private void NoRightToWorkRequiredOnClick() + { + _isRequired = false; + + IndefiniteRtwOnValueChanged(_isIndefiniteRtwChecked); + } + private void IndefiniteRtwOnValueChanged(bool isIndefiniteRtwChecked) + { + _isIndefiniteRtwChecked = isIndefiniteRtwChecked; + if (_isIndefiniteRtwChecked) + { + Model!.ValidTo = new DateTime(9999, 12, 31); + } + else + { + Model!.ValidTo = null; + } + } }