You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nextcloud-server/apps/settings/src/components/PersonalInfo/PhoneSection.vue

49 lines
1.0 KiB

<!--
- SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<AccountPropertySection v-bind.sync="phone"
:placeholder="t('settings', 'Your phone number')"
autocomplete="tel"
type="tel"
:on-validate="onValidate" />
</template>
<script>
import { isValidPhoneNumber } from 'libphonenumber-js'
import { loadState } from '@nextcloud/initial-state'
import AccountPropertySection from './shared/AccountPropertySection.vue'
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
const {
defaultPhoneRegion,
phone,
} = loadState('settings', 'personalInfoParameters', {})
export default {
name: 'PhoneSection',
components: {
AccountPropertySection,
},
data() {
return {
phone: { ...phone, readable: NAME_READABLE_ENUM[phone.name] },
}
},
methods: {
onValidate(value) {
if (defaultPhoneRegion) {
return isValidPhoneNumber(value, defaultPhoneRegion)
}
return isValidPhoneNumber(value)
},
},
}
</script>