Add SMS auto-block threshold input on tenant page.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-08 14:12:30 +03:30
co-authored by Cursor
parent 8e696bb591
commit 196166e1e5
2 changed files with 47 additions and 3 deletions
+15 -3
View File
@@ -10,6 +10,7 @@ import {
/**
* Money field bound to **rial** storage values (API/DB).
* User types and sees **toman** (÷10 / ×10 at the edges).
* With `nullable`, empty input emits `null` (for optional thresholds).
*/
const props = withDefaults(
defineProps<{
@@ -18,23 +19,33 @@ const props = withDefaults(
placeholder?: string
allowNegative?: boolean
disabled?: boolean
nullable?: boolean
}>(),
{
size: 'large',
placeholder: '',
allowNegative: false,
disabled: false,
nullable: false,
},
)
const emit = defineEmits<{
(e: 'update:value', value: number): void
(e: 'update:value', value: number | null): void
}>()
const display = computed(() => toGroupedDisplay(rialToToman(props.value ?? 0)))
const display = computed(() => {
if (props.nullable && (props.value == null || props.value === undefined)) return ''
return toGroupedDisplay(rialToToman(props.value ?? 0))
})
function onInput(raw: string | number) {
const toman = fromGroupedInput(String(raw ?? ''), props.allowNegative)
const text = String(raw ?? '').trim()
if (props.nullable && !text) {
emit('update:value', null)
return
}
const toman = fromGroupedInput(text, props.allowNegative)
emit('update:value', tomanToRial(toman))
}
</script>
@@ -47,6 +58,7 @@ function onInput(raw: string | number) {
:placeholder="placeholder"
:disabled="disabled"
:value="display"
allow-clear
@update:value="onInput"
/>
</template>