Add optional default product fields on tenant creation

When creating a new tenant, users can now choose to initialize with default product fields (Product Name, Item ID, Sale Price, and Image). The option is presented via a checkbox in the tenant creation modal and is enabled by default.
This commit is contained in:
2025-10-20 21:13:05 -04:00
parent 25e3848710
commit a727796ed2
3 changed files with 80 additions and 2 deletions

View File

@@ -160,6 +160,15 @@
<input type="text" class="form-control" id="tenantId" placeholder="e.g., demo-company" required pattern="[a-zA-Z0-9_-]+">
<small class="form-text text-muted">Only letters, numbers, hyphens, and underscores allowed</small>
</div>
<div class="mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="createDefaultFields" checked>
<label class="form-check-label" for="createDefaultFields">
Create products with default fields
</label>
</div>
<small class="form-text text-muted">Adds: Product Name, Item ID, Sale Price, and Image fields</small>
</div>
<div class="alert alert-info">
<i class="bi bi-info-circle"></i>
<small>Default credentials: <strong>admin</strong> / <strong>admin</strong></small>
@@ -237,13 +246,18 @@
document.getElementById('newTenantForm').addEventListener('submit', function(e) {
e.preventDefault();
const tenantId = document.getElementById('tenantId').value;
const createDefaults = document.getElementById('createDefaultFields').checked;
if (tenantId) {
const normalizedId = tenantId.toLowerCase();
if (reservedIds.includes(normalizedId)) {
alert(`"${tenantId}" is a reserved name and cannot be used as a tenant ID.`);
return;
}
window.location.href = '/' + normalizedId + '/';
// Redirect with query parameter for default fields
const url = '/' + normalizedId + '/' + (createDefaults ? '?create_defaults=1' : '');
window.location.href = url;
}
});