-
Notifications
You must be signed in to change notification settings - Fork 11.7k
fix: phone-input #23729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: phone-input #23729
Changes from 9 commits
6e520ad
6a08127
da3b530
c70820f
ae2f6c9
5e9a09e
d863b6d
672a1bd
7625491
6bfe343
a8a7d97
bf081e8
37d5f40
087a678
d3a3cb8
b6d1f15
ec32363
d0334c6
3261a79
a0267b0
a5470e8
4dbb717
056fc84
44d10b8
ae9d4f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -118,7 +118,6 @@ export const getBookingFieldsWithSystemFields = ({ | |||||||||||||||||||||||||||||||||||||||||||||||
| export const ensureBookingInputsHaveSystemFields = ({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| bookingFields, | ||||||||||||||||||||||||||||||||||||||||||||||||
| disableGuests, | ||||||||||||||||||||||||||||||||||||||||||||||||
| isOrgTeamEvent, | ||||||||||||||||||||||||||||||||||||||||||||||||
| disableBookingTitle, | ||||||||||||||||||||||||||||||||||||||||||||||||
| additionalNotesRequired, | ||||||||||||||||||||||||||||||||||||||||||||||||
| customInputs, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -146,17 +145,35 @@ export const ensureBookingInputsHaveSystemFields = ({ | |||||||||||||||||||||||||||||||||||||||||||||||
| [EventTypeCustomInputType.PHONE]: BookingFieldTypeEnum.phone, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| const smsNumberSources = [] as NonNullable<(typeof bookingFields)[number]["sources"]>; | ||||||||||||||||||||||||||||||||||||||||||||||||
| const phoneNumberSources = [] as NonNullable<(typeof bookingFields)[number]["sources"]>; | ||||||||||||||||||||||||||||||||||||||||||||||||
| let isPhoneNumberRequired = false; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| workflows.forEach((workflow) => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| workflow.workflow.steps.forEach((step) => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (step.action === "SMS_ATTENDEE" || step.action === "WHATSAPP_ATTENDEE") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const workflowId = workflow.workflow.id; | ||||||||||||||||||||||||||||||||||||||||||||||||
| smsNumberSources.push( | ||||||||||||||||||||||||||||||||||||||||||||||||
| phoneNumberSources.push( | ||||||||||||||||||||||||||||||||||||||||||||||||
| getSmsReminderNumberSource({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| workflowId, | ||||||||||||||||||||||||||||||||||||||||||||||||
| isSmsReminderNumberRequired: !!step.numberRequired, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (step.numberRequired) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| isPhoneNumberRequired = true; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Check for AI agent call workflows that require phone numbers | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (step.action === "CAL_AI_PHONE_CALL") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const workflowId = workflow.workflow.id; | ||||||||||||||||||||||||||||||||||||||||||||||||
| phoneNumberSources.push( | ||||||||||||||||||||||||||||||||||||||||||||||||
| getAIAgentCallPhoneNumberSource({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| workflowId, | ||||||||||||||||||||||||||||||||||||||||||||||||
| isAIAgentCallPhoneNumberRequired: !!step.numberRequired, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (step.numberRequired) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| isPhoneNumberRequired = true; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+162
to
+173
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CAL_AI_PHONE_CALL must always require a phone number. Per workflows behavior, AI phone calls require phone regardless of step.numberRequired. Current code makes it conditional. Apply: if (step.action === "CAL_AI_PHONE_CALL") {
const workflowId = workflow.workflow.id;
phoneNumberSources.push(
getAIAgentCallPhoneNumberSource({
workflowId,
- isAIAgentCallPhoneNumberRequired: !!step.numberRequired,
+ isAIAgentCallPhoneNumberRequired: true,
})
);
- if (step.numberRequired) {
- isPhoneNumberRequired = true;
- }
+ isPhoneNumberRequired = true;
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -336,21 +353,46 @@ export const ensureBookingInputsHaveSystemFields = ({ | |||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| bookingFields = missingSystemBeforeFields.concat(bookingFields); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Backward Compatibility for SMS Reminder Number | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Note: We still need workflows in `getBookingFields` due to Backward Compatibility. If we do a one time entry for all event-types, we can remove workflows from `getBookingFields` | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Also, note that even if Workflows don't explicitly add smsReminderNumber field to bookingFields, it would be added as a side effect of this backward compatibility logic | ||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| smsNumberSources.length && | ||||||||||||||||||||||||||||||||||||||||||||||||
| !bookingFields.find((f) => getFieldIdentifier(f.name) !== getFieldIdentifier(SMS_REMINDER_NUMBER_FIELD)) | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const indexForLocation = bookingFields.findIndex( | ||||||||||||||||||||||||||||||||||||||||||||||||
| (f) => getFieldIdentifier(f.name) === getFieldIdentifier("location") | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Consolidated Phone Number Logic | ||||||||||||||||||||||||||||||||||||||||||||||||
| // If any workflow requires a phone number, make the attendeePhoneNumber field visible and add sources | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (phoneNumberSources.length) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const attendeePhoneNumberIndex = bookingFields.findIndex( | ||||||||||||||||||||||||||||||||||||||||||||||||
| (f) => getFieldIdentifier(f.name) === getFieldIdentifier("attendeePhoneNumber") | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Add the SMS Reminder Number field after `location` field always | ||||||||||||||||||||||||||||||||||||||||||||||||
| bookingFields.splice(indexForLocation + 1, 0, { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ...getSmsReminderNumberField(), | ||||||||||||||||||||||||||||||||||||||||||||||||
| sources: smsNumberSources, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (attendeePhoneNumberIndex !== -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Update the existing attendeePhoneNumber field to be visible and add sources | ||||||||||||||||||||||||||||||||||||||||||||||||
| bookingFields[attendeePhoneNumberIndex] = { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ...bookingFields[attendeePhoneNumberIndex], | ||||||||||||||||||||||||||||||||||||||||||||||||
| hidden: false, | ||||||||||||||||||||||||||||||||||||||||||||||||
| required: isPhoneNumberRequired, | ||||||||||||||||||||||||||||||||||||||||||||||||
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||
| sources: [...(bookingFields[attendeePhoneNumberIndex].sources || []), ...phoneNumberSources], | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Consolidation Logic: If there are existing separate phone fields, make attendeePhoneNumber visible | ||||||||||||||||||||||||||||||||||||||||||||||||
| // This ensures users see only one phone input instead of multiple | ||||||||||||||||||||||||||||||||||||||||||||||||
| const hasExistingSmsField = bookingFields.find( | ||||||||||||||||||||||||||||||||||||||||||||||||
| (f) => getFieldIdentifier(f.name) === getFieldIdentifier(SMS_REMINDER_NUMBER_FIELD) | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| const hasExistingAiField = bookingFields.find( | ||||||||||||||||||||||||||||||||||||||||||||||||
| (f) => getFieldIdentifier(f.name) === getFieldIdentifier(CAL_AI_AGENT_PHONE_NUMBER_FIELD) | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (hasExistingSmsField || hasExistingAiField) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Make sure attendeePhoneNumber is visible to consolidate the phone inputs | ||||||||||||||||||||||||||||||||||||||||||||||||
| const attendeePhoneNumberIndex = bookingFields.findIndex( | ||||||||||||||||||||||||||||||||||||||||||||||||
| (f) => getFieldIdentifier(f.name) === getFieldIdentifier("attendeePhoneNumber") | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (attendeePhoneNumberIndex !== -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| bookingFields[attendeePhoneNumberIndex] = { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ...bookingFields[attendeePhoneNumberIndex], | ||||||||||||||||||||||||||||||||||||||||||||||||
| hidden: false, | ||||||||||||||||||||||||||||||||||||||||||||||||
| required: bookingFields[attendeePhoneNumberIndex].required || isPhoneNumberRequired, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Backward Compatibility: If we are migrating from old system, we need to map `customInputs` to `bookingFields` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.