Fixed some things

This commit is contained in:
Simon Pocrnjič 2025-10-24 22:06:57 +02:00
parent 930ac83604
commit 266af6595e
2 changed files with 26 additions and 4 deletions

View File

@ -24,7 +24,7 @@ public function sendRaw(SmsProfile $profile, string $to, string $content, ?SmsSe
$log = new SmsLog([ $log = new SmsLog([
'uuid' => (string) Str::uuid(), 'uuid' => (string) Str::uuid(),
'profile_id' => $profile->id, 'profile_id' => $profile->id,
'to_number' => /*$to*/'', 'to_number' => $to,
'sender' => $sender?->sname, 'sender' => $sender?->sname,
'message' => $content, 'message' => $content,
'status' => 'queued', 'status' => 'queued',
@ -36,7 +36,7 @@ public function sendRaw(SmsProfile $profile, string $to, string $content, ?SmsSe
to: $to, to: $to,
content: $content, content: $content,
sender: $sender?->sname, sender: $sender?->sname,
senderPhone: /*$sender?->phone_number*/'', senderPhone: $sender?->phone_number,
countryCode: $countryCode, countryCode: $countryCode,
deliveryReport: $deliveryReport, deliveryReport: $deliveryReport,
clientReference: $clientReference, clientReference: $clientReference,

View File

@ -249,6 +249,14 @@ watch(selectedProfileId, () => {
if (!ok) selectedSenderId.value = null; if (!ok) selectedSenderId.value = null;
}); });
// When the available senders list changes, default to the first sender if none selected
watch(sendersForSelectedProfile, (list) => {
if (!Array.isArray(list)) return;
if (!selectedSenderId.value && list.length > 0) {
selectedSenderId.value = list[0].id;
}
});
watch(selectedTemplateId, () => { watch(selectedTemplateId, () => {
if (!selectedTemplateId.value) return; if (!selectedTemplateId.value) return;
const tpl = (pageSmsTemplates.value || []).find( const tpl = (pageSmsTemplates.value || []).find(
@ -259,6 +267,14 @@ watch(selectedTemplateId, () => {
} }
}); });
// If templates array changes and none is chosen, pick the first by default
watch(pageSmsTemplates, (list) => {
if (!Array.isArray(list)) return;
if (!selectedTemplateId.value && list.length > 0) {
selectedTemplateId.value = list[0].id;
}
});
const openSmsDialog = (phone) => { const openSmsDialog = (phone) => {
if (!props.enableSms || !props.clientCaseUuid) return; if (!props.enableSms || !props.clientCaseUuid) return;
smsTargetPhone.value = phone; smsTargetPhone.value = phone;
@ -273,7 +289,11 @@ const openSmsDialog = (phone) => {
(p) => p.id === selectedProfileId.value (p) => p.id === selectedProfileId.value
); );
if (prof && prof.default_sender_id) { if (prof && prof.default_sender_id) {
selectedSenderId.value = prof.default_sender_id; // Use profile default sender if present
const inList = sendersForSelectedProfile.value.find(
(s) => s.id === prof.default_sender_id
);
selectedSenderId.value = inList ? prof.default_sender_id : null;
} else { } else {
selectedSenderId.value = null; selectedSenderId.value = null;
} }
@ -281,7 +301,9 @@ const openSmsDialog = (phone) => {
selectedSenderId.value = null; selectedSenderId.value = null;
} }
deliveryReport.value = false; deliveryReport.value = false;
selectedTemplateId.value = null; // Default template selection to first available
selectedTemplateId.value =
(pageSmsTemplates.value && pageSmsTemplates.value[0]?.id) || null;
}; };
const closeSmsDialog = () => { const closeSmsDialog = () => {
showSmsDialog.value = false; showSmsDialog.value = false;