| @@ -17,8 +17,9 @@ | ||
| 17 | 17 | const EMAIL_KEYS: (keyof EmailSettingsValues)[] = [ |
| 18 | 18 | "admin_email", |
| 19 | 19 | "from_email", |
| 20 | 20 | "from_name", |
| 21 | + "email_always_bcc", | |
| 21 | 22 | "email_template_booking", |
| 22 | 23 | "email_template_confirmation", |
| 23 | 24 | "email_template_cancellation", |
| 24 | 25 | "email_template_reminder", |
| @@ -24,8 +25,13 @@ | ||
| 24 | 25 | "email_template_reminder", |
| 25 | 26 | "email_template_admin_new_booking", |
| 26 | 27 | "email_template_admin_payment", |
| 27 | 28 | "email_template_admin_cancellation", |
| 29 | + "email_template_trip_consent", | |
| 30 | + "email_template_customer_verification", | |
| 31 | + "email_template_guest_verification", | |
| 32 | + "email_template_account_email_change", | |
| 33 | + "email_template_account_email_changed", | |
| 28 | 34 | "smtp_enabled", |
| 29 | 35 | "smtp_host", |
| 30 | 36 | "smtp_port", |
| 31 | 37 | "smtp_username", |
| @@ -44,8 +50,60 @@ | ||
| 44 | 50 | "email_tpl_admin_payment_subject", |
| 45 | 51 | "email_tpl_admin_payment_body", |
| 46 | 52 | "email_tpl_admin_cancellation_subject", |
| 47 | 53 | "email_tpl_admin_cancellation_body", |
| 54 | + "email_tpl_trip_consent_subject", | |
| 55 | + "email_tpl_trip_consent_body", | |
| 56 | + "email_tpl_customer_verification_subject", | |
| 57 | + "email_tpl_customer_verification_body", | |
| 58 | + "email_tpl_guest_verification_subject", | |
| 59 | + "email_tpl_guest_verification_body", | |
| 60 | + "email_tpl_account_email_change_subject", | |
| 61 | + "email_tpl_account_email_change_body", | |
| 62 | + "email_tpl_account_email_changed_subject", | |
| 63 | + "email_tpl_account_email_changed_body", | |
| 64 | + "email_template_booking_completed", | |
| 65 | + "email_template_booking_expired_customer", | |
| 66 | + "email_template_admin_booking_expired", | |
| 67 | + "email_template_scheduled_payment_reminder", | |
| 68 | + "email_template_scheduled_payment_succeeded", | |
| 69 | + "email_template_scheduled_payment_failed", | |
| 70 | + "email_template_admin_scheduled_payment_failed", | |
| 71 | + "email_template_enquiry_received", | |
| 72 | + "email_template_enquiry_admin", | |
| 73 | + "email_template_enquiry_response", | |
| 74 | + "email_template_review_request", | |
| 75 | + "email_template_abandoned_booking_recovery_first", | |
| 76 | + "email_template_abandoned_booking_recovery_second", | |
| 77 | + "email_template_abandoned_booking_recovery_final", | |
| 78 | + "email_tpl_booking_completed_subject", | |
| 79 | + "email_tpl_booking_completed_body", | |
| 80 | + "email_tpl_booking_expired_customer_subject", | |
| 81 | + "email_tpl_booking_expired_customer_body", | |
| 82 | + "email_tpl_admin_booking_expired_subject", | |
| 83 | + "email_tpl_admin_booking_expired_body", | |
| 84 | + "email_tpl_scheduled_payment_reminder_subject", | |
| 85 | + "email_tpl_scheduled_payment_reminder_body", | |
| 86 | + "email_tpl_scheduled_payment_succeeded_subject", | |
| 87 | + "email_tpl_scheduled_payment_succeeded_body", | |
| 88 | + "email_tpl_scheduled_payment_failed_subject", | |
| 89 | + "email_tpl_scheduled_payment_failed_body", | |
| 90 | + "email_tpl_admin_scheduled_payment_failed_subject", | |
| 91 | + "email_tpl_admin_scheduled_payment_failed_body", | |
| 92 | + "email_tpl_enquiry_received_subject", | |
| 93 | + "email_tpl_enquiry_received_body", | |
| 94 | + "email_tpl_enquiry_admin_subject", | |
| 95 | + "email_tpl_enquiry_admin_body", | |
| 96 | + "email_tpl_enquiry_response_subject", | |
| 97 | + "email_tpl_enquiry_response_body", | |
| 98 | + "email_tpl_review_request_subject", | |
| 99 | + "email_tpl_review_request_body", | |
| 100 | + "email_tpl_abandoned_booking_recovery_first_subject", | |
| 101 | + "email_tpl_abandoned_booking_recovery_first_body", | |
| 102 | + "email_tpl_abandoned_booking_recovery_second_subject", | |
| 103 | + "email_tpl_abandoned_booking_recovery_second_body", | |
| 104 | + "email_tpl_abandoned_booking_recovery_final_subject", | |
| 105 | + "email_tpl_abandoned_booking_recovery_final_body", | |
| 48 | 106 | ]; |
| 49 | 107 | |
| 50 | 108 | const BOOL_KEYS = new Set<keyof EmailSettingsValues>([ |
| 51 | 109 | "email_template_booking", |
| @@ -54,15 +112,35 @@ | ||
| 54 | 112 | "email_template_reminder", |
| 55 | 113 | "email_template_admin_new_booking", |
| 56 | 114 | "email_template_admin_payment", |
| 57 | 115 | "email_template_admin_cancellation", |
| 116 | + "email_template_trip_consent", | |
| 117 | + "email_template_customer_verification", | |
| 118 | + "email_template_guest_verification", | |
| 119 | + "email_template_account_email_change", | |
| 120 | + "email_template_account_email_changed", | |
| 121 | + "email_template_booking_completed", | |
| 122 | + "email_template_booking_expired_customer", | |
| 123 | + "email_template_admin_booking_expired", | |
| 124 | + "email_template_scheduled_payment_reminder", | |
| 125 | + "email_template_scheduled_payment_succeeded", | |
| 126 | + "email_template_scheduled_payment_failed", | |
| 127 | + "email_template_admin_scheduled_payment_failed", | |
| 128 | + "email_template_enquiry_received", | |
| 129 | + "email_template_enquiry_admin", | |
| 130 | + "email_template_enquiry_response", | |
| 131 | + "email_template_review_request", | |
| 132 | + "email_template_abandoned_booking_recovery_first", | |
| 133 | + "email_template_abandoned_booking_recovery_second", | |
| 134 | + "email_template_abandoned_booking_recovery_final", | |
| 58 | 135 | "smtp_enabled", |
| 59 | 136 | ]); |
| 60 | 137 | |
| 61 | 138 | export const EMAIL_SETTINGS_DEFAULTS: EmailSettingsValues = { |
| 62 | - admin_email: "[email protected]", | |
| 63 | - from_email: "[email protected]", | |
| 139 | + admin_email: "[email protected]", | |
| 140 | + from_email: "[email protected]", | |
| 64 | 141 | from_name: "Yatra Travel", |
| 142 | + email_always_bcc: "", | |
| 65 | 143 | email_template_booking: true, |
| 66 | 144 | email_template_confirmation: true, |
| 67 | 145 | email_template_cancellation: true, |
| 68 | 146 | email_template_reminder: true, |
| @@ -68,8 +146,27 @@ | ||
| 68 | 146 | email_template_reminder: true, |
| 69 | 147 | email_template_admin_new_booking: true, |
| 70 | 148 | email_template_admin_payment: true, |
| 71 | 149 | email_template_admin_cancellation: true, |
| 150 | + email_template_trip_consent: true, | |
| 151 | + email_template_customer_verification: true, | |
| 152 | + email_template_guest_verification: true, | |
| 153 | + email_template_account_email_change: true, | |
| 154 | + email_template_account_email_changed: true, | |
| 155 | + email_template_booking_completed: true, | |
| 156 | + email_template_booking_expired_customer: true, | |
| 157 | + email_template_admin_booking_expired: true, | |
| 158 | + email_template_scheduled_payment_reminder: true, | |
| 159 | + email_template_scheduled_payment_succeeded: true, | |
| 160 | + email_template_scheduled_payment_failed: true, | |
| 161 | + email_template_admin_scheduled_payment_failed: true, | |
| 162 | + email_template_enquiry_received: true, | |
| 163 | + email_template_enquiry_admin: true, | |
| 164 | + email_template_enquiry_response: true, | |
| 165 | + email_template_review_request: true, | |
| 166 | + email_template_abandoned_booking_recovery_first: true, | |
| 167 | + email_template_abandoned_booking_recovery_second: true, | |
| 168 | + email_template_abandoned_booking_recovery_final: true, | |
| 72 | 169 | smtp_enabled: false, |
| 73 | 170 | smtp_host: "smtp.gmail.com", |
| 74 | 171 | smtp_port: 587, |
| 75 | 172 | smtp_username: "", |
| @@ -88,8 +185,46 @@ | ||
| 88 | 185 | email_tpl_admin_payment_subject: "", |
| 89 | 186 | email_tpl_admin_payment_body: "", |
| 90 | 187 | email_tpl_admin_cancellation_subject: "", |
| 91 | 188 | email_tpl_admin_cancellation_body: "", |
| 189 | + email_tpl_trip_consent_subject: "", | |
| 190 | + email_tpl_trip_consent_body: "", | |
| 191 | + email_tpl_customer_verification_subject: "", | |
| 192 | + email_tpl_customer_verification_body: "", | |
| 193 | + email_tpl_guest_verification_subject: "", | |
| 194 | + email_tpl_guest_verification_body: "", | |
| 195 | + email_tpl_account_email_change_subject: "", | |
| 196 | + email_tpl_account_email_change_body: "", | |
| 197 | + email_tpl_account_email_changed_subject: "", | |
| 198 | + email_tpl_account_email_changed_body: "", | |
| 199 | + email_tpl_booking_completed_subject: "", | |
| 200 | + email_tpl_booking_completed_body: "", | |
| 201 | + email_tpl_booking_expired_customer_subject: "", | |
| 202 | + email_tpl_booking_expired_customer_body: "", | |
| 203 | + email_tpl_admin_booking_expired_subject: "", | |
| 204 | + email_tpl_admin_booking_expired_body: "", | |
| 205 | + email_tpl_scheduled_payment_reminder_subject: "", | |
| 206 | + email_tpl_scheduled_payment_reminder_body: "", | |
| 207 | + email_tpl_scheduled_payment_succeeded_subject: "", | |
| 208 | + email_tpl_scheduled_payment_succeeded_body: "", | |
| 209 | + email_tpl_scheduled_payment_failed_subject: "", | |
| 210 | + email_tpl_scheduled_payment_failed_body: "", | |
| 211 | + email_tpl_admin_scheduled_payment_failed_subject: "", | |
| 212 | + email_tpl_admin_scheduled_payment_failed_body: "", | |
| 213 | + email_tpl_enquiry_received_subject: "", | |
| 214 | + email_tpl_enquiry_received_body: "", | |
| 215 | + email_tpl_enquiry_admin_subject: "", | |
| 216 | + email_tpl_enquiry_admin_body: "", | |
| 217 | + email_tpl_enquiry_response_subject: "", | |
| 218 | + email_tpl_enquiry_response_body: "", | |
| 219 | + email_tpl_review_request_subject: "", | |
| 220 | + email_tpl_review_request_body: "", | |
| 221 | + email_tpl_abandoned_booking_recovery_first_subject: "", | |
| 222 | + email_tpl_abandoned_booking_recovery_first_body: "", | |
| 223 | + email_tpl_abandoned_booking_recovery_second_subject: "", | |
| 224 | + email_tpl_abandoned_booking_recovery_second_body: "", | |
| 225 | + email_tpl_abandoned_booking_recovery_final_subject: "", | |
| 226 | + email_tpl_abandoned_booking_recovery_final_body: "", | |
| 92 | 227 | }; |
| 93 | 228 | |
| 94 | 229 | function coerceEmailValues( |
| 95 | 230 | raw: Record<string, unknown> | undefined, |
| @@ -152,9 +287,16 @@ | ||
| 152 | 287 | showToast(message, "error"); |
| 153 | 288 | throw error; |
| 154 | 289 | } |
| 155 | 290 | }, |
| 156 | - enabled: can("manage_yatra"), | |
| 291 | + // Was `manage_yatra` — that's not a registered Yatra cap, so the | |
| 292 | + // check returned false for everyone except admins-via-fallback, | |
| 293 | + // which silently broke the Email page on installs where the | |
| 294 | + // admin fallback wasn't yet wired (free, or Pro pre-Team). The | |
| 295 | + // canonical cap for the Email hub is `yatra_manage_emails`, | |
| 296 | + // registered in the Team module's CapabilityRegistry and held | |
| 297 | + // by Marketing role + Owner / Manager. | |
| 298 | + enabled: can("yatra_manage_emails"), | |
| 157 | 299 | }); |
| 158 | 300 | |
| 159 | 301 | const serverSlice = useMemo( |
| 160 | 302 | () => coerceEmailValues(settings as Record<string, unknown> | undefined), |