This commit is contained in:
2026-07-12 22:24:26 +03:30
parent 4b59444e7d
commit 50f6d7f7e5
4 changed files with 229 additions and 25 deletions
@@ -55,11 +55,11 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { ref, watch } from 'vue'
import {
formatSupportMessengers,
parseSelectOptions,
parseSupportMessengers,
parseSupportMessengersDraft,
supportMessengerIdPlaceholder,
type SupportMessengerEntryDraft,
} from './settingTypes'
@@ -74,26 +74,29 @@ const props = withDefaults(
const emit = defineEmits<{ 'update:value': [value: string] }>()
const messengerOptions = computed(() =>
parseSelectOptions({
key: 'support_messenger',
description: 'bale,telegram,whatsapp,rubika,eitaa,soroush',
type: 'select',
}),
)
const rows = computed<SupportMessengerEntryDraft[]>({
get() {
const parsed = parseSupportMessengers(props.modelValue)
if (parsed.length > 0) return parsed
return [{ messenger: 'bale', id: '' }]
},
set(nextRows) {
emit('update:value', formatSupportMessengers(nextRows))
},
const messengerOptions = parseSelectOptions({
key: 'support_messenger',
description: 'bale,telegram,whatsapp,rubika,eitaa,soroush',
type: 'select',
})
const rows = ref<SupportMessengerEntryDraft[]>(parseSupportMessengersDraft(props.modelValue))
let skipExternalSync = false
watch(
() => props.modelValue,
(value) => {
if (skipExternalSync) {
skipExternalSync = false
return
}
rows.value = parseSupportMessengersDraft(value)
},
)
function commit(nextRows: SupportMessengerEntryDraft[]) {
rows.value = nextRows
skipExternalSync = true
emit('update:value', formatSupportMessengers(nextRows))
}