diff --git a/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor b/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor index 8a79f5a2..36162def 100644 --- a/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor +++ b/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor @@ -41,7 +41,8 @@ Yes, Right to Work is required No, Right to Work is not required - + + @if (_isRequired) { - + @bind-Date="Model.ValidTo" Disabled="_disabled" Required />
@@ -83,14 +84,17 @@ private bool _isRequired = true; private bool _uploading = false; - + private bool _disabled = false; + private MudDatePicker? _dpValidTo; + MudCheckBox IndefiniteRtw { get; set; } = default!; + [EditorRequired] [Parameter] 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,24 @@ 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 IndefiniteRtwOnValueChanged() + { + if (IndefiniteRtw.Value) + { + _disabled = true; + Model!.ValidTo = new DateTime(9999, 12, 31); + } + else + { + _disabled = false; + Model!.ValidTo = null; + } + } }