Skip to content

Commit c43c315

Browse files
committed
Fix the filters and the new message button
1 parent 8c4216e commit c43c315

2 files changed

Lines changed: 29 additions & 14 deletions

File tree

web/app/pages/messages/index.vue

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const router = useRouter();
1818
const { mdAndDown } = useDisplay();
1919
const notificationsStore = useNotificationsStore();
2020
const phonesStore = usePhonesStore();
21-
const messagesStore = useMessagesStore();
2221
const { useApi } = useApiComposable();
22+
const { formatPhoneNumber } = useFilters();
2323
2424
const sending = ref(false);
2525
const formPhoneNumber = ref("");
@@ -56,6 +56,7 @@ async function sendMessage() {
5656
to: getRecipientNumber(),
5757
from: phonesStore.owner,
5858
content: formContent.value,
59+
sim: "DEFAULT",
5960
attachments: formAttachments.value
6061
.trim()
6162
.split(",")
@@ -93,6 +94,10 @@ async function sendMessage() {
9394
sending.value = false;
9495
}
9596
}
97+
98+
onMounted(async () => {
99+
await phonesStore.loadPhones();
100+
});
96101
</script>
97102

98103
<template>
@@ -104,16 +109,18 @@ async function sendMessage() {
104109
</VBtn>
105110
<VToolbarTitle>
106111
New Message
107-
<VIcon
108-
size="x-small"
109-
class="mx-2"
110-
color="primary"
111-
:icon="mdiCircle"
112-
/>
113-
{{ useFilters().phoneNumber(phonesStore.owner) }}
112+
<template v-if="phonesStore.owner">
113+
<VIcon
114+
size="12"
115+
class="mx-2"
116+
color="primary"
117+
:icon="mdiCircle"
118+
/>
119+
{{ formatPhoneNumber(phonesStore.owner) }}
120+
</template>
114121
</VToolbarTitle>
115122
</VAppBar>
116-
<VContainer class="mt-16">
123+
<VContainer>
117124
<VRow>
118125
<VCol cols="12" md="8" offset-md="2" xl="6" offset-xl="3">
119126
<form @submit.prevent="sendMessage">
@@ -124,6 +131,8 @@ async function sendMessage() {
124131
:error="errors.has('to')"
125132
:error-messages="errors.get('to')"
126133
variant="outlined"
134+
color="primary"
135+
density="compact"
127136
persistent-placeholder
128137
placeholder="Recipient phone number e.g 18005550199"
129138
label="Phone Number"
@@ -135,6 +144,8 @@ async function sendMessage() {
135144
:error-messages="errors.get('content')"
136145
:disabled="sending"
137146
variant="outlined"
147+
density="compact"
148+
color="primary"
138149
persistent-placeholder
139150
placeholder="Enter your message here"
140151
label="Content"
@@ -145,23 +156,24 @@ async function sendMessage() {
145156
:error-messages="errors.get('attachments')"
146157
:disabled="sending"
147158
variant="outlined"
159+
density="compact"
148160
rows="2"
161+
color="primary"
149162
class="mb-8"
150163
persistent-placeholder
151164
persistent-hint
152165
hint="The message will be sent as an MMS when a comma separated list of attachment URLs are present"
153166
placeholder="https://example.com/image.jpg, https://example.com/video.mp4"
154167
label="Attachment URLs (optional)"
155168
/>
156-
<VBtn
157-
type="submit"
158-
color="primary"
169+
<loading-button
159170
:disabled="sending"
160171
:block="mdAndDown"
172+
:loading="sending"
173+
:icon="mdiSend"
161174
>
162-
<VIcon :icon="mdiSend" />
163175
Send Message
164-
</VBtn>
176+
</loading-button>
165177
</form>
166178
</VCol>
167179
</VRow>

web/app/utils/filters.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { intervalToDuration, formatDuration } from "date-fns";
22
import { parsePhoneNumber, isValidPhoneNumber } from "libphonenumber-js";
33

44
export function formatPhoneNumber(value: string): string {
5+
if (!value || typeof value !== "string") {
6+
return value ?? "";
7+
}
58
if (!isValidPhoneNumber(value)) {
69
return value;
710
}

0 commit comments

Comments
 (0)