feat: send ticket receipts via WhatsApp and normalize phone numbers

Add WhatsApp API integration for automated receipt delivery
Enforce country codes for all phone number inputs (defaults to +60)
This commit is contained in:
2026-04-27 13:12:25 +08:00
parent faa998c7e1
commit c214d643dd
18 changed files with 208 additions and 28 deletions

View File

@@ -166,7 +166,7 @@
size="lg"
type="tel"
class="w-full"
placeholder="e.g. 0123456789"
placeholder="e.g. +60123456789"
/>
</UFormField>
@@ -208,6 +208,7 @@
import type { FormError, FormSubmitEvent } from '@nuxt/ui'
import {
DEFAULT_PHONE_COUNTRY_CODE,
hasValidFullName,
isValidPhoneNumber,
isValidUsername,
@@ -242,7 +243,7 @@ const editingUserId = ref<string | null>(null)
const userForm = reactive({
fullName: '',
username: '',
phoneNumber: '',
phoneNumber: DEFAULT_PHONE_COUNTRY_CODE,
role: 'staff' as UserRole
})
@@ -287,7 +288,7 @@ await refreshUsers()
function resetUserForm() {
userForm.fullName = ''
userForm.username = ''
userForm.phoneNumber = ''
userForm.phoneNumber = DEFAULT_PHONE_COUNTRY_CODE
userForm.role = 'staff'
editingUserId.value = null
}
@@ -303,7 +304,7 @@ function openEditModal(user: ManagedUser) {
editingUserId.value = user.id
userForm.fullName = user.fullName
userForm.username = user.username
userForm.phoneNumber = user.phoneNumber || ''
userForm.phoneNumber = user.phoneNumber ? normalizePhoneNumber(user.phoneNumber) : DEFAULT_PHONE_COUNTRY_CODE
userForm.role = user.role
editorOpen.value = true
}
@@ -329,7 +330,7 @@ function validateUserForm(state: typeof userForm): FormError[] {
}
if (!isValidPhoneNumber(state.phoneNumber)) {
errors.push({ name: 'phoneNumber', message: 'Use a valid phone number with 8 to 15 digits.' })
errors.push({ name: 'phoneNumber', message: 'Use a valid phone number with country code, e.g. +60123456789.' })
}
return errors