feat: Refactor provisioning to instance requests and enhance subdomain availability check
This commit is contained in:
@@ -208,6 +208,7 @@
|
||||
<div class="booking-review__field">
|
||||
<label for="school_name">Schule/Einrichtung *</label>
|
||||
<input id="school_name" name="school_name" type="text" required maxlength="160" value="{{ form_data.school_name }}">
|
||||
<div id="school_name_feedback" style="margin-top:0.4rem; font-size:0.9rem; color:#6b6b6b;"></div>
|
||||
</div>
|
||||
<div class="booking-review__field">
|
||||
<label for="contact_email">E-Mail *</label>
|
||||
@@ -242,10 +243,54 @@
|
||||
</div>
|
||||
|
||||
<div class="booking-review__actions">
|
||||
<button class="btn" type="submit">{{ confirm_label }}</button>
|
||||
<button id="booking_submit" class="btn" type="submit">{{ confirm_label }}</button>
|
||||
<a class="btn secondary" href="{{ url_for('preise') }}">Zurück zu den Preisen</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
<script>
|
||||
(() => {
|
||||
const input = document.getElementById('school_name');
|
||||
const feedback = document.getElementById('school_name_feedback');
|
||||
const submit = document.getElementById('booking_submit');
|
||||
let timer = null;
|
||||
|
||||
function setFeedback(text, ok) {
|
||||
feedback.textContent = text;
|
||||
feedback.style.color = ok ? '#1b8a3e' : '#b02a37';
|
||||
submit.disabled = !ok;
|
||||
}
|
||||
|
||||
async function check(name) {
|
||||
if (!name || name.trim().length < 3) {
|
||||
feedback.textContent = '';
|
||||
submit.disabled = false;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const params = new URLSearchParams({ school_name: name });
|
||||
const res = await fetch(`/instance_request/check_subdomain?${params.toString()}`, { credentials: 'same-origin' });
|
||||
if (!res.ok) throw new Error('Netzwerkfehler');
|
||||
const j = await res.json();
|
||||
setFeedback(j.message || (j.available ? 'verfügbar' : 'nicht verfügbar'), !!j.available);
|
||||
} catch (e) {
|
||||
setFeedback('Prüfung fehlgeschlagen (Netzwerk).', false);
|
||||
}
|
||||
}
|
||||
|
||||
if (input) {
|
||||
input.addEventListener('input', (e) => {
|
||||
clearTimeout(timer);
|
||||
const val = e.target.value;
|
||||
timer = setTimeout(() => check(val), 500);
|
||||
});
|
||||
|
||||
// initial check on load
|
||||
if (input.value && input.value.trim()) {
|
||||
check(input.value);
|
||||
}
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user