feat: timezone support and setting

This commit is contained in:
Per Stark
2025-01-27 14:44:37 +01:00
parent 9a3a8f3a1e
commit d04f3faba5
9 changed files with 130 additions and 9 deletions

View File

@@ -14,6 +14,7 @@
<input type="email" name="email" value="{{ user.email }}" class="input text-primary-content input-bordered w-full"
disabled />
</div>
<div class="form-control">
<label class="label">
<span class="label-text">API key</span>
@@ -33,6 +34,20 @@
{% endif %}
{% endblock %}
</div>
<div class="form-control mt-4">
<label class="label">
<span class="label-text">Timezone</span>
</label>
{% block timezone_section %}
<select name="timezone" class="select w-full" hx-patch="/update-timezone" hx-swap="outerHTML">
{% for tz in timezones %}
<option value="{{ tz }}" {% if tz==user.timezone %}selected{% endif %}>{{ tz }}</option>
{% endfor %}
</select>
{% endblock %}
</div>
<div class="form-control mt-4">
<button hx-post="/verify-email" class="btn btn-secondary w-full">
Verify Email

View File

@@ -43,6 +43,7 @@
Create Account
</button>
</div>
<input type="hidden" name="timezone" id="timezone" />
</form>
<div class="divider">OR</div>
@@ -52,4 +53,9 @@
<a href="/signin" hx-boost="true" class="link link-primary">Sign in</a>
</div>
</div>
<script>
// Detect timezone and set hidden input
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
document.getElementById("timezone").value = timezone;
</script>
{% endblock %}