-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyForm.razor
100 lines (76 loc) · 2.55 KB
/
MyForm.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<EditForm method="post" Model="CustomerInvite" OnValidSubmit="InviteCustomer" class="col-md-4" FormName="Invite">
<DataAnnotationsValidator />
<ValidationSummary/>
<div class="mb-2">
<label for="firstName" class="form-label">First Name:</label>
<ValidationMessage For="() => CustomerInvite.FirstName" />
<InputText id="firstName" class="form-control" @bind-Value="CustomerInvite.FirstName" />
</div>
<div class="mb-2">
<label for="firstName" class="form-label">Email:</label>
<InputText id="firstName" class="form-control" @bind-Value="CustomerInvite.Email" />
</div>
<InputCheckbox @bind-Value="CustomerInvite.IsSwitchButtonPressed" ></InputCheckbox>
@if (CustomerInvite.IsSwitchButtonPressed)
{
<div>show something</div>
}
@if (Step=="2" && CustomerInvite.Mail1 != null)
{
<div class="mb-2">
<MyMail @bind-Value="CustomerInvite.Mail1" />
</div>
}
<div class="mb-2">
<button type="submit" class="btn btn-primary">Invite</button>
</div>
</EditForm>
@if (customerInvited)
{
<div>
<span>Customer Invited - Ask them to check their inbox to complete the signup process.</span>
</div>
}
@if (!string.IsNullOrEmpty(Message))
{
<div>
<span>@Message</span>
</div>
}
<form class="search">
<input name="query" placeholder="Search..." value="@Step" />
<button title="Search" class="ms-Icon ms-Icon--Search"></button>
</form>
@code {
[Inject]
public NavigationManager NavigationManager { get; set; }
[SupplyParameterFromForm]
public CustomerInvite CustomerInvite { get; set; } = new();
[SupplyParameterFromQuery]
public string Step { get; set; }
public string? Message { get; set; }
bool customerInvited = false;
protected override void OnInitialized()
{
base.OnInitialized();
}
private void InviteCustomer()
{
if (Step=="2")
{
Console.WriteLine("Inviting Customer: " + CustomerInvite.Email);
customerInvited = true;
Message = $"{CustomerInvite.Email}-{CustomerInvite.Mail1.Address}";
}
else
{
CustomerInvite.Mail1 = new Mail();
Step = "2";
// var uri = new UriBuilder(NavigationManager.Uri)
// {
// Query = $"Step={Step}"
// };
// NavigationManager.NavigateTo(uri.ToString(), forceLoad: true);
}
}
}