Add SMS auto-block threshold input on tenant page.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user