From b524ceeca14e99cbca4b8d0357fa5337f1ea99e7 Mon Sep 17 00:00:00 2001 From: Pranav Date: Mon, 23 Sep 2024 23:25:38 -0700 Subject: [PATCH] feat: Auto-populate the telephone code based on the browser timezone (#10146) Fixes https://github.com/chatwoot/chatwoot/issues/6228 There is a country code selector for the phone input field. This is often a point of frustration. See the response below. > We are using the phone number field however this can be frustrating for customers, especially mobile users, to select the +1 US country code. Our users are typically local businesses and being able to default to +1 country code in the phone number field or the account would improve the interaction they have with customers. Most people who run local businesses don't need a country selector. However, to preserve the quality of the data we store, we need a country code. A balance between these two issues can be found with an auto-populating country code field based on the browser's timezone. This is what I did in this PR. Based on the browser timezone, we will resolve it to the closest country code. --- .../components/widgets/forms/PhoneInput.vue | 8 ++++++-- .../shared/components/PhoneInput/helper.js | 13 +++++++++++++ .../widget/components/Form/PhoneInput.vue | 9 +++++++-- package.json | 2 ++ yarn.lock | 10 ++++++++++ 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 app/javascript/shared/components/PhoneInput/helper.js diff --git a/app/javascript/dashboard/components/widgets/forms/PhoneInput.vue b/app/javascript/dashboard/components/widgets/forms/PhoneInput.vue index e08c52e1b..833984683 100644 --- a/app/javascript/dashboard/components/widgets/forms/PhoneInput.vue +++ b/app/javascript/dashboard/components/widgets/forms/PhoneInput.vue @@ -1,6 +1,10 @@