Skip to content

Commit

Permalink
When Indefinite Right To Work is checked, hiding ValidTo date
Browse files Browse the repository at this point in the history
  • Loading branch information
vks333 committed Aug 21, 2024
1 parent c74a783 commit 2ece340
Showing 1 changed file with 35 additions and 24 deletions.
59 changes: 35 additions & 24 deletions src/Server.UI/Pages/Enrolments/Components/RightToWork.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,52 @@
if (RightToWorkDtos is not null && RightToWorkDtos.Length > 0)
{
<MudText Typo="Typo.body2">
Right To Work supporting documentation already updated
Right To Work supporting documentation already updated
</MudText>

<MudList T="string">
@foreach (var c in RightToWorkDtos)
{
<MudListItem T="string">
<MudText Typo="Typo.body2">
@c.FileName
@c.FileName
</MudText>
</MudListItem>
}
}
</MudList>

<MudButton ButtonType="ButtonType.Button" Variant="Variant.Filled" Color="Color.Error" @onclick="() => RightToWorkDtos = null">
Add New
</MudButton>
}
else
{
<MudForm @ref="Form">
<MudForm @ref="Form">
<MudText Typo="Typo.caption">
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.
</MudText>
<MudText Typo="Typo.caption">
To your knowledge, is any Right to Work (RTW) documentation required for the enrolment of this person?
</MudText>
<MudButtonGroup OverrideStyles="false" Class="my-4">
<MudButton Color="Color.Primary" Variant="@(_isRequired ? Variant.Filled : Variant.Outlined)" OnClick="() => _isRequired = true">Yes, Right to Work is required</MudButton>
<MudButton Color="Color.Primary" Variant="@(_isRequired ? Variant.Outlined : Variant.Filled)" OnClick="() => _isRequired = false">No, Right to Work is not required</MudButton>
<MudButton Color="Color.Primary" Variant="@(_isRequired ? Variant.Filled : Variant.Outlined)" OnClick="RightToWorkRequiredOnClick">Yes, Right to Work is required</MudButton>
<MudButton Color="Color.Primary" Variant="@(_isRequired ? Variant.Outlined : Variant.Filled)" OnClick="NoRightToWorkRequiredOnClick">No, Right to Work is not required</MudButton>
</MudButtonGroup>
<MudCheckBox @ref="IndefiniteRtw" T="bool" Label="Indefinite Right To Work" ValueChanged="IndefiniteRtwOnValueChanged" />

@if (_isRequired)
{
<MudCheckBox T="bool" Label="Indefinite Right To Work" Value="_isIndefiniteRtwChecked" ValueChanged="IndefiniteRtwOnValueChanged"/>
<MudDatePicker Label="Valid From" Editable="true"
MaxDate="DateTime.Now.Date"
MinDate="DateTime.Now.AddYears(-5).Date"
@bind-Date="Model.ValidFrom" Required/>

<MudDatePicker @ref="_dpValidTo" Label="Valid To" Editable="true"
MaxDate="DateTime.MaxValue.Date"
MinDate="DateTime.Now.Date"
@bind-Date="Model.ValidTo" Disabled="_disabled" Required />
@bind-Date="Model.ValidFrom" Required />
@if (_isIndefiniteRtwChecked == false)
{
<MudDatePicker Label="Valid To" Editable="true"
MaxDate="DateTime.MaxValue.Date"
MinDate="DateTime.Now.Date"
@bind-Date="Model.ValidTo" Required />
}

<div class="mb-4 mt-8">
<MudFileUpload T="IBrowserFile" FilesChanged="UploadFiles" MaximumFileCount="1" Accept=".pdf">
Expand All @@ -63,7 +65,7 @@
StartIcon="@Icons.Material.Filled.Upload">
@if (_uploading)
{
<MudProgressCircular Size="Size.Small" Indeterminate="true"/>
<MudProgressCircular Size="Size.Small" Indeterminate="true" />
@ConstantString.Uploading
}
else
Expand All @@ -84,13 +86,11 @@

private bool _isRequired = true;
private bool _uploading = false;
private bool _disabled = false;
private MudDatePicker? _dpValidTo;
MudCheckBox<bool> IndefiniteRtw { get; set; } = default!;
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; }
Expand Down Expand Up @@ -143,16 +143,27 @@
}
}

private void IndefiniteRtwOnValueChanged()
private void RightToWorkRequiredOnClick()
{
_isRequired = true;

IndefiniteRtwOnValueChanged(_isIndefiniteRtwChecked);
}
private void NoRightToWorkRequiredOnClick()
{
_isRequired = false;

IndefiniteRtwOnValueChanged(_isIndefiniteRtwChecked);
}
private void IndefiniteRtwOnValueChanged(bool isIndefiniteRtwChecked)
{
if (IndefiniteRtw.Value)
_isIndefiniteRtwChecked = isIndefiniteRtwChecked;
if (_isIndefiniteRtwChecked)
{
_disabled = true;
Model!.ValidTo = new DateTime(9999, 12, 31);
}
else
{
_disabled = false;
Model!.ValidTo = null;
}
}
Expand Down

0 comments on commit 2ece340

Please sign in to comment.