feat(developers): simplify timezone dropdown and make email optional
All checks were successful
Build and Deploy / deploy (push) Successful in 42s
All checks were successful
Build and Deploy / deploy (push) Successful in 42s
Replace 100+ raw system timezones with curated list of 26 major zones with browser auto-detection via Intl API. Remove email requirement since applicants receive a @silverlabs.uk address — fallback to username@silverlabs.uk when no personal email is provided. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
@using SilverLabs.Website.Models
|
||||
@using SilverLabs.Website.Services
|
||||
@inject DeveloperApplicationService ApplicationService
|
||||
@inject IJSRuntime JS
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<PageTitle>Join the Team - SilverLabs</PageTitle>
|
||||
@@ -85,8 +86,9 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="email">Email Address</label>
|
||||
<label for="email">Email Address (optional)</label>
|
||||
<InputText id="email" @bind-Value="_application.Email" class="form-input" placeholder="jane@example.com" />
|
||||
<span class="form-hint">Leave blank to use your @@silverlabs.uk address</span>
|
||||
<ValidationMessage For="() => _application.Email" />
|
||||
</div>
|
||||
|
||||
@@ -256,10 +258,35 @@
|
||||
|
||||
private readonly string[] _availablePlatforms = { "Windows", "macOS", "Linux", "Android", "iOS", "Other" };
|
||||
|
||||
private static readonly List<(string Id, string Label)> _timezones = TimeZoneInfo.GetSystemTimeZones()
|
||||
.OrderBy(tz => tz.BaseUtcOffset)
|
||||
.Select(tz => (tz.Id, $"(UTC{(tz.BaseUtcOffset >= TimeSpan.Zero ? "+" : "")}{tz.BaseUtcOffset:hh\\:mm}) {tz.DisplayName}"))
|
||||
.ToList();
|
||||
private static readonly List<(string Id, string Label)> _timezones = new()
|
||||
{
|
||||
("Pacific/Midway", "(UTC-11:00) Midway Island"),
|
||||
("Pacific/Honolulu", "(UTC-10:00) Hawaii"),
|
||||
("America/Anchorage", "(UTC-09:00) Alaska"),
|
||||
("America/Los_Angeles", "(UTC-08:00) Pacific Time (US & Canada)"),
|
||||
("America/Denver", "(UTC-07:00) Mountain Time (US & Canada)"),
|
||||
("America/Chicago", "(UTC-06:00) Central Time (US & Canada)"),
|
||||
("America/New_York", "(UTC-05:00) Eastern Time (US & Canada)"),
|
||||
("America/Caracas", "(UTC-04:00) Venezuela"),
|
||||
("America/Halifax", "(UTC-04:00) Atlantic Time (Canada)"),
|
||||
("America/Sao_Paulo", "(UTC-03:00) Brazil"),
|
||||
("Atlantic/South_Georgia","(UTC-02:00) Mid-Atlantic"),
|
||||
("Atlantic/Azores", "(UTC-01:00) Azores"),
|
||||
("Europe/London", "(UTC+00:00) London, Dublin, Lisbon"),
|
||||
("Europe/Berlin", "(UTC+01:00) Berlin, Paris, Amsterdam"),
|
||||
("Europe/Bucharest", "(UTC+02:00) Bucharest, Helsinki, Athens"),
|
||||
("Europe/Moscow", "(UTC+03:00) Moscow, Istanbul"),
|
||||
("Asia/Dubai", "(UTC+04:00) Dubai, Baku"),
|
||||
("Asia/Karachi", "(UTC+05:00) Karachi, Tashkent"),
|
||||
("Asia/Kolkata", "(UTC+05:30) Mumbai, New Delhi"),
|
||||
("Asia/Dhaka", "(UTC+06:00) Dhaka, Almaty"),
|
||||
("Asia/Bangkok", "(UTC+07:00) Bangkok, Jakarta"),
|
||||
("Asia/Shanghai", "(UTC+08:00) Beijing, Singapore, Perth"),
|
||||
("Asia/Tokyo", "(UTC+09:00) Tokyo, Seoul"),
|
||||
("Australia/Sydney", "(UTC+10:00) Sydney, Melbourne"),
|
||||
("Pacific/Noumea", "(UTC+11:00) Solomon Islands"),
|
||||
("Pacific/Auckland", "(UTC+12:00) Auckland, Fiji"),
|
||||
};
|
||||
|
||||
private static readonly System.Text.RegularExpressions.Regex UsernamePattern =
|
||||
new(@"^[a-zA-Z0-9_-]{3,30}$", System.Text.RegularExpressions.RegexOptions.Compiled);
|
||||
@@ -269,6 +296,26 @@
|
||||
private bool IsSubmitDisabled =>
|
||||
_submitting || _usernameCheckState == UsernameCheckState.Taken || _usernameCheckState == UsernameCheckState.Checking;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender && string.IsNullOrEmpty(_application.Timezone))
|
||||
{
|
||||
try
|
||||
{
|
||||
var detectedTz = await JS.InvokeAsync<string>("eval", "Intl.DateTimeFormat().resolvedOptions().timeZone");
|
||||
if (!string.IsNullOrEmpty(detectedTz) && _timezones.Any(tz => tz.Id == detectedTz))
|
||||
{
|
||||
_application.Timezone = detectedTz;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Browser may not support Intl API — ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectRole(ApplicationRole role)
|
||||
{
|
||||
_application.Role = role;
|
||||
|
||||
Reference in New Issue
Block a user