Skip to content

Commit ce8d67d

Browse files
feat: Add debug data seeding trigger via VAT number 12345
- In DEBUG builds only, entering '12345' as VAT number triggers data seeding - Calls /api/dev/reseed endpoint to seed test data - Shows user feedback: 'Debug mode: Triggering data seeding...' - Useful for mobile app testing where backend reseed may be needed - Only works in debug builds, automatically excluded from release builds
1 parent a3243b8 commit ce8d67d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

ai_mate_blazor/Pages/Onboarding.razor

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
@inject IJSRuntime JS
55
@inject ai_mate_blazor.Services.HmrcValidationService HmrcValidation
66
@inject NavigationManager Navigation
7+
@inject HttpClient Http
8+
@inject IConfiguration Configuration
79

810
<div style="max-width: 600px; margin: 40px auto; padding: 20px;">
911
<h2 id="onboarding-heading" style="margin-bottom: 24px;">Welcome to AI Mate</h2>
@@ -235,6 +237,37 @@
235237
return;
236238
}
237239

240+
// DEBUG ONLY: Check for magic VAT number "12345" to trigger data seeding
241+
#if DEBUG
242+
if (VatRegistrationId?.Trim() == "12345")
243+
{
244+
InfoMessage = "🔧 Debug mode: Triggering data seeding...";
245+
StateHasChanged();
246+
247+
try
248+
{
249+
var apiUrl = Configuration["ApiUrl"] ?? "http://localhost:5252";
250+
var response = await Http.PostAsync($"{apiUrl}/api/dev/reseed", null);
251+
252+
if (response.IsSuccessStatusCode)
253+
{
254+
InfoMessage = "✅ Debug data seeded successfully! Redirecting...";
255+
}
256+
else
257+
{
258+
InfoMessage = $"⚠️ Data seeding failed: {response.StatusCode}. Continuing anyway...";
259+
}
260+
}
261+
catch (Exception ex)
262+
{
263+
InfoMessage = $"⚠️ Data seeding error: {ex.Message}. Continuing anyway...";
264+
}
265+
266+
StateHasChanged();
267+
await Task.Delay(1500);
268+
}
269+
#endif
270+
238271
// Mark onboarding as complete and persist IDs to localStorage immediately for UI tests
239272
try { await JS.InvokeVoidAsync("localStorage.setItem", "aimate_onboarding_completed_v1", "1"); } catch { }
240273
try { await JS.InvokeVoidAsync("localStorage.setItem", "aimate_vat_registration_id_v1", VatRegistrationId ?? ""); } catch { }

0 commit comments

Comments
 (0)