Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

style: fix lint errors and format codebase with prettier/stylelint

Acho Arnold Ewin5381c5ba0a6c
diff --git a/web/app/components/Toast.vue b/web/app/components/AppToast.vue
similarity index 85%
rename from web/app/components/Toast.vue
rename to web/app/components/AppToast.vue
index b046460e..cc62eb09 100644
--- a/web/app/components/Toast.vue
+++ b/web/app/components/AppToast.vue
@@ -1,20 +1,20 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
-import { mdiCheck, mdiInformation } from "@mdi/js";
+import { useDisplay } from 'vuetify'
+import { mdiCheck, mdiInformation } from '@mdi/js'
-const { lgAndUp } = useDisplay();
-const notificationsStore = useNotificationsStore();
+const { lgAndUp } = useDisplay()
+const notificationsStore = useNotificationsStore()
const notificationActive = computed({
get: () => notificationsStore.notification.active,
set: () => notificationsStore.disableNotification(),
-});
+})
</script>
<template>
<v-snackbar
- variant="tonal"
v-model="notificationActive"
+ variant="tonal"
:color="notificationsStore.notification.type"
:timeout="notificationsStore.notification.timeout"
>
diff --git a/web/app/components/BackButton.vue b/web/app/components/BackButton.vue
index 83530da1..c9adfe81 100644
--- a/web/app/components/BackButton.vue
+++ b/web/app/components/BackButton.vue
@@ -1,31 +1,31 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
-import { mdiArrowLeft } from "@mdi/js";
-import type { RouteLocationRaw } from "vue-router";
+import { useDisplay } from 'vuetify'
+import { mdiArrowLeft } from '@mdi/js'
+import type { RouteLocationRaw } from 'vue-router'
const props = withDefaults(
defineProps<{
- route?: RouteLocationRaw;
- block?: boolean;
+ route?: RouteLocationRaw
+ block?: boolean
}>(),
{
block: false,
},
-);
+)
-const router = useRouter();
-const { smAndDown } = useDisplay();
+const router = useRouter()
+const { smAndDown } = useDisplay()
function goBack() {
if (props.route) {
- router.push(props.route);
- return;
+ router.push(props.route)
+ return
}
if (window.history.length > 1) {
- router.back();
- return;
+ router.back()
+ return
}
- router.push({ name: "index" });
+ router.push({ name: 'index' })
}
</script>
diff --git a/web/app/components/BlogAuthorBio.vue b/web/app/components/BlogAuthorBio.vue
index 4b1e2b25..0051e4d6 100644
--- a/web/app/components/BlogAuthorBio.vue
+++ b/web/app/components/BlogAuthorBio.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { mdiTwitter, mdiGithub } from "@mdi/js";
+import { mdiTwitter, mdiGithub } from '@mdi/js'
</script>
<template>
diff --git a/web/app/components/BlogInfo.vue b/web/app/components/BlogInfo.vue
index d3cfc9e5..d1eac607 100644
--- a/web/app/components/BlogInfo.vue
+++ b/web/app/components/BlogInfo.vue
@@ -1,8 +1,8 @@
<script setup lang="ts">
const props = defineProps<{
- date: string;
- readTime: string;
-}>();
+ date: string
+ readTime: string
+}>()
</script>
<template>
diff --git a/web/app/components/BlogSidebar.vue b/web/app/components/BlogSidebar.vue
index 1de94716..81111cac 100644
--- a/web/app/components/BlogSidebar.vue
+++ b/web/app/components/BlogSidebar.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
-import { mdiBookOpenVariant } from "@mdi/js";
+import { mdiBookOpenVariant } from '@mdi/js'
-const appStore = useAppStore();
+const appStore = useAppStore()
</script>
<template>
diff --git a/web/app/components/CopyButton.vue b/web/app/components/CopyButton.vue
index 29f9764e..ca3c30c2 100644
--- a/web/app/components/CopyButton.vue
+++ b/web/app/components/CopyButton.vue
@@ -1,39 +1,39 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
-import { mdiContentCopy } from "@mdi/js";
+import { useDisplay } from 'vuetify'
+import { mdiContentCopy } from '@mdi/js'
const props = withDefaults(
defineProps<{
- value: string;
- color?: string;
- block?: boolean;
- large?: boolean;
- copyText?: string;
- notificationText?: string;
+ value: string
+ color?: string
+ block?: boolean
+ large?: boolean
+ copyText?: string
+ notificationText?: string
}>(),
{
- color: "default",
+ color: 'default',
block: false,
large: false,
- copyText: "Copy",
- notificationText: "Copied",
+ copyText: 'Copy',
+ notificationText: 'Copied',
},
-);
+)
-const { smAndDown } = useDisplay();
-const notificationsStore = useNotificationsStore();
-const disabled = ref(false);
+const { smAndDown } = useDisplay()
+const notificationsStore = useNotificationsStore()
+const disabled = ref(false)
async function copy() {
- disabled.value = true;
- await navigator.clipboard.writeText(props.value);
+ disabled.value = true
+ await navigator.clipboard.writeText(props.value)
notificationsStore.addNotification({
message: props.notificationText,
- type: "success",
- });
+ type: 'success',
+ })
setTimeout(() => {
- disabled.value = false;
- }, 5000);
+ disabled.value = false
+ }, 5000)
}
</script>
diff --git a/web/app/components/FirebaseAuth.vue b/web/app/components/FirebaseAuth.vue
index 2b3d24ac..e481cd30 100644
--- a/web/app/components/FirebaseAuth.vue
+++ b/web/app/components/FirebaseAuth.vue
@@ -6,114 +6,114 @@ import {
GithubAuthProvider,
signInWithEmailAndPassword,
createUserWithEmailAndPassword,
-} from "firebase/auth";
-import { mdiGoogle, mdiGithub, mdiEmail } from "@mdi/js";
+} from 'firebase/auth'
+import { mdiGoogle, mdiGithub, mdiEmail } from '@mdi/js'
const props = withDefaults(
defineProps<{
- to?: string;
+ to?: string
}>(),
- { to: "/" },
-);
+ { to: '/' },
+)
-const router = useRouter();
-const authStore = useAuthStore();
-const notificationsStore = useNotificationsStore();
-const appStore = useAppStore();
+const router = useRouter()
+const authStore = useAuthStore()
+const notificationsStore = useNotificationsStore()
+const appStore = useAppStore()
-const loading = ref(false);
-const showEmailForm = ref(false);
-const isSignUp = ref(false);
-const email = ref("");
-const password = ref("");
-const emailError = ref("");
+const loading = ref(false)
+const showEmailForm = ref(false)
+const isSignUp = ref(false)
+const email = ref('')
+const password = ref('')
+const emailError = ref('')
async function signInWithGoogle() {
- loading.value = true;
+ loading.value = true
try {
- const auth = getAuth();
- const result = await signInWithPopup(auth, new GoogleAuthProvider());
- onSuccess(result.user);
+ const auth = getAuth()
+ const result = await signInWithPopup(auth, new GoogleAuthProvider())
+ onSuccess(result.user)
} catch (error: unknown) {
- handleError(error, true);
+ handleError(error, true)
} finally {
- loading.value = false;
+ loading.value = false
}
}
async function signInWithGithub() {
- loading.value = true;
+ loading.value = true
try {
- const auth = getAuth();
- const result = await signInWithPopup(auth, new GithubAuthProvider());
- onSuccess(result.user);
+ const auth = getAuth()
+ const result = await signInWithPopup(auth, new GithubAuthProvider())
+ onSuccess(result.user)
} catch (error: unknown) {
- handleError(error, true);
+ handleError(error, true)
} finally {
- loading.value = false;
+ loading.value = false
}
}
async function submitEmail() {
- emailError.value = "";
- loading.value = true;
+ emailError.value = ''
+ loading.value = true
try {
- const auth = getAuth();
- let result;
+ const auth = getAuth()
+ let result
if (isSignUp.value) {
result = await createUserWithEmailAndPassword(
auth,
email.value,
password.value,
- );
+ )
} else {
result = await signInWithEmailAndPassword(
auth,
email.value,
password.value,
- );
+ )
}
- onSuccess(result.user);
+ onSuccess(result.user)
} catch (error: unknown) {
- handleError(error);
+ handleError(error)
} finally {
- loading.value = false;
+ loading.value = false
}
}
function onSuccess(user: unknown) {
notificationsStore.addNotification({
- message: "Login successful!",
- type: "success",
- });
- authStore.onAuthStateChanged(user);
- router.push({ path: props.to });
+ message: 'Login successful!',
+ type: 'success',
+ })
+ authStore.onAuthStateChanged(user)
+ router.push({ path: props.to })
}
function handleError(error: unknown, isSocial = false) {
- const firebaseError = error as { code?: string; message?: string };
- const code = firebaseError.code || "";
- let message = "";
- if (code === "auth/user-not-found" || code === "auth/invalid-credential") {
- message = "Invalid email or password";
- } else if (code === "auth/email-already-in-use") {
- message = "An account with this email already exists";
- } else if (code === "auth/weak-password") {
- message = "Password must be at least 6 characters";
+ const firebaseError = error as { code?: string; message?: string }
+ const code = firebaseError.code || ''
+ let message = ''
+ if (code === 'auth/user-not-found' || code === 'auth/invalid-credential') {
+ message = 'Invalid email or password'
+ } else if (code === 'auth/email-already-in-use') {
+ message = 'An account with this email already exists'
+ } else if (code === 'auth/weak-password') {
+ message = 'Password must be at least 6 characters'
} else if (
- code === "auth/popup-closed-by-user" ||
- code === "auth/cancelled-popup-request"
+ code === 'auth/popup-closed-by-user' ||
+ code === 'auth/cancelled-popup-request'
) {
// User closed the popup, no error to show
- return;
+ return
} else {
- message = firebaseError.message || "An error occurred";
+ message = firebaseError.message || 'An error occurred'
}
if (isSocial) {
- notificationsStore.addNotification({ message, type: "error" });
+ notificationsStore.addNotification({ message, type: 'error' })
} else {
- emailError.value = message;
+ emailError.value = message
}
}
</script>
@@ -190,7 +190,7 @@ function handleError(error: unknown, isSocial = false) {
type="submit"
:loading="loading"
>
- {{ isSignUp ? "Sign Up" : "Sign In" }}
+ {{ isSignUp ? 'Sign Up' : 'Sign In' }}
</v-btn>
<v-btn
block
@@ -200,7 +200,7 @@ function handleError(error: unknown, isSocial = false) {
@click="isSignUp = !isSignUp"
>
{{
- isSignUp ? "Already have an account? Sign In" : "No account? Sign Up"
+ isSignUp ? 'Already have an account? Sign In' : 'No account? Sign Up'
}}
</v-btn>
</v-form>
diff --git a/web/app/components/FixedHeader.vue b/web/app/components/FixedHeader.vue
index 9f3f60d2..b1311f23 100644
--- a/web/app/components/FixedHeader.vue
+++ b/web/app/components/FixedHeader.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
+import { useDisplay } from 'vuetify'
-const { lgAndUp, mdAndDown } = useDisplay();
+const { lgAndUp, mdAndDown } = useDisplay()
</script>
<template>
diff --git a/web/app/components/LoadingButton.vue b/web/app/components/LoadingButton.vue
index baf55e62..3b67d987 100644
--- a/web/app/components/LoadingButton.vue
+++ b/web/app/components/LoadingButton.vue
@@ -1,57 +1,57 @@
<script setup lang="ts">
const props = withDefaults(
defineProps<{
- type?: string;
- block?: boolean;
- large?: boolean;
- xLarge?: boolean;
- tile?: boolean;
- text?: boolean;
- small?: boolean;
- color?: string;
- icon?: string | null;
- loading: boolean;
+ type?: string
+ block?: boolean
+ large?: boolean
+ xLarge?: boolean
+ tile?: boolean
+ text?: boolean
+ small?: boolean
+ color?: string
+ icon?: string | null
+ loading: boolean
}>(),
{
- type: "submit",
+ type: 'submit',
block: false,
large: false,
xLarge: false,
tile: false,
text: false,
small: false,
- color: "primary",
+ color: 'primary',
icon: null,
},
-);
+)
const emit = defineEmits<{
- click: [];
- "update:loading": [value: boolean];
-}>();
+ click: []
+ 'update:loading': [value: boolean]
+}>()
-const isClicked = ref(false);
+const isClicked = ref(false)
watch(
() => props.loading,
(submitting) => {
if (!submitting && isClicked.value) {
- isClicked.value = false;
+ isClicked.value = false
}
},
-);
+)
function onClick() {
- isClicked.value = true;
- emit("click");
+ isClicked.value = true
+ emit('click')
}
const size = computed(() => {
- if (props.xLarge) return "x-large";
- if (props.large) return "large";
- if (props.small) return "small";
- return "default";
-});
+ if (props.xLarge) return 'x-large'
+ if (props.large) return 'large'
+ if (props.small) return 'small'
+ return 'default'
+})
</script>
<template>
diff --git a/web/app/components/LoadingDashboard.vue b/web/app/components/LoadingDashboard.vue
index 89adfe61..93997aee 100644
--- a/web/app/components/LoadingDashboard.vue
+++ b/web/app/components/LoadingDashboard.vue
@@ -1,6 +1,6 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
-const { mdAndDown } = useDisplay();
+import { useDisplay } from 'vuetify'
+const { mdAndDown } = useDisplay()
</script>
<template>
diff --git a/web/app/components/MessageThread.vue b/web/app/components/MessageThread.vue
index 41c61508..f1f81edb 100644
--- a/web/app/components/MessageThread.vue
+++ b/web/app/components/MessageThread.vue
@@ -1,32 +1,31 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
-import { mdiPlus, mdiDownload, mdiCheckAll, mdiCheck, mdiAlert } from "@mdi/js";
-import { formatPhoneNumber } from "~/utils/filters";
-import type { MessageThread } from "~~/shared/types/message-thread";
+import { useDisplay } from 'vuetify'
+import { mdiPlus, mdiDownload, mdiCheckAll, mdiCheck, mdiAlert } from '@mdi/js'
+import { formatPhoneNumber } from '~/utils/filters'
-const { mdAndDown } = useDisplay();
-const threadsStore = useThreadsStore();
-const phonesStore = usePhonesStore();
-const appStore = useAppStore();
-const notificationsStore = useNotificationsStore();
+const { mdAndDown } = useDisplay()
+const threadsStore = useThreadsStore()
+const phonesStore = usePhonesStore()
+const appStore = useAppStore()
+const notificationsStore = useNotificationsStore()
function getInitials(contact: string): string {
- const formatted = formatPhoneNumber(contact);
- return formatted.substring(0, 2);
+ const formatted = formatPhoneNumber(contact)
+ return formatted.substring(0, 2)
}
function threadDate(date: string): string {
return new Date(date).toLocaleString(undefined, {
- month: "short",
- day: "numeric",
- });
+ month: 'short',
+ day: 'numeric',
+ })
}
function onInstallApp() {
notificationsStore.addNotification({
- type: "info",
- message: "Downloading the httpSMS Android App",
- });
+ type: 'info',
+ message: 'Downloading the httpSMS Android App',
+ })
}
</script>
diff --git a/web/app/components/MessageThreadHeader.vue b/web/app/components/MessageThreadHeader.vue
index e48b2ca7..6f71630e 100644
--- a/web/app/components/MessageThreadHeader.vue
+++ b/web/app/components/MessageThreadHeader.vue
@@ -1,6 +1,6 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
-import { getAuth, signOut } from "firebase/auth";
+import { useDisplay } from 'vuetify'
+import { getAuth, signOut } from 'firebase/auth'
import {
mdiPlus,
mdiAccountCog,
@@ -15,67 +15,67 @@ import {
mdiMagnify,
mdiCommentTextMultipleOutline,
mdiCircle,
-} from "@mdi/js";
-import { formatPhoneNumber, phoneCountry, humanizeTime } from "~/utils/filters";
-import type { EntitiesPhone } from "~~/shared/types/api";
+} from '@mdi/js'
+import { formatPhoneNumber, phoneCountry, humanizeTime } from '~/utils/filters'
+import type { EntitiesPhone } from '~~/shared/types/api'
-const router = useRouter();
-const route = useRoute();
-const { mdAndDown, mdAndUp, lgAndUp } = useDisplay();
-const authStore = useAuthStore();
-const phonesStore = usePhonesStore();
-const threadsStore = useThreadsStore();
-const appStore = useAppStore();
-const notificationsStore = useNotificationsStore();
+const router = useRouter()
+const route = useRoute()
+const { mdAndDown, lgAndUp } = useDisplay()
+const authStore = useAuthStore()
+const phonesStore = usePhonesStore()
+const threadsStore = useThreadsStore()
+const appStore = useAppStore()
+const notificationsStore = useNotificationsStore()
-const selectedMenuItem = ref(-1);
+const selectedMenuItem = ref(-1)
interface SelectItem {
- title: string;
- value: string;
+ title: string
+ value: string
}
const owners = computed<SelectItem[]>(() => {
return phonesStore.phones.map((phone: EntitiesPhone) => ({
title: formatPhoneNumber(phone.phone_number),
value: phone.phone_number,
- }));
-});
+ }))
+})
async function onOwnerChanged(owner: string) {
- await authStore.updateUser({ owner });
- if (route.name !== "threads") {
- threadsStore.setThreadId(null);
- await router.push({ name: "threads" });
- return;
+ await authStore.updateUser({ owner })
+ if (route.name !== 'threads') {
+ threadsStore.setThreadId(null)
+ await router.push({ name: 'threads' })
+ return
}
- await threadsStore.loadThreads();
+ await threadsStore.loadThreads()
}
async function toggleArchive() {
- threadsStore.toggleArchive();
+ threadsStore.toggleArchive()
setTimeout(() => {
- selectedMenuItem.value = -1;
- }, 1000);
- if (route.name !== "threads") {
- threadsStore.setThreadId(null);
- await router.push({ name: "threads" });
- return;
+ selectedMenuItem.value = -1
+ }, 1000)
+ if (route.name !== 'threads') {
+ threadsStore.setThreadId(null)
+ await router.push({ name: 'threads' })
+ return
}
- await threadsStore.loadThreads();
+ await threadsStore.loadThreads()
}
async function logout() {
- const auth = getAuth();
- await signOut(auth);
- authStore.resetState();
- phonesStore.resetState();
- threadsStore.resetState();
+ const auth = getAuth()
+ await signOut(auth)
+ authStore.resetState()
+ phonesStore.resetState()
+ threadsStore.resetState()
notificationsStore.addNotification({
- type: "info",
- message: "You have successfully logged out",
- });
- router.push({ name: "index" });
+ type: 'info',
+ message: 'You have successfully logged out',
+ })
+ router.push({ name: 'index' })
}
</script>
@@ -158,7 +158,7 @@ async function logout() {
<v-icon v-else :icon="mdiPackageUp" />
</template>
<v-list-item-title>
- {{ threadsStore.archivedThreads ? "Unarchived" : "Archived" }}
+ {{ threadsStore.archivedThreads ? 'Unarchived' : 'Archived' }}
</v-list-item-title>
</v-list-item>
<v-list-item v-if="phonesStore.owner" :to="{ name: 'messages' }">
diff --git a/web/app/composables/useApi.ts b/web/app/composables/useApi.ts
index f6600520..b69020c0 100644
--- a/web/app/composables/useApi.ts
+++ b/web/app/composables/useApi.ts
@@ -1,45 +1,45 @@
-import type { $Fetch } from "ofetch";
+import type { $Fetch } from 'ofetch'
-let authToken: string | null = null;
-let apiKey: string | null = null;
+let authToken: string | null = null
+let apiKey: string | null = null
export function setAuthHeader(token: string | null) {
- authToken = token;
+ authToken = token
}
export function setApiKey(key: string | null) {
- apiKey = key;
+ apiKey = key
}
function createApiFetch(): $Fetch {
- const config = useRuntimeConfig();
- const publicConfig = config.public as Record<string, string>;
- const baseURL = publicConfig.apiBaseUrl;
+ const config = useRuntimeConfig()
+ const publicConfig = config.public as Record<string, string>
+ const baseURL = publicConfig.apiBaseUrl
return $fetch.create({
baseURL,
headers: {
- "X-Client-Version": publicConfig.clientVersion || "dev",
+ 'X-Client-Version': publicConfig.clientVersion || 'dev',
},
onRequest({ options }) {
- const headers = new Headers(options.headers);
+ const headers = new Headers(options.headers)
if (authToken) {
- headers.set("Authorization", `Bearer ${authToken}`);
+ headers.set('Authorization', `Bearer ${authToken}`)
}
if (apiKey) {
- headers.set("x-api-key", apiKey);
+ headers.set('x-api-key', apiKey)
}
- options.headers = headers;
+ options.headers = headers
},
- });
+ })
}
export function useApi() {
- return { apiFetch: createApiFetch(), setAuthHeader, setApiKey };
+ return { apiFetch: createApiFetch(), setAuthHeader, setApiKey }
}
export function useApiComposable() {
return {
useApi: createApiFetch,
- };
+ }
}
diff --git a/web/app/composables/useFilters.ts b/web/app/composables/useFilters.ts
index 48f4e08b..c84157ea 100644
--- a/web/app/composables/useFilters.ts
+++ b/web/app/composables/useFilters.ts
@@ -7,8 +7,8 @@ import {
formatBillingPeriod,
formatBillingPeriodDateOrdinal,
humanizeTime,
-} from "../utils/filters";
-import { capitalize } from "../utils/capitalize";
+} from '../utils/filters'
+import { capitalize } from '../utils/capitalize'
export function useFilters() {
return {
@@ -21,5 +21,5 @@ export function useFilters() {
formatBillingPeriodDateOrdinal,
humanizeTime,
capitalize,
- };
+ }
}
diff --git a/web/app/layouts/default.vue b/web/app/layouts/default.vue
index eb9a1a29..1256cb15 100644
--- a/web/app/layouts/default.vue
+++ b/web/app/layouts/default.vue
@@ -1,66 +1,66 @@
<script setup lang="ts">
-import Pusher from "pusher-js";
-import { useDisplay } from "vuetify";
-import { setAuthHeader } from "~/composables/useApi";
-import { getAuth } from "firebase/auth";
+import Pusher from 'pusher-js'
+import { useDisplay } from 'vuetify'
+import { setAuthHeader } from '~/composables/useApi'
+import { getAuth } from 'firebase/auth'
-const route = useRoute();
-const config = useRuntimeConfig();
-const { lgAndUp } = useDisplay();
-const authStore = useAuthStore();
-const phonesStore = usePhonesStore();
-const threadsStore = useThreadsStore();
-const appStore = useAppStore();
+const route = useRoute()
+const config = useRuntimeConfig()
+const { lgAndUp } = useDisplay()
+const authStore = useAuthStore()
+const phonesStore = usePhonesStore()
+const threadsStore = useThreadsStore()
+const appStore = useAppStore()
-let poller: ReturnType<typeof setInterval> | null = null;
-let canPoll = false;
+let poller: ReturnType<typeof setInterval> | null = null
+let canPoll = false
const hasDrawer = computed(() => {
- return ["threads", "threads-id"].includes((route.name as string) ?? "");
-});
+ return ['threads', 'threads-id'].includes((route.name as string) ?? '')
+})
onMounted(() => {
setTimeout(() => {
const pusher = new Pusher(config.public.pusherKey as string, {
cluster: config.public.pusherCluster as string,
- });
+ })
if (authStore.authUser) {
- const channel = pusher.subscribe(authStore.authUser.id);
- channel.bind("phone.updated", () => {
- canPoll = true;
- });
+ const channel = pusher.subscribe(authStore.authUser.id)
+ channel.bind('phone.updated', () => {
+ canPoll = true
+ })
}
- startPoller();
- }, 10_000);
-});
+ startPoller()
+ }, 10_000)
+})
onBeforeUnmount(() => {
- if (poller) clearInterval(poller);
-});
+ if (poller) clearInterval(poller)
+})
function startPoller() {
poller = setInterval(async () => {
- if (!canPoll || authStore.authUser == null) return;
+ if (!canPoll || authStore.authUser == null) return
- appStore.setPolling(true);
+ appStore.setPolling(true)
if (authStore.authUser && phonesStore.owner) {
- const auth = getAuth();
- const token = await auth.currentUser?.getIdToken();
- if (token) setAuthHeader(token);
+ const auth = getAuth()
+ const token = await auth.currentUser?.getIdToken()
+ if (token) setAuthHeader(token)
await Promise.all([
phonesStore.loadPhones(true),
threadsStore.loadThreads(),
phonesStore.getHeartbeat(),
- ]);
+ ])
}
- canPoll = false;
- setTimeout(() => appStore.setPolling(false), 1000);
- }, 10_000);
+ canPoll = false
+ setTimeout(() => appStore.setPolling(false), 1000)
+ }, 10_000)
}
</script>
@@ -77,7 +77,7 @@ function startPoller() {
</template>
</v-navigation-drawer>
<v-main :class="{ 'has-drawer': hasDrawer && lgAndUp }">
- <Toast />
+ <AppToast />
<slot v-if="authStore.authStateChanged" />
<LoadingDashboard v-else />
</v-main>
diff --git a/web/app/layouts/error.vue b/web/app/layouts/error.vue
index 74d4a4f0..c9b50eb2 100644
--- a/web/app/layouts/error.vue
+++ b/web/app/layouts/error.vue
@@ -1,10 +1,10 @@
<script setup lang="ts">
-const props = defineProps<{
+defineProps<{
error: {
- statusCode: number;
- message: string;
- };
-}>();
+ statusCode: number
+ message: string
+ }
+}>()
</script>
<template>
diff --git a/web/app/layouts/website.vue b/web/app/layouts/website.vue
index 8e252fbb..1fb6b9ad 100644
--- a/web/app/layouts/website.vue
+++ b/web/app/layouts/website.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
+import { useDisplay } from 'vuetify'
import {
mdiGithub,
mdiCircle,
@@ -14,25 +14,25 @@ import {
mdiScaleBalance,
mdiEmailOutline,
mdiBookOpenVariant,
-} from "@mdi/js";
+} from '@mdi/js'
-const router = useRouter();
-const route = useRoute();
-const { lgAndUp, mdAndUp } = useDisplay();
-const authStore = useAuthStore();
-const appStore = useAppStore();
+const router = useRouter()
+const route = useRoute()
+const { lgAndUp, mdAndUp } = useDisplay()
+const authStore = useAuthStore()
+const appStore = useAppStore()
function goToPricing() {
- if (route.name === "index") {
- document.getElementById("pricing")?.scrollIntoView({ behavior: "smooth" });
+ if (route.name === 'index') {
+ document.getElementById('pricing')?.scrollIntoView({ behavior: 'smooth' })
} else {
- router.push("/").then(() => {
+ router.push('/').then(() => {
setTimeout(() => {
document
- .getElementById("pricing")
- ?.scrollIntoView({ behavior: "smooth" });
- }, 300);
- });
+ .getElementById('pricing')
+ ?.scrollIntoView({ behavior: 'smooth' })
+ }, 300)
+ })
}
}
</script>
@@ -115,7 +115,7 @@ function goToPricing() {
</v-container>
</v-app-bar>
<v-main>
- <Toast />
+ <AppToast />
<slot />
</v-main>
<v-footer>
diff --git a/web/app/middleware/auth.ts b/web/app/middleware/auth.ts
index 15bbecac..33c9c9e2 100644
--- a/web/app/middleware/auth.ts
+++ b/web/app/middleware/auth.ts
@@ -1,7 +1,7 @@
-import { useAuthStore } from "../stores/auth";
+import { useAuthStore } from '../stores/auth'
export default defineNuxtRouteMiddleware(async (to: { path: string }) => {
- const authStore = useAuthStore();
+ const authStore = useAuthStore()
if (!authStore.authStateChanged) {
await new Promise<void>((resolve) => {
@@ -9,16 +9,16 @@ export default defineNuxtRouteMiddleware(async (to: { path: string }) => {
() => authStore.authStateChanged,
(changed) => {
if (changed) {
- stop();
- resolve();
+ stop()
+ resolve()
}
},
{ immediate: true },
- );
- });
+ )
+ })
}
if (authStore.authUser === null) {
- return navigateTo({ path: "/login", query: { to: to.path } });
+ return navigateTo({ path: '/login', query: { to: to.path } })
}
-});
+})
diff --git a/web/app/middleware/guest.ts b/web/app/middleware/guest.ts
index 9082bb47..b1c4cc80 100644
--- a/web/app/middleware/guest.ts
+++ b/web/app/middleware/guest.ts
@@ -1,5 +1,5 @@
export default defineNuxtRouteMiddleware(async () => {
- const authStore = useAuthStore();
+ const authStore = useAuthStore()
if (!authStore.authStateChanged) {
await new Promise<void>((resolve) => {
@@ -7,16 +7,16 @@ export default defineNuxtRouteMiddleware(async () => {
() => authStore.authStateChanged,
(changed) => {
if (changed) {
- stop();
- resolve();
+ stop()
+ resolve()
}
},
{ immediate: true },
- );
- });
+ )
+ })
}
if (authStore.authUser !== null) {
- return navigateTo("/threads");
+ return navigateTo('/threads')
}
-});
+})
diff --git a/web/app/pages/billing/index.vue b/web/app/pages/billing/index.vue
index 96ca2250..582f401c 100644
--- a/web/app/pages/billing/index.vue
+++ b/web/app/pages/billing/index.vue
@@ -1,219 +1,220 @@
<script setup lang="ts">
import {
mdiArrowLeft,
- mdiCreditCard,
mdiCallReceived,
mdiCallMade,
mdiCheck,
mdiAlert,
mdiInvoice,
mdiDownloadOutline,
-} from "@mdi/js";
-import type { BillingUsage } from "~~/shared/types/billing";
+} from '@mdi/js'
import type {
RequestsUserPaymentInvoice,
ResponsesUserSubscriptionPaymentsResponse,
-} from "~~/shared/types/api";
-import { formatBillingPeriodDateOrdinal } from "~/utils/filters";
-import { countries, getStateOptions } from "~/utils/countries";
+} from '~~/shared/types/api'
+import { formatBillingPeriodDateOrdinal } from '~/utils/filters'
+import { countries, getStateOptions } from '~/utils/countries'
+
+type SubscriptionPayment =
+ ResponsesUserSubscriptionPaymentsResponse['data'][number]
definePageMeta({
- middleware: ["auth"],
-});
+ middleware: ['auth'],
+})
useHead({
- title: "Usage & Billing - httpSMS",
-});
+ title: 'Usage & Billing - httpSMS',
+})
-const config = useRuntimeConfig();
-const { mdAndDown, lgAndUp } = useDisplay();
-const authStore = useAuthStore();
-const billingStore = useBillingStore();
-const notificationsStore = useNotificationsStore();
-const { formatDecimal, formatMoney, formatTimestamp } = useFilters();
+const config = useRuntimeConfig()
+const { mdAndDown, lgAndUp } = useDisplay()
+const authStore = useAuthStore()
+const billingStore = useBillingStore()
+const notificationsStore = useNotificationsStore()
+const { formatDecimal, formatTimestamp } = useFilters()
-const loading = ref(true);
-const loadingSubscriptionPayments = ref(false);
-const dialog = ref(false);
-const subscriptionInvoiceDialog = ref(false);
-const payments = ref<ResponsesUserSubscriptionPaymentsResponse | null>(null);
-const selectedPayment = ref<any>(null);
-const invoiceFormName = ref("");
-const invoiceFormAddress = ref("");
-const invoiceFormCity = ref("");
-const invoiceFormState = ref("");
-const invoiceFormZipCode = ref("");
-const invoiceFormCountry = ref("");
-const invoiceFormNotes = ref("");
-const errorMessages = ref(new Map<string, string>());
+const loading = ref(true)
+const loadingSubscriptionPayments = ref(false)
+const dialog = ref(false)
+const subscriptionInvoiceDialog = ref(false)
+const payments = ref<ResponsesUserSubscriptionPaymentsResponse | null>(null)
+const selectedPayment = ref<SubscriptionPayment | null>(null)
+const invoiceFormName = ref('')
+const invoiceFormAddress = ref('')
+const invoiceFormCity = ref('')
+const invoiceFormState = ref('')
+const invoiceFormZipCode = ref('')
+const invoiceFormCountry = ref('')
+const invoiceFormNotes = ref('')
+const errorMessages = ref(new Map<string, string>())
type PaymentPlan = {
- name: string;
- id: string;
- price: number;
- messagesPerMonth: number;
-};
+ name: string
+ id: string
+ price: number
+ messagesPerMonth: number
+}
const plans: PaymentPlan[] = [
- { name: "Free", id: "free", messagesPerMonth: 200, price: 0 },
+ { name: 'Free', id: 'free', messagesPerMonth: 200, price: 0 },
{
- name: "PRO - Monthly",
- id: "pro-monthly",
+ name: 'PRO - Monthly',
+ id: 'pro-monthly',
messagesPerMonth: 5000,
price: 10,
},
{
- name: "PRO - Yearly",
- id: "pro-yearly",
+ name: 'PRO - Yearly',
+ id: 'pro-yearly',
messagesPerMonth: 5000,
price: 100,
},
{
- name: "Ultra - Monthly",
- id: "ultra-monthly",
+ name: 'Ultra - Monthly',
+ id: 'ultra-monthly',
messagesPerMonth: 10000,
price: 20,
},
{
- name: "Ultra - Yearly",
- id: "ultra-yearly",
+ name: 'Ultra - Yearly',
+ id: 'ultra-yearly',
messagesPerMonth: 10000,
price: 200,
},
{
- name: "20k - Monthly",
- id: "20k-monthly",
+ name: '20k - Monthly',
+ id: '20k-monthly',
messagesPerMonth: 20000,
price: 35,
},
{
- name: "20k - Yearly",
- id: "20k-yearly",
+ name: '20k - Yearly',
+ id: '20k-yearly',
messagesPerMonth: 20000,
price: 350,
},
{
- name: "50k - Monthly",
- id: "50k-monthly",
+ name: '50k - Monthly',
+ id: '50k-monthly',
messagesPerMonth: 50000,
price: 89,
},
{
- name: "100k - Monthly",
- id: "100k-monthly",
+ name: '100k - Monthly',
+ id: '100k-monthly',
messagesPerMonth: 100000,
price: 175,
},
{
- name: "200k - Monthly",
- id: "200k-monthly",
+ name: '200k - Monthly',
+ id: '200k-monthly',
messagesPerMonth: 200000,
price: 350,
},
{
- name: "PRO - Lifetime",
- id: "pro-lifetime",
+ name: 'PRO - Lifetime',
+ id: 'pro-lifetime',
messagesPerMonth: 10000,
price: 1000,
},
-];
+]
const plan = computed<PaymentPlan>(() => {
return (plans.find(
- (x) => x.id === (authStore.user?.subscription_name || "free"),
- ) ?? plans[0])!;
-});
+ (x) => x.id === (authStore.user?.subscription_name || 'free'),
+ ) ?? plans[0])!
+})
-const isOnFreePlan = computed(() => plan.value.id === "free");
-const isOnLifetimePlan = computed(() => plan.value.id === "pro-lifetime");
+const isOnFreePlan = computed(() => plan.value.id === 'free')
+const isOnLifetimePlan = computed(() => plan.value.id === 'pro-lifetime')
const subscriptionIsCancelled = computed(
- () => authStore.user?.subscription_status === "cancelled",
-);
+ () => authStore.user?.subscription_status === 'cancelled',
+)
const invoiceStateOptions = computed(() =>
getStateOptions(invoiceFormCountry.value),
-);
+)
const totalMessages = computed(() => {
- if (!billingStore.billingUsage) return 0;
+ if (!billingStore.billingUsage) return 0
return (
billingStore.billingUsage.sent_messages +
billingStore.billingUsage.received_messages
- );
-});
+ )
+})
const checkoutURL = computed(() => {
- const url = new URL(config.public.checkoutUrl as string);
- const user = authStore.authUser;
+ const url = new URL(config.public.checkoutUrl as string)
+ const user = authStore.authUser
if (user) {
- url.searchParams.append("checkout[custom][user_id]", user.id);
- url.searchParams.append("checkout[email]", user.email || "");
- url.searchParams.append("checkout[name]", user.displayName || "");
+ url.searchParams.append('checkout[custom][user_id]', user.id)
+ url.searchParams.append('checkout[email]', user.email || '')
+ url.searchParams.append('checkout[name]', user.displayName || '')
}
- return url.toString();
-});
+ return url.toString()
+})
const enterpriseCheckoutURL = computed(() => {
- const url = new URL(config.public.enterpriseCheckoutUrl as string);
- const user = authStore.authUser;
+ const url = new URL(config.public.enterpriseCheckoutUrl as string)
+ const user = authStore.authUser
if (user) {
- url.searchParams.append("checkout[custom][user_id]", user.id);
- url.searchParams.append("checkout[email]", user.email || "");
- url.searchParams.append("checkout[name]", user.displayName || "");
+ url.searchParams.append('checkout[custom][user_id]', user.id)
+ url.searchParams.append('checkout[email]', user.email || '')
+ url.searchParams.append('checkout[name]', user.displayName || '')
}
- return url.toString();
-});
+ return url.toString()
+})
async function loadData() {
await Promise.all([
authStore.loadUser(),
billingStore.loadBillingUsage(),
billingStore.loadBillingUsageHistory(),
- ]);
- loading.value = false;
- loadSubscriptionInvoices();
+ ])
+ loading.value = false
+ loadSubscriptionInvoices()
}
async function loadSubscriptionInvoices() {
- if (!authStore.user?.subscription_id) return;
- loadingSubscriptionPayments.value = true;
+ if (!authStore.user?.subscription_id) return
+ loadingSubscriptionPayments.value = true
try {
- payments.value = await billingStore.indexSubscriptionPayments();
+ payments.value = await billingStore.indexSubscriptionPayments()
} finally {
- loadingSubscriptionPayments.value = false;
+ loadingSubscriptionPayments.value = false
}
}
async function updateDetails() {
- loading.value = true;
+ loading.value = true
try {
- const link = await billingStore.getSubscriptionUpdateLink();
- window.location.href = link;
+ const link = await billingStore.getSubscriptionUpdateLink()
+ window.location.href = link
} catch {
- loading.value = false;
+ loading.value = false
}
}
async function cancelPlan() {
- loading.value = true;
+ loading.value = true
try {
- await billingStore.cancelSubscription();
+ await billingStore.cancelSubscription()
notificationsStore.addNotification({
- message: "Subscription cancelled successfully",
- type: "success",
- });
- navigateTo("/");
+ message: 'Subscription cancelled successfully',
+ type: 'success',
+ })
+ navigateTo('/')
} catch {
- loading.value = false;
+ loading.value = false
}
}
async function generateInvoice() {
- errorMessages.value = new Map();
- loading.value = true;
+ errorMessages.value = new Map()
+ loading.value = true
try {
await billingStore.generateSubscriptionPaymentInvoice(
- selectedPayment.value?.id || "",
+ selectedPayment.value?.id || '',
{
name: invoiceFormName.value,
address: invoiceFormAddress.value,
@@ -223,25 +224,25 @@ async function generateInvoice() {
country: invoiceFormCountry.value,
notes: invoiceFormNotes.value,
} as RequestsUserPaymentInvoice,
- );
- subscriptionInvoiceDialog.value = false;
- } catch (error: any) {
+ )
+ subscriptionInvoiceDialog.value = false
+ } catch (error: unknown) {
if (error instanceof Map) {
- errorMessages.value = error;
+ errorMessages.value = error
}
} finally {
- loading.value = false;
+ loading.value = false
}
}
-function showInvoiceDialog(payment: any) {
- selectedPayment.value = payment;
- subscriptionInvoiceDialog.value = true;
+function showInvoiceDialog(payment: SubscriptionPayment) {
+ selectedPayment.value = payment
+ subscriptionInvoiceDialog.value = true
}
onMounted(async () => {
- await loadData();
-});
+ await loadData()
+})
</script>
<template>
@@ -630,7 +631,7 @@ onMounted(async () => {
<VCardSubtitle class="mt-n1">
Create an invoice for your
<b>{{ selectedPayment?.attributes.total_formatted }}</b> payment on
- {{ formatTimestamp(selectedPayment?.attributes.created_at ?? "") }}
+ {{ formatTimestamp(selectedPayment?.attributes.created_at ?? '') }}
</VCardSubtitle>
<VCardText>
<VContainer>
diff --git a/web/app/pages/blog/end-to-end-encryption-to-sms-messages.vue b/web/app/pages/blog/end-to-end-encryption-to-sms-messages.vue
index f9840961..731b5961 100644
--- a/web/app/pages/blog/end-to-end-encryption-to-sms-messages.vue
+++ b/web/app/pages/blog/end-to-end-encryption-to-sms-messages.vue
@@ -1,33 +1,33 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
+import { useDisplay } from 'vuetify'
-const { mdAndUp } = useDisplay();
+import { mdiLanguageGo, mdiLanguageJavascript } from '@mdi/js'
+import { ref } from 'vue'
-import { mdiLanguageGo, mdiLanguageJavascript } from "@mdi/js";
-import { ref } from "vue";
+const { mdAndUp } = useDisplay()
-const encryptTab = ref("javascript");
-const sendTab = ref("javascript");
-const receiveTab = ref("javascript");
+const encryptTab = ref('javascript')
+const sendTab = ref('javascript')
+const receiveTab = ref('javascript')
-definePageMeta({ layout: "website" });
+definePageMeta({ layout: 'website' })
useHead({
title:
- "Secure your conversations with end-to-end encryption for SMS messages - httpSMS",
+ 'Secure your conversations with end-to-end encryption for SMS messages - httpSMS',
meta: [
{
- property: "og:title",
+ property: 'og:title',
content:
- "Secure your conversations with end-to-end encryption for SMS messages",
+ 'Secure your conversations with end-to-end encryption for SMS messages',
},
{
- property: "og:description",
+ property: 'og:description',
content:
- "We have added support for end-to-end encryption for SMS messages so that no one can see the content of the messages you send using httpSMS except you.",
+ 'We have added support for end-to-end encryption for SMS messages so that no one can see the content of the messages you send using httpSMS except you.',
},
],
-});
+})
</script>
<template>
@@ -41,7 +41,7 @@ useHead({
>
Secure your conversations by encrypting your SMS messages end-to-end
</h1>
- <BlogInfo date="January 21, 2024" readTime="10 min read" />
+ <BlogInfo date="January 21, 2024" read-time="10 min read" />
<p class="text-body-large mt-2">
We have added support for end-to-end encryption for SMS messages so
diff --git a/web/app/pages/blog/forward-incoming-sms-from-phone-to-webhook.vue b/web/app/pages/blog/forward-incoming-sms-from-phone-to-webhook.vue
index f94feaf6..7342c474 100644
--- a/web/app/pages/blog/forward-incoming-sms-from-phone-to-webhook.vue
+++ b/web/app/pages/blog/forward-incoming-sms-from-phone-to-webhook.vue
@@ -1,40 +1,40 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
+import { useDisplay } from 'vuetify'
-const { mdAndUp } = useDisplay();
+const { mdAndUp } = useDisplay()
-definePageMeta({ layout: "website" });
+definePageMeta({ layout: 'website' })
useHead({
title:
- "How to forward a text message (SMS) from an android phone into your webhook - httpSMS",
+ 'How to forward a text message (SMS) from an android phone into your webhook - httpSMS',
meta: [
{
- property: "og:title",
+ property: 'og:title',
content:
- "How to forward a text message (SMS) from an android phone into your webhook",
+ 'How to forward a text message (SMS) from an android phone into your webhook',
},
{
- property: "og:description",
+ property: 'og:description',
content:
- "You can now program your android phone to forward messages received on your phone to your server and trigger powerful automations with tools like Zapier and IFTTT.",
+ 'You can now program your android phone to forward messages received on your phone to your server and trigger powerful automations with tools like Zapier and IFTTT.',
},
{
- property: "og:image",
+ property: 'og:image',
content:
- "https://httpsms.com/img/blog/forward-incoming-sms-from-phone-to-webhook/header.png",
+ 'https://httpsms.com/img/blog/forward-incoming-sms-from-phone-to-webhook/header.png',
},
{
- name: "twitter:card",
- content: "summary_large_image",
+ name: 'twitter:card',
+ content: 'summary_large_image',
},
{
- property: "og:url",
+ property: 'og:url',
content:
- "https://httpsms.com/blog/forward-incoming-sms-from-phone-to-webhook/",
+ 'https://httpsms.com/blog/forward-incoming-sms-from-phone-to-webhook/',
},
],
-});
+})
</script>
<template>
@@ -55,7 +55,7 @@ useHead({
How to forward a text message (SMS) from an android phone into your
webhook
</h1>
- <BlogInfo date="April 08, 2023" readTime="5 min read" />
+ <BlogInfo date="April 08, 2023" read-time="5 min read" />
<p class="text-body-large mt-2">
You can now program your android phone to forward messages received on
diff --git a/web/app/pages/blog/grant-send-and-read-sms-permissions-on-android.vue b/web/app/pages/blog/grant-send-and-read-sms-permissions-on-android.vue
index 4d38812e..4fe0a992 100644
--- a/web/app/pages/blog/grant-send-and-read-sms-permissions-on-android.vue
+++ b/web/app/pages/blog/grant-send-and-read-sms-permissions-on-android.vue
@@ -1,27 +1,27 @@
<script setup lang="ts">
-import { mdiDotsVertical } from "@mdi/js";
-import { useDisplay } from "vuetify";
+import { mdiDotsVertical } from '@mdi/js'
+import { useDisplay } from 'vuetify'
-const { mdAndUp } = useDisplay();
+const { mdAndUp } = useDisplay()
-definePageMeta({ layout: "website" });
+definePageMeta({ layout: 'website' })
useHead({
title:
- "How to grant SEND_SMS and RECEIVE_SMS permissions on Android 14+ - httpSMS",
+ 'How to grant SEND_SMS and RECEIVE_SMS permissions on Android 14+ - httpSMS',
meta: [
{
- property: "og:title",
+ property: 'og:title',
content:
- "How to grant SEND_SMS and RECEIVE_SMS permissions on Android 14+",
+ 'How to grant SEND_SMS and RECEIVE_SMS permissions on Android 14+',
},
{
- property: "og:description",
+ property: 'og:description',
content:
- "In Android 15 (Vanilla Ice Cream), the SEND_SMS and RECEIVE_SMS permissions are now hard restricted. Learn how to grant these permissions step by step.",
+ 'In Android 15 (Vanilla Ice Cream), the SEND_SMS and RECEIVE_SMS permissions are now hard restricted. Learn how to grant these permissions step by step.',
},
],
-});
+})
</script>
<template>
@@ -35,7 +35,7 @@ useHead({
>
How to grant SMS permissions on Android 15+
</h1>
- <BlogInfo date="February 18, 2025" readTime="5 min read" />
+ <BlogInfo date="February 18, 2025" read-time="5 min read" />
<p class="text-body-large mt-2">
In Android 15 (Vanilla Ice Cream), the
diff --git a/web/app/pages/blog/how-to-send-sms-messages-from-excel.vue b/web/app/pages/blog/how-to-send-sms-messages-from-excel.vue
index 8ff45a7d..8cf3fdbd 100644
--- a/web/app/pages/blog/how-to-send-sms-messages-from-excel.vue
+++ b/web/app/pages/blog/how-to-send-sms-messages-from-excel.vue
@@ -1,35 +1,35 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
+import { useDisplay } from 'vuetify'
-const { mdAndUp } = useDisplay();
+import { mdiCommentTextMultipleOutline } from '@mdi/js'
-import { mdiCommentTextMultipleOutline } from "@mdi/js";
+const { mdAndUp } = useDisplay()
-definePageMeta({ layout: "website" });
+definePageMeta({ layout: 'website' })
useHead({
title:
- "How to send SMS messages to multiple phone numbers from Excel - httpSMS",
+ 'How to send SMS messages to multiple phone numbers from Excel - httpSMS',
meta: [
{
- property: "og:title",
- content: "How to send SMS messages to multiple phone numbers from Excel",
+ property: 'og:title',
+ content: 'How to send SMS messages to multiple phone numbers from Excel',
},
{
- property: "og:description",
+ property: 'og:description',
content:
- "Send personalized SMS messages to multiple phone numbers for less than $0.002 per SMS message using your Android phone as the SMS gateway.",
+ 'Send personalized SMS messages to multiple phone numbers for less than $0.002 per SMS message using your Android phone as the SMS gateway.',
},
{
- name: "twitter:card",
- content: "summary_large_image",
+ name: 'twitter:card',
+ content: 'summary_large_image',
},
{
- property: "og:url",
- content: "https://httpsms.com/blog/how-to-send-sms-messages-from-excel/",
+ property: 'og:url',
+ content: 'https://httpsms.com/blog/how-to-send-sms-messages-from-excel/',
},
],
-});
+})
</script>
<template>
@@ -43,7 +43,7 @@ useHead({
>
How to send SMS messages to multiple phone numbers from Excel
</h1>
- <BlogInfo date="October 29, 2023" readTime="5 min read" />
+ <BlogInfo date="October 29, 2023" read-time="5 min read" />
<p class="text-body-large mt-2">
Send personalized SMS messages to multiple phone numbers for less than
diff --git a/web/app/pages/blog/index.vue b/web/app/pages/blog/index.vue
index f4475e3b..4c02f8c1 100644
--- a/web/app/pages/blog/index.vue
+++ b/web/app/pages/blog/index.vue
@@ -1,102 +1,102 @@
<script setup lang="ts">
-const { mdAndUp } = useDisplay();
+const { mdAndUp } = useDisplay()
definePageMeta({
- layout: "website",
-});
+ layout: 'website',
+})
useHead({
- title: "Blog Posts - httpSMS",
-});
+ title: 'Blog Posts - httpSMS',
+})
type Article = {
- slug: string;
- title: string;
- description: string;
- date: string;
- readTime: string;
- author: string;
- sortDate: string;
-};
+ slug: string
+ title: string
+ description: string
+ date: string
+ readTime: string
+ author: string
+ sortDate: string
+}
const articles: Article[] = [
{
- slug: "grant-send-and-read-sms-permissions-on-android",
- title: "How to grant SMS permissions on Android 15+",
+ slug: 'grant-send-and-read-sms-permissions-on-android',
+ title: 'How to grant SMS permissions on Android 15+',
description:
- "In Android 15 (Vanilla Ice Cream), the SEND_SMS and RECEIVE_SMS permissions are now hard restricted. Learn how to grant these permissions step by step.",
- date: "February 18, 2025",
- readTime: "5 min read",
- author: "Acho Arnold",
- sortDate: "2025-02-18",
+ 'In Android 15 (Vanilla Ice Cream), the SEND_SMS and RECEIVE_SMS permissions are now hard restricted. Learn how to grant these permissions step by step.',
+ date: 'February 18, 2025',
+ readTime: '5 min read',
+ author: 'Acho Arnold',
+ sortDate: '2025-02-18',
},
{
- slug: "end-to-end-encryption-to-sms-messages",
+ slug: 'end-to-end-encryption-to-sms-messages',
title:
- "Secure your conversations with end-to-end encryption for SMS messages",
+ 'Secure your conversations with end-to-end encryption for SMS messages',
description:
- "Take control of your privacy by encrypting your SMS messages end-to-end. Safeguard your messages from prying eyes, ensuring absolute confidentiality.",
- date: "January 21, 2024",
- readTime: "10 min read",
- author: "Acho Arnold",
- sortDate: "2024-01-21",
+ 'Take control of your privacy by encrypting your SMS messages end-to-end. Safeguard your messages from prying eyes, ensuring absolute confidentiality.',
+ date: 'January 21, 2024',
+ readTime: '10 min read',
+ author: 'Acho Arnold',
+ sortDate: '2024-01-21',
},
{
- slug: "send-sms-when-new-row-is-added-to-google-sheets-using-zapier",
- title: "Send an SMS when a new row is added to Google Sheets using Zapier",
+ slug: 'send-sms-when-new-row-is-added-to-google-sheets-using-zapier',
+ title: 'Send an SMS when a new row is added to Google Sheets using Zapier',
description:
- "Automate sending personalized SMS messages each time a new row is added to your Google Sheets document using Zapier without writing code.",
- date: "November 29, 2023",
- readTime: "7 min read",
- author: "Acho Arnold",
- sortDate: "2023-11-29",
+ 'Automate sending personalized SMS messages each time a new row is added to your Google Sheets document using Zapier without writing code.',
+ date: 'November 29, 2023',
+ readTime: '7 min read',
+ author: 'Acho Arnold',
+ sortDate: '2023-11-29',
},
{
- slug: "how-to-send-sms-messages-from-excel",
- title: "How to send SMS messages to multiple phone numbers from Excel",
+ slug: 'how-to-send-sms-messages-from-excel',
+ title: 'How to send SMS messages to multiple phone numbers from Excel',
description:
- "Send multiple SMS messages to your customers from a an Excel file using your Android phone as the SMS gateway.",
- date: "October 29, 2023",
- readTime: "5 min read",
- author: "Acho Arnold",
- sortDate: "2023-10-29",
+ 'Send multiple SMS messages to your customers from a an Excel file using your Android phone as the SMS gateway.',
+ date: 'October 29, 2023',
+ readTime: '5 min read',
+ author: 'Acho Arnold',
+ sortDate: '2023-10-29',
},
{
- slug: "send-bulk-sms-from-csv-file-with-no-code",
- title: "Send bulk SMS messages from a CSV file with no code",
+ slug: 'send-bulk-sms-from-csv-file-with-no-code',
+ title: 'Send bulk SMS messages from a CSV file with no code',
description:
- "Send SMS messages to multiple recipients in your CSV file without writing a single piece of code.",
- date: "October 29, 2023",
- readTime: "7 min read",
- author: "Acho Arnold",
- sortDate: "2023-10-29",
+ 'Send SMS messages to multiple recipients in your CSV file without writing a single piece of code.',
+ date: 'October 29, 2023',
+ readTime: '7 min read',
+ author: 'Acho Arnold',
+ sortDate: '2023-10-29',
},
{
- slug: "send-sms-from-android-phone-with-python",
- title: "Send an SMS from your Android phone with Python",
+ slug: 'send-sms-from-android-phone-with-python',
+ title: 'Send an SMS from your Android phone with Python',
description:
- "This article will show you how to configure your Android phone as an SMS gateway to automate sending text messages with the Python programing language.",
- date: "June 03, 2023",
- readTime: "6 min read",
- author: "Acho Arnold",
- sortDate: "2023-06-03",
+ 'This article will show you how to configure your Android phone as an SMS gateway to automate sending text messages with the Python programing language.',
+ date: 'June 03, 2023',
+ readTime: '6 min read',
+ author: 'Acho Arnold',
+ sortDate: '2023-06-03',
},
{
- slug: "forward-incoming-sms-from-phone-to-webhook",
+ slug: 'forward-incoming-sms-from-phone-to-webhook',
title:
- "Forward a text message (SMS) from an Android phone into your webhook",
+ 'Forward a text message (SMS) from an Android phone into your webhook',
description:
- "Program your android phone to forward messages received on your phone to your server and trigger powerful automations with tools like Zapier and IFTTT.",
- date: "April 08, 2023",
- readTime: "5 min read",
- author: "Acho Arnold",
- sortDate: "2023-04-08",
+ 'Program your android phone to forward messages received on your phone to your server and trigger powerful automations with tools like Zapier and IFTTT.',
+ date: 'April 08, 2023',
+ readTime: '5 min read',
+ author: 'Acho Arnold',
+ sortDate: '2023-04-08',
},
-];
+]
const sortedArticles = computed(() =>
[...articles].sort((a, b) => b.sortDate.localeCompare(a.sortDate)),
-);
+)
</script>
<template>
@@ -171,7 +171,7 @@ const sortedArticles = computed(() =>
overflow: hidden;
}
-@media (min-width: 1280px) {
+@media (width >= 1280px) {
.title-clamp {
-webkit-line-clamp: 2;
height: calc(2.7rem * 2);
@@ -184,14 +184,14 @@ const sortedArticles = computed(() =>
overflow: hidden;
}
-@media (min-width: 1280px) {
+@media (width >= 1280px) {
.description-clamp {
-webkit-line-clamp: 3;
height: calc(1.5rem * 3);
}
}
-@media (min-width: 2560px) {
+@media (width >= 2560px) {
.description-clamp {
-webkit-line-clamp: 2;
height: calc(1.5rem * 2);
diff --git a/web/app/pages/blog/send-bulk-sms-from-csv-file-with-no-code.vue b/web/app/pages/blog/send-bulk-sms-from-csv-file-with-no-code.vue
index 0c20e81a..03b6f59d 100644
--- a/web/app/pages/blog/send-bulk-sms-from-csv-file-with-no-code.vue
+++ b/web/app/pages/blog/send-bulk-sms-from-csv-file-with-no-code.vue
@@ -1,35 +1,35 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
+import { useDisplay } from 'vuetify'
-const { mdAndUp } = useDisplay();
+import { mdiCommentTextMultipleOutline } from '@mdi/js'
-import { mdiCommentTextMultipleOutline } from "@mdi/js";
+const { mdAndUp } = useDisplay()
-definePageMeta({ layout: "website" });
+definePageMeta({ layout: 'website' })
useHead({
- title: "Send bulk SMS messages from a CSV file with no code - httpSMS",
+ title: 'Send bulk SMS messages from a CSV file with no code - httpSMS',
meta: [
{
- property: "og:title",
- content: "Send bulk SMS messages from a CSV file with no code",
+ property: 'og:title',
+ content: 'Send bulk SMS messages from a CSV file with no code',
},
{
- property: "og:description",
+ property: 'og:description',
content:
- "Send personalized SMS messages from your CSV file instantly using your Android phone as the SMS gateway.",
+ 'Send personalized SMS messages from your CSV file instantly using your Android phone as the SMS gateway.',
},
{
- name: "twitter:card",
- content: "summary_large_image",
+ name: 'twitter:card',
+ content: 'summary_large_image',
},
{
- property: "og:url",
+ property: 'og:url',
content:
- "https://httpsms.com/blog/send-bulk-sms-from-csv-file-with-no-code/",
+ 'https://httpsms.com/blog/send-bulk-sms-from-csv-file-with-no-code/',
},
],
-});
+})
</script>
<template>
@@ -43,7 +43,7 @@ useHead({
>
Send multiple SMS messages from a CSV file with no code
</h1>
- <BlogInfo date="October 29, 2023" readTime="7 min read" />
+ <BlogInfo date="October 29, 2023" read-time="7 min read" />
<p class="text-body-large mt-2">
Send personalized SMS messages to your users in bulk using your
diff --git a/web/app/pages/blog/send-sms-from-android-phone-with-python.vue b/web/app/pages/blog/send-sms-from-android-phone-with-python.vue
index 77b49ad3..7919face 100644
--- a/web/app/pages/blog/send-sms-from-android-phone-with-python.vue
+++ b/web/app/pages/blog/send-sms-from-android-phone-with-python.vue
@@ -1,38 +1,38 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
+import { useDisplay } from 'vuetify'
-const { mdAndUp } = useDisplay();
+const { mdAndUp } = useDisplay()
-definePageMeta({ layout: "website" });
+definePageMeta({ layout: 'website' })
useHead({
- title: "Send an SMS from your Android phone with Python - httpSMS",
+ title: 'Send an SMS from your Android phone with Python - httpSMS',
meta: [
{
- property: "og:title",
- content: "Send an SMS from your Android phone with Python",
+ property: 'og:title',
+ content: 'Send an SMS from your Android phone with Python',
},
{
- property: "og:description",
+ property: 'og:description',
content:
- "Configure your Android phone as an SMS gateway to automate sending text messages with the Python programing language.",
+ 'Configure your Android phone as an SMS gateway to automate sending text messages with the Python programing language.',
},
{
- property: "og:image",
+ property: 'og:image',
content:
- "https://httpsms.com/img/blog/send-sms-from-android-phone-with-python/header.png",
+ 'https://httpsms.com/img/blog/send-sms-from-android-phone-with-python/header.png',
},
{
- name: "twitter:card",
- content: "summary_large_image",
+ name: 'twitter:card',
+ content: 'summary_large_image',
},
{
- property: "og:url",
+ property: 'og:url',
content:
- "https://httpsms.com/blog/send-sms-from-android-phone-with-python/",
+ 'https://httpsms.com/blog/send-sms-from-android-phone-with-python/',
},
],
-});
+})
</script>
<template>
@@ -52,7 +52,7 @@ useHead({
>
Send an SMS from your Android phone with Python
</h1>
- <BlogInfo date="June 03, 2023" readTime="6 min read" />
+ <BlogInfo date="June 03, 2023" read-time="6 min read" />
<p class="text-body-large mt-2">
In an era dominated by social media, instant messaging apps, and
diff --git a/web/app/pages/blog/send-sms-when-new-row-is-added-to-google-sheets-using-zapier.vue b/web/app/pages/blog/send-sms-when-new-row-is-added-to-google-sheets-using-zapier.vue
index b80af549..ae54699a 100644
--- a/web/app/pages/blog/send-sms-when-new-row-is-added-to-google-sheets-using-zapier.vue
+++ b/web/app/pages/blog/send-sms-when-new-row-is-added-to-google-sheets-using-zapier.vue
@@ -1,35 +1,35 @@
<script setup lang="ts">
-import { useDisplay } from "vuetify";
+import { useDisplay } from 'vuetify'
-const { mdAndUp } = useDisplay();
+const { mdAndUp } = useDisplay()
-definePageMeta({ layout: "website" });
+definePageMeta({ layout: 'website' })
useHead({
title:
- "Send an SMS message when a new row is added to Google Sheets using Zapier - httpSMS",
+ 'Send an SMS message when a new row is added to Google Sheets using Zapier - httpSMS',
meta: [
{
- property: "og:title",
+ property: 'og:title',
content:
- "Send an SMS message when a new row is added to Google Sheets using Zapier",
+ 'Send an SMS message when a new row is added to Google Sheets using Zapier',
},
{
- property: "og:description",
+ property: 'og:description',
content:
"Automate sending personalized SMS messages each time a new row is added to your Google Sheets document using Zapier. You don't need to write any code to make this happen and you can personalize the SMS messages which are sent out.",
},
{
- name: "twitter:card",
- content: "summary_large_image",
+ name: 'twitter:card',
+ content: 'summary_large_image',
},
{
- property: "og:url",
+ property: 'og:url',
content:
- "https://httpsms.com/blog/send-sms-when-new-row-is-added-to-google-sheets-using-zapier/",
+ 'https://httpsms.com/blog/send-sms-when-new-row-is-added-to-google-sheets-using-zapier/',
},
],
-});
+})
</script>
<template>
@@ -44,7 +44,7 @@ useHead({
Send an SMS message when a new row is added to Google Sheets using
Zapier
</h1>
- <BlogInfo date="October 29, 2023" readTime="5 min read" />
+ <BlogInfo date="October 29, 2023" read-time="5 min read" />
<p class="text-body-large mt-2">
Automate sending personalized SMS messages each time a new row is
diff --git a/web/app/pages/bulk-messages/index.vue b/web/app/pages/bulk-messages/index.vue
index a842022b..a8336246 100644
--- a/web/app/pages/bulk-messages/index.vue
+++ b/web/app/pages/bulk-messages/index.vue
@@ -1,105 +1,111 @@
<script setup lang="ts">
-import { mdiArrowLeft, mdiMicrosoftExcel, mdiSendCheck } from "@mdi/js";
-import { ErrorMessages } from "~/utils/errors";
-import capitalize from "~/utils/capitalize";
+import { mdiArrowLeft, mdiMicrosoftExcel, mdiSendCheck } from '@mdi/js'
+import { ErrorMessages } from '~/utils/errors'
+import { toApiError } from '~/utils/api-error'
+import type { BulkMessageOrder } from '~~/shared/types/bulk-message'
+import capitalize from '~/utils/capitalize'
definePageMeta({
- middleware: ["auth"],
-});
+ middleware: ['auth'],
+})
useHead({
- title: "Send Bulk Messages - httpSMS",
-});
+ title: 'Send Bulk Messages - httpSMS',
+})
-const router = useRouter();
-const { mdAndUp, mdAndDown } = useDisplay();
-const authStore = useAuthStore();
-const notificationsStore = useNotificationsStore();
-const { formatTimestamp } = useFilters();
-const { useApi } = useApiComposable();
+const router = useRouter()
+const { mdAndUp, mdAndDown } = useDisplay()
+const authStore = useAuthStore()
+const notificationsStore = useNotificationsStore()
+const { formatTimestamp } = useFilters()
+const { useApi } = useApiComposable()
-const formFile = ref<File | null>(null);
-const loading = ref(true);
-const loadingHistory = ref(true);
-const errorTitle = ref("");
-const errorMessages = ref(new ErrorMessages());
-const bulkOrders = ref<any[]>([]);
+const formFile = ref<File | null>(null)
+const loading = ref(true)
+const loadingHistory = ref(true)
+const errorTitle = ref('')
+const errorMessages = ref(new ErrorMessages())
+const bulkOrders = ref<BulkMessageOrder[]>([])
-function parseErrors(error: any): ErrorMessages {
- const bag = new ErrorMessages();
- const data = error?.data?.data;
- if (data && typeof data === "object") {
- Object.keys(data).forEach((key) => bag.addMany(key, data[key]));
+function parseErrors(error: unknown): ErrorMessages {
+ const bag = new ErrorMessages()
+ const data = toApiError(error).data?.data
+ if (data && typeof data === 'object') {
+ Object.keys(data).forEach((key) => bag.addMany(key, data[key]))
}
- return bag;
+ return bag
}
function cleanName(requestId: string): string {
- if (requestId.startsWith("bulk-csv-"))
- return requestId.replace(/^bulk-csv-/, "") + ".csv";
- if (requestId.startsWith("bulk-xls-"))
- return requestId.replace(/^bulk-xls-/, "") + ".xlsx";
- const newFormatMatch = requestId.match(/^bulk-[0-9A-Za-z]+-(.+)$/);
- if (newFormatMatch) return newFormatMatch[1];
- return requestId.replace(/^bulk-/, "");
+ if (requestId.startsWith('bulk-csv-'))
+ return requestId.replace(/^bulk-csv-/, '') + '.csv'
+ if (requestId.startsWith('bulk-xls-'))
+ return requestId.replace(/^bulk-xls-/, '') + '.xlsx'
+ const newFormatMatch = requestId.match(/^bulk-[0-9A-Za-z]+-(.+)$/)
+ if (newFormatMatch) return newFormatMatch[1]
+ return requestId.replace(/^bulk-/, '')
}
async function fetchBulkOrders() {
- loadingHistory.value = true;
+ loadingHistory.value = true
try {
- const api = useApi();
- const response = await api<{ data: any[] }>("/v1/bulk-messages", {
- method: "GET",
- });
- bulkOrders.value = response.data ?? [];
+ const api = useApi()
+ const response = await api<{ data: BulkMessageOrder[] }>(
+ '/v1/bulk-messages',
+ {
+ method: 'GET',
+ },
+ )
+ bulkOrders.value = response.data ?? []
} catch {
notificationsStore.addNotification({
- message: "Error while fetching bulk messages history",
- type: "error",
- });
+ message: 'Error while fetching bulk messages history',
+ type: 'error',
+ })
} finally {
- loadingHistory.value = false;
+ loadingHistory.value = false
}
}
async function sendBulkMessages() {
- loading.value = true;
- errorMessages.value = new ErrorMessages();
- errorTitle.value = "";
+ loading.value = true
+ errorMessages.value = new ErrorMessages()
+ errorTitle.value = ''
try {
- const api = useApi();
- const formData = new FormData();
- if (formFile.value) formData.append("document", formFile.value);
- const response = await api<{ message?: string }>("/v1/bulk-messages", {
- method: "POST",
+ const api = useApi()
+ const formData = new FormData()
+ if (formFile.value) formData.append('document', formFile.value)
+ const response = await api<{ message?: string }>('/v1/bulk-messages', {
+ method: 'POST',
body: formData,
- });
+ })
notificationsStore.addNotification({
- message: response?.message ?? "Bulk messages sent successfully",
- type: "success",
- });
- loading.value = false;
- formFile.value = null;
- fetchBulkOrders();
- } catch (error: any) {
+ message: response?.message ?? 'Bulk messages sent successfully',
+ type: 'success',
+ })
+ loading.value = false
+ formFile.value = null
+ fetchBulkOrders()
+ } catch (error: unknown) {
errorTitle.value = capitalize(
- error?.data?.message ?? "Error while sending bulk messages",
- );
- errorMessages.value = parseErrors(error);
+ toApiError(error).data?.message ?? 'Error while sending bulk messages',
+ )
+ errorMessages.value = parseErrors(error)
notificationsStore.addNotification({
- message: error?.data?.message ?? "Errors while sending bulk messages",
- type: "error",
- });
- loading.value = false;
+ message:
+ toApiError(error).data?.message ?? 'Errors while sending bulk messages',
+ type: 'error',
+ })
+ loading.value = false
}
}
onMounted(async () => {
- await authStore.loadUser();
- loading.value = false;
- fetchBulkOrders();
-});
+ await authStore.loadUser()
+ loading.value = false
+ fetchBulkOrders()
+})
</script>
<template>
@@ -206,12 +212,12 @@ onMounted(async () => {
individual messages on the search page.
</p>
<VProgressLinear
- color="primary"
v-if="loadingHistory"
+ color="primary"
indeterminate
class="mb-4"
/>
- <VTable density="comfortable" v-else>
+ <VTable v-else density="comfortable">
<thead>
<tr class="text-uppercase text-medium-emphasis">
<th class="text-left">Name</th>
@@ -259,6 +265,7 @@ onMounted(async () => {
.clickable-row {
cursor: pointer;
}
+
.clickable-row:hover {
background-color: rgb(0 0 0 / 4%);
}
diff --git a/web/app/pages/heartbeats/[id].vue b/web/app/pages/heartbeats/[id].vue
index 20695208..c3abbc6b 100644
--- a/web/app/pages/heartbeats/[id].vue
+++ b/web/app/pages/heartbeats/[id].vue
@@ -1,40 +1,41 @@
<script setup lang="ts">
-import { mdiArrowLeft, mdiHeartPulse } from "@mdi/js";
+import { mdiArrowLeft, mdiHeartPulse } from '@mdi/js'
+import type { Heartbeat } from '~~/shared/types/heartbeat'
definePageMeta({
- middleware: ["auth"],
-});
+ middleware: ['auth'],
+})
useHead({
- title: "Heartbeats - httpSMS",
-});
+ title: 'Heartbeats - httpSMS',
+})
-const route = useRoute();
-const { mdAndDown, lgAndUp } = useDisplay();
-const authStore = useAuthStore();
-const { useApi } = useApiComposable();
+const route = useRoute()
+const { mdAndDown, lgAndUp } = useDisplay()
+const authStore = useAuthStore()
+const { useApi } = useApiComposable()
-const loading = ref(true);
-const heartbeats = ref<any[]>([]);
-const phoneId = computed(() => route.params.id as string);
+const loading = ref(true)
+const heartbeats = ref<Heartbeat[]>([])
+const phoneId = computed(() => route.params.id as string)
async function loadHeartbeats() {
- loading.value = true;
+ loading.value = true
try {
- const api = useApi();
- const response = await api<{ data: any[] }>(
+ const api = useApi()
+ const response = await api<{ data: Heartbeat[] }>(
`/v1/heartbeats?owner=${phoneId.value}`,
- );
- heartbeats.value = response.data ?? [];
+ )
+ heartbeats.value = response.data ?? []
} finally {
- loading.value = false;
+ loading.value = false
}
}
onMounted(async () => {
- await authStore.loadUser();
- await loadHeartbeats();
-});
+ await authStore.loadUser()
+ await loadHeartbeats()
+})
</script>
<template>
@@ -58,8 +59,8 @@ onMounted(async () => {
are sent every 15 minutes when the phone is online.
</p>
<VProgressLinear
- color="primary"
v-if="loading"
+ color="primary"
indeterminate
class="mb-4"
/>
@@ -80,14 +81,14 @@ onMounted(async () => {
:color="heartbeat.is_online ? 'success' : 'error'"
size="small"
>
- {{ heartbeat.is_online ? "Online" : "Offline" }}
+ {{ heartbeat.is_online ? 'Online' : 'Offline' }}
</VChip>
</td>
<td class="text-center">
{{ useFilters().timestamp(heartbeat.timestamp) }}
</td>
<td class="text-center">
- {{ heartbeat.charging ? "Yes" : "No" }}
+ {{ heartbeat.charging ? 'Yes' : 'No' }}
</td>
</tr>
</tbody>
diff --git a/web/app/pages/index.vue b/web/app/pages/index.vue
index 0044c829..63fc223d 100644
--- a/web/app/pages/index.vue
+++ b/web/app/pages/index.vue
@@ -1,13 +1,10 @@
<script setup lang="ts">
import {
- mdiGithub,
mdiCheckCircle,
mdiSend,
mdiGift,
mdiLightbulbOn60,
- mdiForum,
mdiCreation,
- mdiSale,
mdiLockOutline,
mdiLanguagePython,
mdiCellphoneKey,
@@ -27,37 +24,37 @@ import {
mdiArrowRightThin,
mdiPowershell,
mdiLanguageGo,
-} from "@mdi/js";
+} from '@mdi/js'
definePageMeta({
- layout: "website",
-});
+ layout: 'website',
+})
useHead({
- title: "Convert your android phone into an SMS gateway - httpSMS",
-});
+ title: 'Convert your android phone into an SMS gateway - httpSMS',
+})
-const config = useRuntimeConfig();
-const { lgAndUp, mdAndUp, mdAndDown, md, smAndDown, xl } = useDisplay();
+const config = useRuntimeConfig()
+const { lgAndUp, mdAndUp, mdAndDown, md, smAndDown, xl } = useDisplay()
-const selectedTab = ref("javascript");
-const yearlyPricing = ref(false);
-const faqPanel = ref<number | undefined>(undefined);
-const pricing = ref(0);
+const selectedTab = ref('javascript')
+const yearlyPricing = ref(false)
+const faqPanel = ref<number | undefined>(undefined)
+const pricing = ref(0)
-const pricingLabels = ["10K", "20K", "50K", "100K", "200K"];
-const pricingLabelsFull = ["10,000", "20,000", "50,000", "100,000", "200,000"];
+const pricingLabels = ['10K', '20K', '50K', '100K', '200K']
+const pricingLabelsFull = ['10,000', '20,000', '50,000', '100,000', '200,000']
const planMessages = computed(() =>
- pricingLabels[pricing.value].replace("K", ",000"),
-);
-const planMonthlyPrice = computed(() => [20, 35, 89, 175, 350][pricing.value]);
+ pricingLabels[pricing.value].replace('K', ',000'),
+)
+const planMonthlyPrice = computed(() => [20, 35, 89, 175, 350][pricing.value])
const planYearlyPrice = computed(
() => [200, 350, 1068, 2100, 4200][pricing.value],
-);
+)
const planYearlyMonthlyPrice = computed(
() => [16.66, 29.16, 89, 175, 350][pricing.value],
-);
+)
</script>
<template>
@@ -483,9 +480,9 @@ const planYearlyMonthlyPrice = computed(
<VCol cols="12" md="7">
<div class="w-100 mt-n8">
<VTabs
+ v-model="selectedTab"
color="primary"
bg-color="#212121"
- v-model="selectedTab"
show-arrows
>
<VTab value="javascript">
diff --git a/web/app/pages/login.vue b/web/app/pages/login.vue
index ce14255d..46a9044f 100644
--- a/web/app/pages/login.vue
+++ b/web/app/pages/login.vue
@@ -1,15 +1,15 @@
<script setup lang="ts">
definePageMeta({
- middleware: ["guest"],
- layout: "blank",
-});
+ middleware: ['guest'],
+ layout: 'blank',
+})
useHead({
- title: "Login To Your Account - httpSMS",
-});
+ title: 'Login To Your Account - httpSMS',
+})
-const route = useRoute();
-const to = computed(() => (route.query.to as string) || "/threads");
+const route = useRoute()
+const to = computed(() => (route.query.to as string) || '/threads')
</script>
<template>
diff --git a/web/app/pages/messages/index.vue b/web/app/pages/messages/index.vue
index cebd5a75..c291d0d4 100644
--- a/web/app/pages/messages/index.vue
+++ b/web/app/pages/messages/index.vue
@@ -1,103 +1,104 @@
<script setup lang="ts">
-import { mdiArrowLeft, mdiSend, mdiCircle } from "@mdi/js";
+import { mdiArrowLeft, mdiSend, mdiCircle } from '@mdi/js'
import {
isValidPhoneNumber,
getCountryCallingCode,
type CountryCode,
-} from "libphonenumber-js";
+} from 'libphonenumber-js'
+import { toApiError } from '~/utils/api-error'
definePageMeta({
- middleware: ["auth"],
-});
+ middleware: ['auth'],
+})
useHead({
- title: "New Message - httpSMS",
-});
+ title: 'New Message - httpSMS',
+})
-const router = useRouter();
-const { mdAndDown } = useDisplay();
-const notificationsStore = useNotificationsStore();
-const phonesStore = usePhonesStore();
-const { useApi } = useApiComposable();
-const { formatPhoneNumber } = useFilters();
+const router = useRouter()
+const { mdAndDown } = useDisplay()
+const notificationsStore = useNotificationsStore()
+const phonesStore = usePhonesStore()
+const { useApi } = useApiComposable()
+const { formatPhoneNumber } = useFilters()
-const sending = ref(false);
-const formPhoneNumber = ref("");
-const phoneCountry = ref("US");
-const formContent = ref("");
-const formAttachments = ref("");
-const errors = ref(new Map<string, string[]>());
+const sending = ref(false)
+const formPhoneNumber = ref('')
+const phoneCountry = ref('US')
+const formContent = ref('')
+const formAttachments = ref('')
+const errors = ref(new Map<string, string[]>())
function getRecipientNumber(): string {
- const phone = formPhoneNumber.value;
+ const phone = formPhoneNumber.value
if (isValidPhoneNumber(phone)) {
- return phone;
+ return phone
}
// Short code — strip the country dial code prefix
const dialCode = getCountryCallingCode(
phoneCountry.value.toUpperCase() as CountryCode,
- );
- const prefix = `+${dialCode}`;
+ )
+ const prefix = `+${dialCode}`
if (phone.startsWith(prefix)) {
- return phone.slice(prefix.length);
+ return phone.slice(prefix.length)
}
- return phone;
+ return phone
}
async function sendMessage() {
- errors.value = new Map();
- sending.value = true;
+ errors.value = new Map()
+ sending.value = true
try {
- const api = useApi();
- await api("/v1/messages/send", {
- method: "POST",
+ const api = useApi()
+ await api('/v1/messages/send', {
+ method: 'POST',
body: {
to: getRecipientNumber(),
from: phonesStore.owner,
content: formContent.value,
- sim: "DEFAULT",
+ sim: 'DEFAULT',
attachments: formAttachments.value
.trim()
- .split(",")
- .filter((x) => x.trim() !== "")
+ .split(',')
+ .filter((x) => x.trim() !== '')
.map((x) => x.trim()),
},
- });
+ })
notificationsStore.addNotification({
- message: "Message Sent!",
- type: "success",
- });
- await router.push("/threads");
- } catch (err: any) {
- const data = err?.data?.data;
+ message: 'Message Sent!',
+ type: 'success',
+ })
+ await router.push('/threads')
+ } catch (err: unknown) {
+ const data = toApiError(err).data?.data
if (data) {
- const newErrors = new Map<string, string[]>();
- if (data.content) newErrors.set("content", data.content);
+ const newErrors = new Map<string, string[]>()
+ if (data.content) newErrors.set('content', data.content)
if (data.to)
newErrors.set(
- "to",
+ 'to',
data.to.map((x: string) =>
- x.replace("to field", "phone number field"),
+ x.replace('to field', 'phone number field'),
),
- );
- if (data.attachments) newErrors.set("attachments", data.attachments);
+ )
+ if (data.attachments) newErrors.set('attachments', data.attachments)
if (data.from) {
notificationsStore.addNotification({
message: data.from[0],
- type: "error",
- });
+ type: 'error',
+ })
}
- errors.value = newErrors;
+ errors.value = newErrors
}
} finally {
- sending.value = false;
+ sending.value = false
}
}
onMounted(async () => {
- await phonesStore.loadPhones();
-});
+ await phonesStore.loadPhones()
+})
</script>
<template>
diff --git a/web/app/pages/phone-api-keys/index.vue b/web/app/pages/phone-api-keys/index.vue
index f3945163..12506dcb 100644
--- a/web/app/pages/phone-api-keys/index.vue
+++ b/web/app/pages/phone-api-keys/index.vue
@@ -1,222 +1,228 @@
<script setup lang="ts">
-import { mdiArrowLeft, mdiPlus, mdiDelete, mdiEye } from "@mdi/js";
-import QRCode from "qrcode";
-import Pusher from "pusher-js";
-import type { Channel } from "pusher-js";
-import { ErrorMessages } from "~/utils/errors";
-import type { EntitiesPhoneAPIKey } from "~~/shared/types/api";
+import { mdiArrowLeft, mdiPlus, mdiDelete, mdiEye } from '@mdi/js'
+import QRCode from 'qrcode'
+import Pusher from 'pusher-js'
+import type { Channel } from 'pusher-js'
+import { ErrorMessages } from '~/utils/errors'
+import { toApiError } from '~/utils/api-error'
+import type { EntitiesPhoneAPIKey } from '~~/shared/types/api'
definePageMeta({
- middleware: ["auth"],
-});
+ middleware: ['auth'],
+})
useHead({
- title: "Phone API Keys - httpSMS",
-});
+ title: 'Phone API Keys - httpSMS',
+})
-const config = useRuntimeConfig();
-const { mdAndDown, lgAndUp } = useDisplay();
-const authStore = useAuthStore();
-const appStore = useAppStore();
-const phonesStore = usePhonesStore();
-const notificationsStore = useNotificationsStore();
-const { formatTimestamp, formatPhoneNumber } = useFilters();
-const { useApi } = useApiComposable();
+const config = useRuntimeConfig()
+const { mdAndDown, lgAndUp } = useDisplay()
+const authStore = useAuthStore()
+const appStore = useAppStore()
+const phonesStore = usePhonesStore()
+const notificationsStore = useNotificationsStore()
+const { formatTimestamp, formatPhoneNumber } = useFilters()
+const { useApi } = useApiComposable()
-const loading = ref(true);
-const phoneApiKeys = ref<EntitiesPhoneAPIKey[]>([]);
-const errorMessages = ref(new ErrorMessages());
+const loading = ref(true)
+const phoneApiKeys = ref<EntitiesPhoneAPIKey[]>([])
+const errorMessages = ref(new ErrorMessages())
-const showCreateApiKeyDialog = ref(false);
-const formPhoneApiKeyName = ref("");
+const showCreateApiKeyDialog = ref(false)
+const formPhoneApiKeyName = ref('')
-const showPhoneApiKeyQrCode = ref(false);
-const deleteApiKeyDialog = ref(false);
-const removePhoneFromApiKeyDialog = ref(false);
-const activePhoneApiKey = ref<EntitiesPhoneAPIKey | null>(null);
-const activePhoneNumber = ref("");
+const showPhoneApiKeyQrCode = ref(false)
+const deleteApiKeyDialog = ref(false)
+const removePhoneFromApiKeyDialog = ref(false)
+const activePhoneApiKey = ref<EntitiesPhoneAPIKey | null>(null)
+const activePhoneNumber = ref('')
-const qrCodeCanvas = ref<HTMLCanvasElement | null>(null);
-let webhookChannel: Channel | null = null;
+const qrCodeCanvas = ref<HTMLCanvasElement | null>(null)
+let webhookChannel: Channel | null = null
-function parseErrors(error: any): ErrorMessages {
- const bag = new ErrorMessages();
- const data = error?.data?.data;
- if (data && typeof data === "object") {
- Object.keys(data).forEach((key) => bag.addMany(key, data[key]));
+function parseErrors(error: unknown): ErrorMessages {
+ const bag = new ErrorMessages()
+ const data = toApiError(error).data?.data
+ if (data && typeof data === 'object') {
+ Object.keys(data).forEach((key) => bag.addMany(key, data[key]))
}
- return bag;
+ return bag
}
async function loadPhoneApiKeys() {
- loading.value = true;
+ loading.value = true
try {
- const api = useApi();
+ const api = useApi()
const response = await api<{ data: EntitiesPhoneAPIKey[] }>(
- "/v1/phone-api-keys",
+ '/v1/phone-api-keys',
{ query: { limit: 100 } },
- );
- phoneApiKeys.value = response.data ?? [];
+ )
+ phoneApiKeys.value = response.data ?? []
} catch {
notificationsStore.addNotification({
- message: "Failed to load Phone API Keys",
- type: "error",
- });
+ message: 'Failed to load Phone API Keys',
+ type: 'error',
+ })
} finally {
- loading.value = false;
+ loading.value = false
}
}
async function createPhoneApiKey() {
- errorMessages.value = new ErrorMessages();
- loading.value = true;
+ errorMessages.value = new ErrorMessages()
+ loading.value = true
try {
- const api = useApi();
- await api("/v1/phone-api-keys", {
- method: "POST",
+ const api = useApi()
+ await api('/v1/phone-api-keys', {
+ method: 'POST',
body: { name: formPhoneApiKeyName.value },
- });
+ })
notificationsStore.addNotification({
- message: "Phone API Key created successfully",
- type: "success",
- });
- formPhoneApiKeyName.value = "";
- showCreateApiKeyDialog.value = false;
- await loadPhoneApiKeys();
- } catch (error: any) {
- errorMessages.value = parseErrors(error);
+ message: 'Phone API Key created successfully',
+ type: 'success',
+ })
+ formPhoneApiKeyName.value = ''
+ showCreateApiKeyDialog.value = false
+ await loadPhoneApiKeys()
+ } catch (error: unknown) {
+ errorMessages.value = parseErrors(error)
if (errorMessages.value.size() === 0) {
notificationsStore.addNotification({
- message: "Failed to create Phone API Key",
- type: "error",
- });
+ message: 'Failed to create Phone API Key',
+ type: 'error',
+ })
}
} finally {
- loading.value = false;
+ loading.value = false
}
}
function generateQrCode(text: string) {
- const canvas = qrCodeCanvas.value;
+ const canvas = qrCodeCanvas.value
if (!canvas) {
- return;
+ return
}
- QRCode.toCanvas(canvas, text, { errorCorrectionLevel: "H" }, (err: any) => {
- if (err) {
- notificationsStore.addNotification({
- message: "Failed to generate phone API key QR code",
- type: "error",
- });
- }
- });
+ QRCode.toCanvas(
+ canvas,
+ text,
+ { errorCorrectionLevel: 'H' },
+ (err: Error | null | undefined) => {
+ if (err) {
+ notificationsStore.addNotification({
+ message: 'Failed to generate phone API key QR code',
+ type: 'error',
+ })
+ }
+ },
+ )
}
function showPhoneApiKey(apiKey: EntitiesPhoneAPIKey) {
- activePhoneApiKey.value = apiKey;
- showPhoneApiKeyQrCode.value = true;
+ activePhoneApiKey.value = apiKey
+ showPhoneApiKeyQrCode.value = true
nextTick(() => {
- generateQrCode(apiKey.api_key);
- });
+ generateQrCode(apiKey.api_key)
+ })
}
function showDeletePhoneApiKeyDialog(apiKey: EntitiesPhoneAPIKey) {
- activePhoneApiKey.value = apiKey;
- deleteApiKeyDialog.value = true;
+ activePhoneApiKey.value = apiKey
+ deleteApiKeyDialog.value = true
}
function showRemovePhoneFromApiKeyDialog(
apiKey: EntitiesPhoneAPIKey,
phoneNumber: string,
) {
- activePhoneApiKey.value = apiKey;
- activePhoneNumber.value = phoneNumber;
- removePhoneFromApiKeyDialog.value = true;
+ activePhoneApiKey.value = apiKey
+ activePhoneNumber.value = phoneNumber
+ removePhoneFromApiKeyDialog.value = true
}
async function deleteApiKey() {
if (!activePhoneApiKey.value) {
- return;
+ return
}
- loading.value = true;
+ loading.value = true
try {
- const api = useApi();
+ const api = useApi()
await api(`/v1/phone-api-keys/${activePhoneApiKey.value.id}`, {
- method: "DELETE",
- });
+ method: 'DELETE',
+ })
notificationsStore.addNotification({
- message: "The phone API key has been deleted successfully",
- type: "success",
- });
- deleteApiKeyDialog.value = false;
- await loadPhoneApiKeys();
+ message: 'The phone API key has been deleted successfully',
+ type: 'success',
+ })
+ deleteApiKeyDialog.value = false
+ await loadPhoneApiKeys()
} catch {
notificationsStore.addNotification({
- message: "Failed to delete Phone API Key",
- type: "error",
- });
- loading.value = false;
+ message: 'Failed to delete Phone API Key',
+ type: 'error',
+ })
+ loading.value = false
}
}
async function removePhoneFromPhoneKey() {
if (!activePhoneApiKey.value) {
- return;
+ return
}
const phoneId = phonesStore.phones.find(
(phone) => phone.phone_number === activePhoneNumber.value,
- )?.id;
+ )?.id
if (!phoneId) {
notificationsStore.addNotification({
- message: "Could not find the phone to remove from the API key",
- type: "error",
- });
- return;
+ message: 'Could not find the phone to remove from the API key',
+ type: 'error',
+ })
+ return
}
- loading.value = true;
+ loading.value = true
try {
- const api = useApi();
+ const api = useApi()
await api(
`/v1/phone-api-keys/${activePhoneApiKey.value.id}/phones/${phoneId}`,
- { method: "DELETE" },
- );
+ { method: 'DELETE' },
+ )
notificationsStore.addNotification({
- message: "The phone has been removed from the phone API key successfully",
- type: "success",
- });
- removePhoneFromApiKeyDialog.value = false;
- await loadPhoneApiKeys();
+ message: 'The phone has been removed from the phone API key successfully',
+ type: 'success',
+ })
+ removePhoneFromApiKeyDialog.value = false
+ await loadPhoneApiKeys()
} catch {
notificationsStore.addNotification({
- message: "Failed to remove the phone from the Phone API Key",
- type: "error",
- });
- loading.value = false;
+ message: 'Failed to remove the phone from the Phone API Key',
+ type: 'error',
+ })
+ loading.value = false
}
}
onMounted(async () => {
- await authStore.loadUser();
- await phonesStore.loadPhones();
- await loadPhoneApiKeys();
+ await authStore.loadUser()
+ await phonesStore.loadPhones()
+ await loadPhoneApiKeys()
- const pusherKey = config.public.pusherKey as string;
- const pusherCluster = config.public.pusherCluster as string;
+ const pusherKey = config.public.pusherKey as string
+ const pusherCluster = config.public.pusherCluster as string
if (pusherKey && authStore.user?.id) {
- const pusher = new Pusher(pusherKey, { cluster: pusherCluster });
- webhookChannel = pusher.subscribe(authStore.user.id);
- webhookChannel.bind("phone.updated", () => {
+ const pusher = new Pusher(pusherKey, { cluster: pusherCluster })
+ webhookChannel = pusher.subscribe(authStore.user.id)
+ webhookChannel.bind('phone.updated', () => {
if (!loading.value) {
- loadPhoneApiKeys();
+ loadPhoneApiKeys()
}
- });
+ })
}
-});
+})
onBeforeUnmount(() => {
if (webhookChannel) {
- webhookChannel.unsubscribe();
+ webhookChannel.unsubscribe()
}
-});
+})
</script>
<template>
@@ -381,7 +387,7 @@ onBeforeUnmount(() => {
:loading="loading"
@click="createPhoneApiKey"
>
- Create<span class="mx-1" v-if="lgAndUp">Phone API</span>Key
+ Create<span v-if="lgAndUp" class="mx-1">Phone API</span>Key
</VBtn>
<VSpacer />
<VBtn
diff --git a/web/app/pages/privacy-policy/index.vue b/web/app/pages/privacy-policy/index.vue
index 9031199b..fcaeb572 100644
--- a/web/app/pages/privacy-policy/index.vue
+++ b/web/app/pages/privacy-policy/index.vue
@@ -1,11 +1,11 @@
<script setup lang="ts">
definePageMeta({
- layout: "website",
-});
+ layout: 'website',
+})
useHead({
- title: "Privacy Policy - httpSMS",
-});
+ title: 'Privacy Policy - httpSMS',
+})
</script>
<template>
diff --git a/web/app/pages/search-messages/index.vue b/web/app/pages/search-messages/index.vue
index b4a1dc57..1bdb102d 100644
--- a/web/app/pages/search-messages/index.vue
+++ b/web/app/pages/search-messages/index.vue
@@ -12,275 +12,275 @@ import {
mdiMagnify,
mdiProgressCheck,
mdiRefresh,
-} from "@mdi/js";
-import type { EntitiesMessage, EntitiesPhone } from "~~/shared/types/api";
-import type { SearchMessagesRequest } from "~~/shared/types/message";
-import { ErrorMessages } from "~/utils/errors";
+} from '@mdi/js'
+import type { EntitiesMessage, EntitiesPhone } from '~~/shared/types/api'
+import type { SearchMessagesRequest } from '~~/shared/types/message'
+import { ErrorMessages } from '~/utils/errors'
+import { toApiError } from '~/utils/api-error'
interface Turnstile {
- ready(callback: () => void): void;
+ ready(callback: () => void): void
render(
container: string | HTMLElement,
params?: {
- sitekey: string;
- action: string;
- callback?: (token: string) => void;
- "error-callback"?: (error: string) => void;
+ sitekey: string
+ action: string
+ callback?: (token: string) => void
+ 'error-callback'?: (error: string) => void
},
- ): string | null | undefined;
- remove(widgetId?: string): void;
+ ): string | null | undefined
+ remove(widgetId?: string): void
}
definePageMeta({
- middleware: ["auth"],
-});
+ middleware: ['auth'],
+})
useHead({
- title: "Search your Messages - httpSMS",
-});
-
-const route = useRoute();
-const config = useRuntimeConfig();
-const { mdAndDown, mdAndUp, smAndDown, lgAndUp } = useDisplay();
-const messagesStore = useMessagesStore();
-const phonesStore = usePhonesStore();
-const authStore = useAuthStore();
-const notificationsStore = useNotificationsStore();
-const { useApi } = useApiComposable();
-const { formatPhoneNumber, formatTimestamp, capitalize } = useFilters();
-
-const loading = ref(true);
-const initialLoadComplete = ref(false);
-const errorTitle = ref("");
-const showDeleteDialog = ref(false);
-const showResendDialog = ref(false);
-const errorMessages = ref(new ErrorMessages());
-
-const formOwners = ref<string[]>([]);
-const formTypes = ref<string[]>([]);
-const formStatuses = ref<string[]>([]);
-const formQuery = ref("");
-
-const messages = ref<EntitiesMessage[]>([]);
-const totalMessages = ref(0);
-const selectedIds = ref<string[]>([]);
-let turnstileWidgetId: string | null = null;
-
-const page = ref(1);
-const itemsPerPage = ref(100);
-const sortBy = ref<{ key: string; order: "asc" | "desc" }[]>([
- { key: "created_at", order: "desc" },
-]);
+ title: 'Search your Messages - httpSMS',
+})
+
+const route = useRoute()
+const config = useRuntimeConfig()
+const { mdAndDown, mdAndUp, smAndDown, lgAndUp } = useDisplay()
+const messagesStore = useMessagesStore()
+const phonesStore = usePhonesStore()
+const authStore = useAuthStore()
+const notificationsStore = useNotificationsStore()
+const { useApi } = useApiComposable()
+const { formatPhoneNumber, formatTimestamp, capitalize } = useFilters()
+
+const loading = ref(true)
+const initialLoadComplete = ref(false)
+const errorTitle = ref('')
+const showDeleteDialog = ref(false)
+const showResendDialog = ref(false)
+const errorMessages = ref(new ErrorMessages())
+
+const formOwners = ref<string[]>([])
+const formTypes = ref<string[]>([])
+const formStatuses = ref<string[]>([])
+const formQuery = ref('')
+
+const messages = ref<EntitiesMessage[]>([])
+const totalMessages = ref(0)
+const selectedIds = ref<string[]>([])
+let turnstileWidgetId: string | null = null
+
+const page = ref(1)
+const itemsPerPage = ref(100)
+const sortBy = ref<{ key: string; order: 'asc' | 'desc' }[]>([
+ { key: 'created_at', order: 'desc' },
+])
const itemsPerPageOptions = [
- { value: 10, title: "10" },
- { value: 50, title: "50" },
- { value: 100, title: "100" },
- { value: 200, title: "200" },
-];
+ { value: 10, title: '10' },
+ { value: 50, title: '50' },
+ { value: 100, title: '100' },
+ { value: 200, title: '200' },
+]
const headers = [
- { title: "Created At", key: "created_at" },
- { title: "Owner", key: "owner" },
- { title: "Contact", key: "contact" },
- { title: "Message Type", key: "type" },
- { title: "Status", key: "status" },
- { title: "Message Content", key: "content", sortable: false },
-];
+ { title: 'Created At', key: 'created_at' },
+ { title: 'Owner', key: 'owner' },
+ { title: 'Contact', key: 'contact' },
+ { title: 'Message Type', key: 'type' },
+ { title: 'Status', key: 'status' },
+ { title: 'Message Content', key: 'content', sortable: false },
+]
const selectedMessages = computed<EntitiesMessage[]>(() =>
messages.value.filter((message) => selectedIds.value.includes(message.id)),
-);
+)
const canResendSelected = computed<boolean>(
() =>
selectedMessages.value.length > 0 &&
selectedMessages.value.every(
(message) =>
- message.type === "mobile-terminated" &&
- (message.status === "expired" || message.status === "failed"),
+ message.type === 'mobile-terminated' &&
+ (message.status === 'expired' || message.status === 'failed'),
),
-);
+)
const phoneNumberSelectItems = computed(() =>
phonesStore.phones.map((phone: EntitiesPhone) => ({
title: formatPhoneNumber(phone.phone_number),
value: phone.phone_number,
})),
-);
+)
const messageTypeSelectItems = [
- { title: "Outbound", value: "mobile-terminated" },
- { title: "Inbound", value: "mobile-originated" },
- { title: "Missed Calls", value: "call/missed" },
-];
+ { title: 'Outbound', value: 'mobile-terminated' },
+ { title: 'Inbound', value: 'mobile-originated' },
+ { title: 'Missed Calls', value: 'call/missed' },
+]
const messageStatusSelectItems = [
- { value: "pending", title: "Pending" },
- { value: "sent", title: "Sent" },
- { value: "delivered", title: "Delivered" },
- { value: "failed", title: "Failed" },
- { value: "expired", title: "Expired" },
- { value: "received", title: "Received" },
-];
+ { value: 'pending', title: 'Pending' },
+ { value: 'sent', title: 'Sent' },
+ { value: 'delivered', title: 'Delivered' },
+ { value: 'failed', title: 'Failed' },
+ { value: 'expired', title: 'Expired' },
+ { value: 'received', title: 'Received' },
+]
function getCaptcha(): Promise<string> {
return new Promise<string>((resolve, reject) => {
const turnstile: Turnstile = (
window as unknown as { turnstile?: Turnstile }
- ).turnstile!;
+ ).turnstile!
turnstile.ready(() => {
if (turnstileWidgetId) {
- turnstile.remove(turnstileWidgetId);
- turnstileWidgetId = null;
+ turnstile.remove(turnstileWidgetId)
+ turnstileWidgetId = null
}
turnstileWidgetId =
- turnstile.render("#cloudflare-turnstile", {
+ turnstile.render('#cloudflare-turnstile', {
sitekey: (config.public as Record<string, string>)
.cloudflareTurnstileSiteKey!,
- action: "search_messages",
+ action: 'search_messages',
callback: (token) => resolve(token),
- "error-callback": (error: string) => reject(error),
- }) ?? null;
- });
- });
+ 'error-callback': (error: string) => reject(error),
+ }) ?? null
+ })
+ })
}
-function parseErrors(error: any): ErrorMessages {
- const bag = new ErrorMessages();
- const data = error?.data?.data;
- if (data && typeof data === "object") {
- Object.keys(data).forEach((key) => bag.addMany(key, data[key]));
+function parseErrors(error: unknown): ErrorMessages {
+ const bag = new ErrorMessages()
+ const data = toApiError(error).data?.data
+ if (data && typeof data === 'object') {
+ Object.keys(data).forEach((key) => bag.addMany(key, data[key]))
}
- return bag;
+ return bag
}
async function fetchMessages(reset = false) {
- loading.value = true;
- errorMessages.value = new ErrorMessages();
- errorTitle.value = "";
+ loading.value = true
+ errorMessages.value = new ErrorMessages()
+ errorTitle.value = ''
if (reset) {
- page.value = 1;
+ page.value = 1
}
try {
- const token = await getCaptcha();
- const sort = sortBy.value[0];
+ const token = await getCaptcha()
+ const sort = sortBy.value[0]
const results = await messagesStore.searchMessages({
token,
owners: formOwners.value,
types: formTypes.value,
statuses: formStatuses.value,
query: formQuery.value,
- sort_by: sort?.key ?? "created_at",
- sort_descending: sort ? sort.order === "desc" : true,
+ sort_by: sort?.key ?? 'created_at',
+ sort_descending: sort ? sort.order === 'desc' : true,
skip: (page.value - 1) * itemsPerPage.value,
limit: itemsPerPage.value,
- } as SearchMessagesRequest);
+ } as SearchMessagesRequest)
- messages.value = results;
- totalMessages.value =
- (page.value - 1) * itemsPerPage.value + results.length;
+ messages.value = results
+ totalMessages.value = (page.value - 1) * itemsPerPage.value + results.length
if (results.length === itemsPerPage.value) {
- totalMessages.value += 1;
+ totalMessages.value += 1
}
- } catch (error: any) {
+ } catch (error: unknown) {
errorTitle.value = capitalize(
- error?.data?.message ??
- "Error while searching messages. Contact us via email",
- );
- errorMessages.value = parseErrors(error);
+ toApiError(error).data?.message ??
+ 'Error while searching messages. Contact us via email',
+ )
+ errorMessages.value = parseErrors(error)
} finally {
- loading.value = false;
+ loading.value = false
}
}
function onUpdateOptions(options: {
- page: number;
- itemsPerPage: number;
- sortBy: { key: string; order: "asc" | "desc" }[];
+ page: number
+ itemsPerPage: number
+ sortBy: { key: string; order: 'asc' | 'desc' }[]
}) {
- page.value = options.page;
- itemsPerPage.value = options.itemsPerPage;
+ page.value = options.page
+ itemsPerPage.value = options.itemsPerPage
sortBy.value = options.sortBy.length
? options.sortBy
- : [{ key: "created_at", order: "desc" }];
+ : [{ key: 'created_at', order: 'desc' }]
if (!initialLoadComplete.value) {
- return;
+ return
}
- fetchMessages();
+ fetchMessages()
}
function sanitizeContent(content: string): string {
- content = content.replaceAll('"', '""');
- return content.includes(",") ? '"' + content + '"' : content;
+ content = content.replaceAll('"', '""')
+ return content.includes(',') ? '"' + content + '"' : content
}
function exportMessages() {
- let csvContent = "data:text/csv;charset=utf-8,";
+ let csvContent = 'data:text/csv;charset=utf-8,'
csvContent +=
- "Message ID,Created At,Owner,Contact,Message Type,Status,Message Content\n";
+ 'Message ID,Created At,Owner,Contact,Message Type,Status,Message Content\n'
selectedMessages.value.forEach((message) => {
csvContent += `${message.id},${new Date(
message.created_at,
).toLocaleString()},${message.owner},${message.contact},${message.type},${
message.status
- },${sanitizeContent(message.content)}\n`;
- });
+ },${sanitizeContent(message.content)}\n`
+ })
- const encodedUri = encodeURI(csvContent);
- const link = document.createElement("a");
- link.setAttribute("href", encodedUri);
+ const encodedUri = encodeURI(csvContent)
+ const link = document.createElement('a')
+ link.setAttribute('href', encodedUri)
link.setAttribute(
- "download",
+ 'download',
`httpsms-${new Date().toJSON().slice(0, 10)}.csv`,
- );
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
+ )
+ document.body.appendChild(link)
+ link.click()
+ document.body.removeChild(link)
notificationsStore.addNotification({
- message: "The selected messages have been exported successfully",
- type: "success",
- });
+ message: 'The selected messages have been exported successfully',
+ type: 'success',
+ })
}
async function deleteMessages() {
- loading.value = true;
+ loading.value = true
try {
await Promise.all(
selectedMessages.value.map((message) =>
messagesStore.deleteMessage(message.id),
),
- );
+ )
notificationsStore.addNotification({
- message: "The selected messages have been deleted successfully",
- type: "success",
- });
- selectedIds.value = [];
+ message: 'The selected messages have been deleted successfully',
+ type: 'success',
+ })
+ selectedIds.value = []
} catch {
notificationsStore.addNotification({
- message: "Error while deleting the selected messages",
- type: "error",
- });
+ message: 'Error while deleting the selected messages',
+ type: 'error',
+ })
} finally {
- loading.value = false;
- showDeleteDialog.value = false;
- fetchMessages();
+ loading.value = false
+ showDeleteDialog.value = false
+ fetchMessages()
}
}
async function resendMessages() {
- loading.value = true;
- const api = useApi();
+ loading.value = true
+ const api = useApi()
try {
const results = await Promise.allSettled(
selectedMessages.value.map((message) =>
- api("/v1/messages/send", {
- method: "POST",
+ api('/v1/messages/send', {
+ method: 'POST',
body: {
from: message.owner,
to: message.contact,
@@ -290,60 +290,60 @@ async function resendMessages() {
},
}),
),
- );
+ )
- const failed = results.filter((r) => r.status === "rejected");
+ const failed = results.filter((r) => r.status === 'rejected')
if (failed.length === 0) {
notificationsStore.addNotification({
- message: "The selected messages have been queued for resending",
- type: "success",
- });
- selectedIds.value = [];
+ message: 'The selected messages have been queued for resending',
+ type: 'success',
+ })
+ selectedIds.value = []
} else if (failed.length === results.length) {
notificationsStore.addNotification({
- message: "Error while resending the selected messages",
- type: "error",
- });
+ message: 'Error while resending the selected messages',
+ type: 'error',
+ })
} else {
notificationsStore.addNotification({
message: `${results.length - failed.length} messages resent, ${
failed.length
} failed`,
- type: "info",
- });
- selectedIds.value = [];
+ type: 'info',
+ })
+ selectedIds.value = []
}
} finally {
- loading.value = false;
- showResendDialog.value = false;
- fetchMessages();
+ loading.value = false
+ showResendDialog.value = false
+ fetchMessages()
}
}
onMounted(async () => {
- await authStore.loadUser();
- await phonesStore.loadPhones();
+ await authStore.loadUser()
+ await phonesStore.loadPhones()
- const queryParam = route.query.query;
- if (queryParam && typeof queryParam === "string") {
- formQuery.value = queryParam;
+ const queryParam = route.query.query
+ if (queryParam && typeof queryParam === 'string') {
+ formQuery.value = queryParam
}
- loading.value = false;
- initialLoadComplete.value = true;
+ loading.value = false
+ initialLoadComplete.value = true
if (formQuery.value) {
- await fetchMessages(true);
+ await fetchMessages(true)
}
-});
+})
onBeforeUnmount(() => {
- const turnstile = (window as unknown as { turnstile?: Turnstile }).turnstile;
+ const turnstile = (window as unknown as { turnstile?: Turnstile }).turnstile
if (turnstile && turnstileWidgetId) {
- turnstile.remove(turnstileWidgetId);
- turnstileWidgetId = null;
+ turnstile.remove(turnstileWidgetId)
+ turnstileWidgetId = null
}
-});
+})
</script>
<template>
diff --git a/web/app/pages/settings/index.vue b/web/app/pages/settings/index.vue
index cbd675da..3e80baaf 100644
--- a/web/app/pages/settings/index.vue
+++ b/web/app/pages/settings/index.vue
@@ -12,133 +12,136 @@ import {
mdiDelete,
mdiContentSave,
mdiConnection,
- mdiClose,
mdiCalendarClock,
mdiPlus,
-} from "@mdi/js";
-import { getAuth, signOut, type User as FirebaseUser } from "firebase/auth";
-import QRCode from "qrcode";
-import { ErrorMessages } from "~/utils/errors";
+} from '@mdi/js'
+import { getAuth, signOut, type User as FirebaseUser } from 'firebase/auth'
+import QRCode from 'qrcode'
+import { ErrorMessages } from '~/utils/errors'
+import { toApiError } from '~/utils/api-error'
import type {
EntitiesPhone,
EntitiesWebhook,
EntitiesDiscord,
EntitiesMessageSendSchedule,
-} from "~~/shared/types/api";
+} from '~~/shared/types/api'
definePageMeta({
- middleware: ["auth"],
-});
+ middleware: ['auth'],
+})
useHead({
- title: "Settings - httpSMS",
-});
+ title: 'Settings - httpSMS',
+})
-const config = useRuntimeConfig();
-const route = useRoute();
-const router = useRouter();
-const { mdAndDown, mdAndUp, lgAndUp, xlAndUp, smAndUp } = useDisplay();
-const authStore = useAuthStore();
-const phonesStore = usePhonesStore();
-const billingStore = useBillingStore();
-const notificationsStore = useNotificationsStore();
+const config = useRuntimeConfig()
+const route = useRoute()
+const router = useRouter()
+const { mdAndDown, mdAndUp, lgAndUp, xlAndUp, smAndUp } = useDisplay()
+const authStore = useAuthStore()
+const phonesStore = usePhonesStore()
+const billingStore = useBillingStore()
+const notificationsStore = useNotificationsStore()
-const firebaseUser = ref<FirebaseUser | null>(null);
+const firebaseUser = ref<FirebaseUser | null>(null)
-const apiKeyShow = ref(false);
-const showQrCodeDialog = ref(false);
-const showRotateApiKey = ref(false);
-const rotatingApiKey = ref(false);
-const qrCodeCanvas = ref<HTMLCanvasElement | null>(null);
+const apiKeyShow = ref(false)
+const showQrCodeDialog = ref(false)
+const showRotateApiKey = ref(false)
+const rotatingApiKey = ref(false)
+const qrCodeCanvas = ref<HTMLCanvasElement | null>(null)
-const errorMessages = ref(new ErrorMessages());
+const errorMessages = ref(new ErrorMessages())
// Timezones
const timezones = (() => {
try {
- return (Intl as any).supportedValuesOf("timeZone") as string[];
+ const intlWithTimeZones = Intl as typeof Intl & {
+ supportedValuesOf(key: string): string[]
+ }
+ return intlWithTimeZones.supportedValuesOf('timeZone')
} catch {
- return [] as string[];
+ return [] as string[]
}
-})();
+})()
-const apiKey = computed(() => authStore.user?.api_key ?? "");
+const apiKey = computed(() => authStore.user?.api_key ?? '')
const hasActiveSubscription = computed(() => {
- if (authStore.user === null) return true;
- return authStore.user.subscription_renews_at != null;
-});
+ if (authStore.user === null) return true
+ return authStore.user.subscription_renews_at != null
+})
const phoneNumbers = computed(() =>
phonesStore.phones.map((phone) => phone.phone_number),
-);
+)
const webhookEventOptions = [
- "message.phone.received",
- "message.phone.sent",
- "message.phone.delivered",
- "message.send.failed",
- "message.send.expired",
- "message.call.missed",
- "phone.heartbeat.offline",
- "phone.heartbeat.online",
-];
+ 'message.phone.received',
+ 'message.phone.sent',
+ 'message.phone.delivered',
+ 'message.send.failed',
+ 'message.send.expired',
+ 'message.call.missed',
+ 'phone.heartbeat.offline',
+ 'phone.heartbeat.online',
+]
function resetErrors() {
- errorMessages.value = new ErrorMessages();
+ errorMessages.value = new ErrorMessages()
}
-function parseErrors(error: any): ErrorMessages {
- const bag = new ErrorMessages();
- const data = error?.data?.data;
- if (data && typeof data === "object") {
- Object.keys(data).forEach((key) => bag.addMany(key, data[key]));
+function parseErrors(error: unknown): ErrorMessages {
+ const bag = new ErrorMessages()
+ const data = toApiError(error).data?.data
+ if (data && typeof data === 'object') {
+ Object.keys(data).forEach((key) => bag.addMany(key, data[key]))
}
- return bag;
+ return bag
}
// ---------------------------------------------------------------------------
// API Key
// ---------------------------------------------------------------------------
async function rotateApiKey() {
- if (!authStore.user) return;
- rotatingApiKey.value = true;
+ if (!authStore.user) return
+ rotatingApiKey.value = true
try {
- await authStore.rotateApiKey(authStore.user.id);
- showRotateApiKey.value = false;
+ await authStore.rotateApiKey(authStore.user.id)
+ showRotateApiKey.value = false
notificationsStore.addNotification({
- message: "API Key rotated successfully",
- type: "success",
- });
+ message: 'API Key rotated successfully',
+ type: 'success',
+ })
} catch {
notificationsStore.addNotification({
- message: "Failed to rotate API Key",
- type: "error",
- });
+ message: 'Failed to rotate API Key',
+ type: 'error',
+ })
} finally {
- rotatingApiKey.value = false;
+ rotatingApiKey.value = false
}
}
function generateQrCode() {
- showQrCodeDialog.value = true;
+ showQrCodeDialog.value = true
nextTick(() => {
if (qrCodeCanvas.value) {
QRCode.toCanvas(
qrCodeCanvas.value,
apiKey.value,
- { errorCorrectionLevel: "H", width: 300, margin: 2 },
+ { errorCorrectionLevel: 'H', width: 300, margin: 2 },
(err) => {
if (err) {
notificationsStore.addNotification({
- message: "Failed to generate API key QR code",
- type: "error",
- });
+ message: 'Failed to generate API key QR code',
+ type: 'error',
+ })
}
},
- );
+ )
}
- });
+ })
}
// ---------------------------------------------------------------------------
@@ -146,71 +149,71 @@ function generateQrCode() {
// ---------------------------------------------------------------------------
async function updateTimezone(timezone: string) {
try {
- await authStore.updateUser({ timezone });
+ await authStore.updateUser({ timezone })
notificationsStore.addNotification({
- message: "Timezone updated successfully",
- type: "success",
- });
+ message: 'Timezone updated successfully',
+ type: 'success',
+ })
} catch {
notificationsStore.addNotification({
- message: "Failed to update timezone",
- type: "error",
- });
+ message: 'Failed to update timezone',
+ type: 'error',
+ })
}
}
// ---------------------------------------------------------------------------
// Webhooks
// ---------------------------------------------------------------------------
-const loadingWebhooks = ref(true);
-const webhooks = ref<EntitiesWebhook[]>([]);
-const updatingWebhook = ref(false);
-const showWebhookEdit = ref(false);
+const loadingWebhooks = ref(true)
+const webhooks = ref<EntitiesWebhook[]>([])
+const updatingWebhook = ref(false)
+const showWebhookEdit = ref(false)
const activeWebhook = ref<{
- id: string | null;
- url: string;
- signing_key: string;
- phone_numbers: string[];
- events: string[];
+ id: string | null
+ url: string
+ signing_key: string
+ phone_numbers: string[]
+ events: string[]
}>({
id: null,
- url: "",
- signing_key: "",
+ url: '',
+ signing_key: '',
phone_numbers: [],
- events: ["message.phone.received"],
-});
+ events: ['message.phone.received'],
+})
async function loadWebhooks() {
- loadingWebhooks.value = true;
+ loadingWebhooks.value = true
try {
- webhooks.value = await billingStore.getWebhooks();
+ webhooks.value = await billingStore.getWebhooks()
} finally {
- loadingWebhooks.value = false;
+ loadingWebhooks.value = false
}
}
function onWebhookCreate() {
- resetErrors();
+ resetErrors()
activeWebhook.value = {
id: null,
- url: "",
- signing_key: "",
+ url: '',
+ signing_key: '',
phone_numbers: phoneNumbers.value.slice(),
events: [
- "message.phone.received",
- "message.phone.sent",
- "message.phone.delivered",
- "message.send.failed",
- "message.send.expired",
+ 'message.phone.received',
+ 'message.phone.sent',
+ 'message.phone.delivered',
+ 'message.send.failed',
+ 'message.send.expired',
],
- };
- showWebhookEdit.value = true;
+ }
+ showWebhookEdit.value = true
}
function onWebhookEdit(webhookId: string) {
- const webhook = webhooks.value.find((x) => x.id === webhookId);
- if (!webhook) return;
- resetErrors();
+ const webhook = webhooks.value.find((x) => x.id === webhookId)
+ if (!webhook) return
+ resetErrors()
activeWebhook.value = {
id: webhook.id,
url: webhook.url,
@@ -219,279 +222,279 @@ function onWebhookEdit(webhookId: string) {
phoneNumbers.value.includes(x),
),
events: webhook.events ?? [],
- };
- showWebhookEdit.value = true;
+ }
+ showWebhookEdit.value = true
}
async function saveWebhook() {
- resetErrors();
- updatingWebhook.value = true;
+ resetErrors()
+ updatingWebhook.value = true
try {
const payload = {
url: activeWebhook.value.url,
signing_key: activeWebhook.value.signing_key,
phone_numbers: activeWebhook.value.phone_numbers,
events: activeWebhook.value.events,
- };
+ }
if (activeWebhook.value.id) {
await billingStore.updateWebhook({
id: activeWebhook.value.id,
...payload,
- });
+ })
} else {
- await billingStore.createWebhook(payload);
+ await billingStore.createWebhook(payload)
}
notificationsStore.addNotification({
- message: `Webhook ${activeWebhook.value.id ? "updated" : "created"} successfully`,
- type: "success",
- });
- showWebhookEdit.value = false;
- await loadWebhooks();
- } catch (error: any) {
- errorMessages.value = parseErrors(error);
+ message: `Webhook ${activeWebhook.value.id ? 'updated' : 'created'} successfully`,
+ type: 'success',
+ })
+ showWebhookEdit.value = false
+ await loadWebhooks()
+ } catch (error: unknown) {
+ errorMessages.value = parseErrors(error)
if (errorMessages.value.size() === 0) {
notificationsStore.addNotification({
- message: "Failed to save webhook",
- type: "error",
- });
+ message: 'Failed to save webhook',
+ type: 'error',
+ })
}
} finally {
- updatingWebhook.value = false;
+ updatingWebhook.value = false
}
}
async function deleteWebhook(id: string) {
- updatingWebhook.value = true;
+ updatingWebhook.value = true
try {
- await billingStore.deleteWebhook(id);
+ await billingStore.deleteWebhook(id)
notificationsStore.addNotification({
- message: "Webhook deleted successfully",
- type: "success",
- });
- showWebhookEdit.value = false;
- await loadWebhooks();
+ message: 'Webhook deleted successfully',
+ type: 'success',
+ })
+ showWebhookEdit.value = false
+ await loadWebhooks()
} catch {
notificationsStore.addNotification({
- message: "Failed to delete webhook",
- type: "error",
- });
+ message: 'Failed to delete webhook',
+ type: 'error',
+ })
} finally {
- updatingWebhook.value = false;
+ updatingWebhook.value = false
}
}
// ---------------------------------------------------------------------------
// Discord
// ---------------------------------------------------------------------------
-const loadingDiscordIntegrations = ref(true);
-const discords = ref<EntitiesDiscord[]>([]);
-const updatingDiscord = ref(false);
-const showDiscordEdit = ref(false);
+const loadingDiscordIntegrations = ref(true)
+const discords = ref<EntitiesDiscord[]>([])
+const updatingDiscord = ref(false)
+const showDiscordEdit = ref(false)
const activeDiscord = ref<{
- id: string | null;
- name: string;
- server_id: string;
- incoming_channel_id: string;
+ id: string | null
+ name: string
+ server_id: string
+ incoming_channel_id: string
}>({
id: null,
- name: "",
- server_id: "",
- incoming_channel_id: "",
-});
+ name: '',
+ server_id: '',
+ incoming_channel_id: '',
+})
async function loadDiscordIntegrations() {
- loadingDiscordIntegrations.value = true;
+ loadingDiscordIntegrations.value = true
try {
- discords.value = await billingStore.getDiscordIntegrations();
+ discords.value = await billingStore.getDiscordIntegrations()
} finally {
- loadingDiscordIntegrations.value = false;
+ loadingDiscordIntegrations.value = false
}
}
function onDiscordCreate() {
- resetErrors();
+ resetErrors()
activeDiscord.value = {
id: null,
- name: "",
- server_id: "",
- incoming_channel_id: "",
- };
- showDiscordEdit.value = true;
+ name: '',
+ server_id: '',
+ incoming_channel_id: '',
+ }
+ showDiscordEdit.value = true
}
function onDiscordEdit(discordId: string) {
- const discord = discords.value.find((x) => x.id === discordId);
- if (!discord) return;
- resetErrors();
+ const discord = discords.value.find((x) => x.id === discordId)
+ if (!discord) return
+ resetErrors()
activeDiscord.value = {
id: discord.id,
name: discord.name,
server_id: discord.server_id,
incoming_channel_id: discord.incoming_channel_id,
- };
- showDiscordEdit.value = true;
+ }
+ showDiscordEdit.value = true
}
async function saveDiscord() {
- resetErrors();
- updatingDiscord.value = true;
+ resetErrors()
+ updatingDiscord.value = true
try {
const payload = {
name: activeDiscord.value.name,
server_id: activeDiscord.value.server_id,
incoming_channel_id: activeDiscord.value.incoming_channel_id,
- };
+ }
if (activeDiscord.value.id) {
await billingStore.updateDiscordIntegration({
id: activeDiscord.value.id,
...payload,
- });
+ })
} else {
- await billingStore.createDiscord(payload);
+ await billingStore.createDiscord(payload)
}
notificationsStore.addNotification({
- message: `Discord integration ${activeDiscord.value.id ? "updated" : "created"} successfully`,
- type: "success",
- });
- showDiscordEdit.value = false;
- await loadDiscordIntegrations();
- } catch (error: any) {
- errorMessages.value = parseErrors(error);
+ message: `Discord integration ${activeDiscord.value.id ? 'updated' : 'created'} successfully`,
+ type: 'success',
+ })
+ showDiscordEdit.value = false
+ await loadDiscordIntegrations()
+ } catch (error: unknown) {
+ errorMessages.value = parseErrors(error)
if (errorMessages.value.size() === 0) {
notificationsStore.addNotification({
- message: "Failed to save discord integration",
- type: "error",
- });
+ message: 'Failed to save discord integration',
+ type: 'error',
+ })
}
} finally {
- updatingDiscord.value = false;
+ updatingDiscord.value = false
}
}
async function deleteDiscord(id: string) {
- updatingDiscord.value = true;
+ updatingDiscord.value = true
try {
- await billingStore.deleteDiscordIntegration(id);
+ await billingStore.deleteDiscordIntegration(id)
notificationsStore.addNotification({
- message: "Discord integration deleted successfully",
- type: "success",
- });
- showDiscordEdit.value = false;
- await loadDiscordIntegrations();
+ message: 'Discord integration deleted successfully',
+ type: 'success',
+ })
+ showDiscordEdit.value = false
+ await loadDiscordIntegrations()
} catch {
notificationsStore.addNotification({
- message: "Failed to delete discord integration",
- type: "error",
- });
+ message: 'Failed to delete discord integration',
+ type: 'error',
+ })
} finally {
- updatingDiscord.value = false;
+ updatingDiscord.value = false
}
}
// ---------------------------------------------------------------------------
// Phones
// ---------------------------------------------------------------------------
-const updatingPhone = ref(false);
-const showPhoneEdit = ref(false);
-const activePhone = ref<EntitiesPhone | null>(null);
+const updatingPhone = ref(false)
+const showPhoneEdit = ref(false)
+const activePhone = ref<EntitiesPhone | null>(null)
function showEditPhone(phoneId: string) {
- const phone = phonesStore.phones.find((x) => x.id === phoneId);
- if (!phone) return;
- resetErrors();
- activePhone.value = { ...phone };
- showPhoneEdit.value = true;
+ const phone = phonesStore.phones.find((x) => x.id === phoneId)
+ if (!phone) return
+ resetErrors()
+ activePhone.value = { ...phone }
+ showPhoneEdit.value = true
}
async function updatePhone() {
- if (!activePhone.value) return;
- updatingPhone.value = true;
+ if (!activePhone.value) return
+ updatingPhone.value = true
try {
- await phonesStore.updatePhone(activePhone.value);
- showPhoneEdit.value = false;
- activePhone.value = null;
+ await phonesStore.updatePhone(activePhone.value)
+ showPhoneEdit.value = false
+ activePhone.value = null
} finally {
- updatingPhone.value = false;
+ updatingPhone.value = false
}
}
async function deletePhone(phoneId: string) {
- updatingPhone.value = true;
+ updatingPhone.value = true
try {
- await phonesStore.deletePhone(phoneId);
+ await phonesStore.deletePhone(phoneId)
notificationsStore.addNotification({
- message: "Phone deleted successfully",
- type: "success",
- });
- showPhoneEdit.value = false;
- activePhone.value = null;
+ message: 'Phone deleted successfully',
+ type: 'success',
+ })
+ showPhoneEdit.value = false
+ activePhone.value = null
} catch {
notificationsStore.addNotification({
- message: "Failed to delete phone",
- type: "error",
- });
+ message: 'Failed to delete phone',
+ type: 'error',
+ })
} finally {
- updatingPhone.value = false;
+ updatingPhone.value = false
}
}
// ---------------------------------------------------------------------------
// Send Schedules
// ---------------------------------------------------------------------------
-const loadingSendSchedules = ref(true);
-const sendSchedules = ref<EntitiesMessageSendSchedule[]>([]);
-const showScheduleEdit = ref(false);
-const showScheduleDelete = ref(false);
-const savingSchedule = ref(false);
+const loadingSendSchedules = ref(true)
+const sendSchedules = ref<EntitiesMessageSendSchedule[]>([])
+const showScheduleEdit = ref(false)
+const showScheduleDelete = ref(false)
+const savingSchedule = ref(false)
const activeSchedule = ref<{
- id: string | null;
- name: string;
- timezone: string;
+ id: string | null
+ name: string
+ timezone: string
windows: Array<{
- day_of_week: number;
- start_time: string;
- end_time: string;
- }>;
+ day_of_week: number
+ start_time: string
+ end_time: string
+ }>
}>({
id: null,
- name: "",
- timezone: "",
+ name: '',
+ timezone: '',
windows: [],
-});
+})
const weekDays = [
- { value: 1, label: "Monday" },
- { value: 2, label: "Tuesday" },
- { value: 3, label: "Wednesday" },
- { value: 4, label: "Thursday" },
- { value: 5, label: "Friday" },
- { value: 6, label: "Saturday" },
- { value: 0, label: "Sunday" },
-];
+ { value: 1, label: 'Monday' },
+ { value: 2, label: 'Tuesday' },
+ { value: 3, label: 'Wednesday' },
+ { value: 4, label: 'Thursday' },
+ { value: 5, label: 'Friday' },
+ { value: 6, label: 'Saturday' },
+ { value: 0, label: 'Sunday' },
+]
async function loadSendSchedules() {
- loadingSendSchedules.value = true;
+ loadingSendSchedules.value = true
try {
- sendSchedules.value = await billingStore.getSendSchedules();
+ sendSchedules.value = await billingStore.getSendSchedules()
} finally {
- loadingSendSchedules.value = false;
+ loadingSendSchedules.value = false
}
}
function minuteToClock(value: number): string {
- const hours = String(Math.floor(value / 60)).padStart(2, "0");
- const minutes = String(value % 60).padStart(2, "0");
- return `${hours}:${minutes}`;
+ const hours = String(Math.floor(value / 60)).padStart(2, '0')
+ const minutes = String(value % 60).padStart(2, '0')
+ return `${hours}:${minutes}`
}
function clockToMinute(value: string): number {
- if (!value || !value.includes(":")) return 0;
- const [hours = 0, minutes = 0] = value.split(":").map((x) => parseInt(x, 10));
- return hours * 60 + minutes;
+ if (!value || !value.includes(':')) return 0
+ const [hours = 0, minutes = 0] = value.split(':').map((x) => parseInt(x, 10))
+ return hours * 60 + minutes
}
function getWeekday(index: number): string {
- return weekDays.find((x) => x.value === index)?.label ?? "";
+ return weekDays.find((x) => x.value === index)?.label ?? ''
}
function scheduleSummary(schedule: EntitiesMessageSendSchedule): string[][] {
@@ -499,8 +502,8 @@ function scheduleSummary(schedule: EntitiesMessageSendSchedule): string[][] {
.map((day) => {
const windows = (schedule.windows || []).filter(
(x) => x.day_of_week === day.value,
- );
- if (windows.length === 0) return [];
+ )
+ if (windows.length === 0) return []
return [
day.label,
windows
@@ -508,35 +511,35 @@ function scheduleSummary(schedule: EntitiesMessageSendSchedule): string[][] {
(w) =>
`${minuteToClock(w.start_minute)} - ${minuteToClock(w.end_minute)}`,
)
- .join(", "),
- ];
+ .join(', '),
+ ]
})
- .filter((x) => x.length > 0);
+ .filter((x) => x.length > 0)
}
function defaultTimezone(): string {
return (
authStore.user?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone
- );
+ )
}
function openCreateSchedule() {
- resetErrors();
+ resetErrors()
activeSchedule.value = {
id: null,
- name: "",
+ name: '',
timezone: defaultTimezone(),
windows: [1, 2, 3, 4, 5].map((day) => ({
day_of_week: day,
- start_time: "09:00",
- end_time: "17:00",
+ start_time: '09:00',
+ end_time: '17:00',
})),
- };
- showScheduleEdit.value = true;
+ }
+ showScheduleEdit.value = true
}
function openEditSchedule(schedule: EntitiesMessageSendSchedule) {
- resetErrors();
+ resetErrors()
activeSchedule.value = {
id: schedule.id,
name: schedule.name,
@@ -546,64 +549,62 @@ function openEditSchedule(schedule: EntitiesMessageSendSchedule) {
start_time: minuteToClock(x.start_minute),
end_time: minuteToClock(x.end_minute),
})),
- };
- showScheduleEdit.value = true;
+ }
+ showScheduleEdit.value = true
}
function scheduleWindowsForDay(dayOfWeek: number) {
- return activeSchedule.value.windows.filter(
- (x) => x.day_of_week === dayOfWeek,
- );
+ return activeSchedule.value.windows.filter((x) => x.day_of_week === dayOfWeek)
}
function scheduleDayEnabled(dayOfWeek: number): boolean {
- return scheduleWindowsForDay(dayOfWeek).length > 0;
+ return scheduleWindowsForDay(dayOfWeek).length > 0
}
function scheduleToggleDay(dayOfWeek: number, enabled: boolean | null) {
if (enabled) {
if (!scheduleDayEnabled(dayOfWeek)) {
- scheduleAddWindow(dayOfWeek);
+ scheduleAddWindow(dayOfWeek)
}
- return;
+ return
}
activeSchedule.value.windows = activeSchedule.value.windows.filter(
(x) => x.day_of_week !== dayOfWeek,
- );
+ )
}
function scheduleAddWindow(dayOfWeek: number) {
activeSchedule.value.windows.push({
day_of_week: dayOfWeek,
- start_time: "09:00",
- end_time: "17:00",
- });
+ start_time: '09:00',
+ end_time: '17:00',
+ })
}
function scheduleRemoveWindow(dayOfWeek: number, index: number) {
const matches = activeSchedule.value.windows.filter(
(x) => x.day_of_week === dayOfWeek,
- );
- const target = matches[index];
+ )
+ const target = matches[index]
activeSchedule.value.windows = activeSchedule.value.windows.filter(
(x) => x !== target,
- );
+ )
}
function scheduleWindowError(index: number): string | null {
- const messages = errorMessages.value.has("windows")
- ? errorMessages.value.get("windows")
- : [];
- if (messages.length === 0) return null;
- const message = messages.find((x) => x.includes(`Day of week ${index}`));
+ const messages = errorMessages.value.has('windows')
+ ? errorMessages.value.get('windows')
+ : []
+ if (messages.length === 0) return null
+ const message = messages.find((x) => x.includes(`Day of week ${index}`))
return message
? message.replace(`Day of week ${index}`, getWeekday(index))
- : null;
+ : null
}
async function saveSchedule() {
- resetErrors();
- savingSchedule.value = true;
+ resetErrors()
+ savingSchedule.value = true
try {
const payload = {
name: activeSchedule.value.name,
@@ -613,158 +614,158 @@ async function saveSchedule() {
start_minute: clockToMinute(window.start_time),
end_minute: clockToMinute(window.end_time),
})),
- };
+ }
if (activeSchedule.value.id) {
await billingStore.updateSendSchedule({
id: activeSchedule.value.id,
...payload,
- });
+ })
} else {
- await billingStore.createSendSchedule(payload);
+ await billingStore.createSendSchedule(payload)
}
notificationsStore.addNotification({
- type: "success",
- message: "Send schedule saved successfully",
- });
- showScheduleEdit.value = false;
- await loadSendSchedules();
- } catch (error: any) {
- errorMessages.value = parseErrors(error);
+ type: 'success',
+ message: 'Send schedule saved successfully',
+ })
+ showScheduleEdit.value = false
+ await loadSendSchedules()
+ } catch (error: unknown) {
+ errorMessages.value = parseErrors(error)
if (errorMessages.value.size() === 0) {
notificationsStore.addNotification({
- type: "error",
- message: "Failed to save send schedule",
- });
+ type: 'error',
+ message: 'Failed to save send schedule',
+ })
}
} finally {
- savingSchedule.value = false;
+ savingSchedule.value = false
}
}
function confirmDeleteSchedule() {
- showScheduleDelete.value = true;
+ showScheduleDelete.value = true
}
async function deleteSchedule() {
- if (!activeSchedule.value.id) return;
- savingSchedule.value = true;
+ if (!activeSchedule.value.id) return
+ savingSchedule.value = true
try {
- await billingStore.deleteSendSchedule(activeSchedule.value.id);
+ await billingStore.deleteSendSchedule(activeSchedule.value.id)
notificationsStore.addNotification({
- type: "success",
- message: "Send schedule deleted successfully",
- });
- showScheduleDelete.value = false;
- showScheduleEdit.value = false;
- await loadSendSchedules();
+ type: 'success',
+ message: 'Send schedule deleted successfully',
+ })
+ showScheduleDelete.value = false
+ showScheduleEdit.value = false
+ await loadSendSchedules()
} catch {
notificationsStore.addNotification({
- type: "error",
- message: "Failed to delete send schedule",
- });
+ type: 'error',
+ message: 'Failed to delete send schedule',
+ })
} finally {
- savingSchedule.value = false;
+ savingSchedule.value = false
}
}
// ---------------------------------------------------------------------------
// Email Notifications
// ---------------------------------------------------------------------------
-const updatingEmailNotifications = ref(false);
+const updatingEmailNotifications = ref(false)
const notificationSettings = ref({
webhook_enabled: true,
message_status_enabled: true,
newsletter_enabled: true,
heartbeat_enabled: true,
-});
+})
function syncEmailNotifications() {
- if (!authStore.user) return;
+ if (!authStore.user) return
notificationSettings.value = {
webhook_enabled: authStore.user.notification_webhook_enabled,
message_status_enabled: authStore.user.notification_message_status_enabled,
heartbeat_enabled: authStore.user.notification_heartbeat_enabled,
newsletter_enabled: authStore.user.notification_newsletter_enabled,
- };
+ }
}
async function saveEmailNotifications() {
- if (!authStore.user) return;
- updatingEmailNotifications.value = true;
+ if (!authStore.user) return
+ updatingEmailNotifications.value = true
try {
await billingStore.saveEmailNotifications(
authStore.user.id,
notificationSettings.value,
- );
+ )
notificationsStore.addNotification({
- message: "Email notifications saved successfully",
- type: "success",
- });
- syncEmailNotifications();
+ message: 'Email notifications saved successfully',
+ type: 'success',
+ })
+ syncEmailNotifications()
} catch {
notificationsStore.addNotification({
- message: "Failed to save email notifications",
- type: "error",
- });
+ message: 'Failed to save email notifications',
+ type: 'error',
+ })
} finally {
- updatingEmailNotifications.value = false;
+ updatingEmailNotifications.value = false
}
}
// ---------------------------------------------------------------------------
// Delete account
// ---------------------------------------------------------------------------
-const deletingAccount = ref(false);
-const showDeleteAccountDialog = ref(false);
+const deletingAccount = ref(false)
+const showDeleteAccountDialog = ref(false)
async function deleteUserAccount() {
- deletingAccount.value = true;
+ deletingAccount.value = true
try {
- const message = await authStore.deleteUserAccount();
+ const message = await authStore.deleteUserAccount()
notificationsStore.addNotification({
- message: message ?? "Your account has been deleted successfully",
- type: "success",
- });
- const auth = getAuth();
- await signOut(auth);
- authStore.resetState();
- phonesStore.resetState();
+ message: message ?? 'Your account has been deleted successfully',
+ type: 'success',
+ })
+ const auth = getAuth()
+ await signOut(auth)
+ authStore.resetState()
+ phonesStore.resetState()
notificationsStore.addNotification({
- type: "info",
- message: "You have successfully logged out",
- });
- await router.push({ name: "index" });
+ type: 'info',
+ message: 'You have successfully logged out',
+ })
+ await router.push({ name: 'index' })
} catch {
notificationsStore.addNotification({
- message: "Failed to delete your account",
- type: "error",
- });
+ message: 'Failed to delete your account',
+ type: 'error',
+ })
} finally {
- deletingAccount.value = false;
- showDeleteAccountDialog.value = false;
+ deletingAccount.value = false
+ showDeleteAccountDialog.value = false
}
}
watch(showQrCodeDialog, (open) => {
if (open && apiKey.value) {
- nextTick(() => generateQrCode());
+ nextTick(() => generateQrCode())
}
-});
+})
onMounted(async () => {
- firebaseUser.value = getAuth().currentUser;
- await Promise.all([authStore.loadUser(), phonesStore.loadPhones()]);
- syncEmailNotifications();
- loadWebhooks();
- loadDiscordIntegrations();
- loadSendSchedules();
+ firebaseUser.value = getAuth().currentUser
+ await Promise.all([authStore.loadUser(), phonesStore.loadPhones()])
+ syncEmailNotifications()
+ loadWebhooks()
+ loadDiscordIntegrations()
+ loadSendSchedules()
if (route.hash) {
nextTick(() => {
- const el = document.querySelector(route.hash);
- if (el) el.scrollIntoView({ behavior: "smooth" });
- });
+ const el = document.querySelector(route.hash)
+ if (el) el.scrollIntoView({ behavior: 'smooth' })
+ })
}
-});
+})
</script>
<template>
@@ -791,8 +792,8 @@ onMounted(async () => {
</v-avatar>
<h3
- class="text-title-large mt-2 mb-0"
v-if="firebaseUser.displayName"
+ class="text-title-large mt-2 mb-0"
>
{{ firebaseUser.displayName }}
</h3>
@@ -1407,7 +1408,7 @@ onMounted(async () => {
:loading="updatingWebhook"
@click="saveWebhook"
>
- {{ activeWebhook.id ? "Update Webhook" : "Save Webhook" }}
+ {{ activeWebhook.id ? 'Update Webhook' : 'Save Webhook' }}
</LoadingButton>
<VSpacer />
<VBtn
@@ -1514,8 +1515,8 @@ onMounted(async () => {
>
{{
activeDiscord.id
- ? "Update Discord Integration"
- : "Save Discord Integration"
+ ? 'Update Discord Integration'
+ : 'Save Discord Integration'
}}
</LoadingButton>
<VSpacer />
@@ -1782,7 +1783,7 @@ onMounted(async () => {
:loading="savingSchedule"
@click="saveSchedule"
>
- {{ activeSchedule.id ? "Update Schedule" : "Save Schedule" }}
+ {{ activeSchedule.id ? 'Update Schedule' : 'Save Schedule' }}
</LoadingButton>
<VSpacer />
<VBtn
diff --git a/web/app/pages/terms-and-conditions/index.vue b/web/app/pages/terms-and-conditions/index.vue
index d21f46b7..ffdaf599 100644
--- a/web/app/pages/terms-and-conditions/index.vue
+++ b/web/app/pages/terms-and-conditions/index.vue
@@ -1,11 +1,11 @@
<script setup lang="ts">
definePageMeta({
- layout: "website",
-});
+ layout: 'website',
+})
useHead({
- title: "Terms and Conditions - httpSMS",
-});
+ title: 'Terms and Conditions - httpSMS',
+})
</script>
<template>
diff --git a/web/app/pages/threads/[id]/index.vue b/web/app/pages/threads/[id]/index.vue
index 39fd7c9e..ea49bb80 100644
--- a/web/app/pages/threads/[id]/index.vue
+++ b/web/app/pages/threads/[id]/index.vue
@@ -14,137 +14,137 @@ import {
mdiAccount,
mdiRefresh,
mdiContentCopy,
-} from "@mdi/js";
-import Pusher from "pusher-js";
-import type { Channel } from "pusher-js";
-import { isValidPhoneNumber } from "libphonenumber-js";
-import type { Message } from "~/shared/types/message";
+} from '@mdi/js'
+import Pusher from 'pusher-js'
+import type { Channel } from 'pusher-js'
+import { isValidPhoneNumber } from 'libphonenumber-js'
+import type { Message } from '~/shared/types/message'
definePageMeta({
- middleware: ["auth"],
-});
+ middleware: ['auth'],
+})
useHead({
- title: "Messages - httpSMS",
-});
-
-const route = useRoute();
-const router = useRouter();
-const config = useRuntimeConfig();
-const { lgAndUp, mdAndDown, mdAndUp } = useDisplay();
-const notificationsStore = useNotificationsStore();
-const authStore = useAuthStore();
-const phonesStore = usePhonesStore();
-const threadsStore = useThreadsStore();
-const messagesStore = useMessagesStore();
-
-const formMessage = ref("");
-const submitting = ref(false);
-const loadingMessages = ref(false);
-const hideMessages = ref(true);
-const messages = ref<Message[]>([]);
-const selectedMenuItem = ref(-1);
-const messageBody = ref<HTMLElement | null>(null);
-
-let webhookChannel: Channel | null = null;
+ title: 'Messages - httpSMS',
+})
+
+const route = useRoute()
+const router = useRouter()
+const config = useRuntimeConfig()
+const { lgAndUp, mdAndDown } = useDisplay()
+const notificationsStore = useNotificationsStore()
+const authStore = useAuthStore()
+const phonesStore = usePhonesStore()
+const threadsStore = useThreadsStore()
+const messagesStore = useMessagesStore()
+
+const formMessage = ref('')
+const submitting = ref(false)
+const loadingMessages = ref(false)
+const hideMessages = ref(true)
+const messages = ref<Message[]>([])
+const selectedMenuItem = ref(-1)
+const messageBody = ref<HTMLElement | null>(null)
+
+let webhookChannel: Channel | null = null
const contactIsPhoneNumber = computed(() => {
- const thread = threadsStore.currentThread;
- if (!thread) return false;
- return isValidPhoneNumber(thread.contact) || !isNaN(Number(thread.contact));
-});
+ const thread = threadsStore.currentThread
+ if (!thread) return false
+ return isValidPhoneNumber(thread.contact) || !isNaN(Number(thread.contact))
+})
const messageVisibility = computed(() =>
- hideMessages.value ? "hidden" : "visible",
-);
-const contact = computed(() => threadsStore.currentThread?.contact ?? "");
+ hideMessages.value ? 'hidden' : 'visible',
+)
+const contact = computed(() => threadsStore.currentThread?.contact ?? '')
function isMT(message: Message): boolean {
- return message.type === "mobile-terminated";
+ return message.type === 'mobile-terminated'
}
function isMo(message: Message): boolean {
- return message.type === "mobile-originated";
+ return message.type === 'mobile-originated'
}
function isMissedCall(message: Message): boolean {
- return message.type === "call/missed";
+ return message.type === 'call/missed'
}
function isPending(message: Message): boolean {
- return ["sending", "pending", "scheduled"].includes(message.status);
+ return ['sending', 'pending', 'scheduled'].includes(message.status)
}
function statusColor(message: Message): string {
- if (message.status === "sending") return "warning";
- if (message.status === "scheduled") return "teal";
- return "primary";
+ if (message.status === 'sending') return 'warning'
+ if (message.status === 'scheduled') return 'teal'
+ return 'primary'
}
function canResend(message: Message): boolean {
return (
isMT(message) &&
- (message.status === "expired" || message.status === "failed")
- );
+ (message.status === 'expired' || message.status === 'failed')
+ )
}
function formatAttachmentName(url: string): string {
- const parts = url.split("/");
- if (parts.length >= 2) return "/" + parts.slice(-2).join("/");
- return url;
+ const parts = url.split('/')
+ if (parts.length >= 2) return '/' + parts.slice(-2).join('/')
+ return url
}
function scrollToElement() {
- const el = messageBody.value;
+ const el = messageBody.value
if (el) {
- el.scrollTop = el.scrollHeight + 120;
+ el.scrollTop = el.scrollHeight + 120
}
- hideMessages.value = false;
+ hideMessages.value = false
}
function loadMessages(hide = true) {
- loadingMessages.value = true;
- const threadId = route.params.id as string;
+ loadingMessages.value = true
+ const threadId = route.params.id as string
messagesStore
.loadThreadMessages(threadId)
.then((msgs: Message[]) => {
- messages.value = [...msgs].reverse();
+ messages.value = [...msgs].reverse()
})
.finally(() => {
setTimeout(() => {
- loadingMessages.value = false;
- }, 1100);
- });
- hideMessages.value = hide;
+ loadingMessages.value = false
+ }, 1100)
+ })
+ hideMessages.value = hide
setTimeout(() => {
- scrollToElement();
- }, 950);
+ scrollToElement()
+ }, 950)
}
async function loadData() {
- await authStore.loadUser();
- await phonesStore.loadPhones();
- await threadsStore.loadThreads();
+ await authStore.loadUser()
+ await phonesStore.loadPhones()
+ await threadsStore.loadThreads()
if (!threadsStore.hasThreadId(route.params.id as string)) {
- await router.push("/threads");
- return;
+ await router.push('/threads')
+ return
}
- loadMessages();
+ loadMessages()
}
async function archiveThread() {
- await threadsStore.updateThread(threadsStore.currentThread!.id, true);
+ await threadsStore.updateThread(threadsStore.currentThread!.id, true)
setTimeout(() => {
- selectedMenuItem.value = -1;
- }, 1000);
+ selectedMenuItem.value = -1
+ }, 1000)
}
async function unArchiveThread() {
- await threadsStore.updateThread(threadsStore.currentThread!.id, false);
+ await threadsStore.updateThread(threadsStore.currentThread!.id, false)
setTimeout(() => {
- selectedMenuItem.value = -1;
- }, 1000);
+ selectedMenuItem.value = -1
+ }, 1000)
}
async function resendMessage(message: Message) {
@@ -152,73 +152,73 @@ async function resendMessage(message: Message) {
from: message.owner,
to: message.contact,
content: message.content,
- });
+ })
setTimeout(() => {
- selectedMenuItem.value = -1;
- }, 1000);
- loadMessages(false);
+ selectedMenuItem.value = -1
+ }, 1000)
+ loadMessages(false)
}
async function deleteMessage(message: Message) {
- await messagesStore.deleteMessage(message.id);
+ await messagesStore.deleteMessage(message.id)
setTimeout(() => {
- selectedMenuItem.value = -1;
- }, 1000);
- loadMessages(false);
+ selectedMenuItem.value = -1
+ }, 1000)
+ loadMessages(false)
}
async function copyMessageId(message: Message) {
- await navigator.clipboard.writeText(message.id);
+ await navigator.clipboard.writeText(message.id)
notificationsStore.addNotification({
- message: "Message ID copied to clipboard",
- type: "success",
- });
+ message: 'Message ID copied to clipboard',
+ type: 'success',
+ })
setTimeout(() => {
- selectedMenuItem.value = -1;
- }, 1000);
+ selectedMenuItem.value = -1
+ }, 1000)
}
async function deleteThread(threadID: string) {
- await threadsStore.deleteThread(threadID);
- await router.push("/threads");
+ await threadsStore.deleteThread(threadID)
+ await router.push('/threads')
}
async function sendMessage(event: KeyboardEvent | Event) {
- if (event instanceof KeyboardEvent && event.shiftKey) return;
- if (!formMessage.value.trim()) return;
+ if (event instanceof KeyboardEvent && event.shiftKey) return
+ if (!formMessage.value.trim()) return
- submitting.value = true;
+ submitting.value = true
await messagesStore.sendMessage({
from: phonesStore.owner,
to: threadsStore.currentThread!.contact,
content: formMessage.value,
- });
- loadMessages(false);
- formMessage.value = "";
- submitting.value = false;
+ })
+ loadMessages(false)
+ formMessage.value = ''
+ submitting.value = false
}
onMounted(async () => {
- await loadData();
+ await loadData()
const pusher = new Pusher(config.public.pusherKey as string, {
cluster: config.public.pusherCluster as string,
- });
- webhookChannel = pusher.subscribe(authStore.user!.id);
- webhookChannel.bind("message.phone.sent", () => {
- if (!loadingMessages.value) loadMessages(false);
- });
- webhookChannel.bind("message.send.failed", () => {
- if (!loadingMessages.value) loadMessages(false);
- });
- webhookChannel.bind("message.phone.received", () => {
- if (!loadingMessages.value) loadMessages(false);
- });
-});
+ })
+ webhookChannel = pusher.subscribe(authStore.user!.id)
+ webhookChannel.bind('message.phone.sent', () => {
+ if (!loadingMessages.value) loadMessages(false)
+ })
+ webhookChannel.bind('message.send.failed', () => {
+ if (!loadingMessages.value) loadMessages(false)
+ })
+ webhookChannel.bind('message.phone.received', () => {
+ if (!loadingMessages.value) loadMessages(false)
+ })
+})
onBeforeUnmount(() => {
- if (webhookChannel) webhookChannel.unsubscribe();
-});
+ if (webhookChannel) webhookChannel.unsubscribe()
+})
</script>
<template>
diff --git a/web/app/pages/threads/index.vue b/web/app/pages/threads/index.vue
index 96bc5e47..d77cf560 100644
--- a/web/app/pages/threads/index.vue
+++ b/web/app/pages/threads/index.vue
@@ -1,22 +1,22 @@
<script setup lang="ts">
definePageMeta({
- middleware: ["auth"],
-});
+ middleware: ['auth'],
+})
useHead({
- title: "Threads - httpSMS",
-});
+ title: 'Threads - httpSMS',
+})
-const { lgAndUp } = useDisplay();
-const authStore = useAuthStore();
-const phonesStore = usePhonesStore();
-const threadsStore = useThreadsStore();
+const { lgAndUp } = useDisplay()
+const authStore = useAuthStore()
+const phonesStore = usePhonesStore()
+const threadsStore = useThreadsStore()
onMounted(async () => {
- await authStore.loadUser();
- await phonesStore.loadPhones();
- await threadsStore.loadThreads();
-});
+ await authStore.loadUser()
+ await phonesStore.loadPhones()
+ await threadsStore.loadThreads()
+})
</script>
<template>
diff --git a/web/app/plugins/chart.client.ts b/web/app/plugins/chart.client.ts
index 44d4ec2c..3828cc42 100644
--- a/web/app/plugins/chart.client.ts
+++ b/web/app/plugins/chart.client.ts
@@ -10,8 +10,8 @@ import {
Legend,
Filler,
TimeScale,
-} from "chart.js";
-import "chartjs-adapter-moment";
+} from 'chart.js'
+import 'chartjs-adapter-moment'
export default defineNuxtPlugin(() => {
ChartJS.register(
@@ -25,5 +25,5 @@ export default defineNuxtPlugin(() => {
Legend,
Filler,
TimeScale,
- );
-});
+ )
+})
diff --git a/web/app/plugins/firebase.client.ts b/web/app/plugins/firebase.client.ts
index 68762491..31f7c31a 100644
--- a/web/app/plugins/firebase.client.ts
+++ b/web/app/plugins/firebase.client.ts
@@ -1,20 +1,20 @@
-import { initializeApp, getApps } from "firebase/app";
-import type { FirebaseApp } from "firebase/app";
-import { getAuth, onAuthStateChanged } from "firebase/auth";
-import { useAuthStore } from "../stores/auth";
+import { initializeApp, getApps } from 'firebase/app'
+import type { FirebaseApp } from 'firebase/app'
+import { getAuth, onAuthStateChanged } from 'firebase/auth'
+import { useAuthStore } from '../stores/auth'
export default defineNuxtPlugin(() => {
- const config = useRuntimeConfig();
- const publicConfig = config.public as Record<string, string>;
+ const config = useRuntimeConfig()
+ const publicConfig = config.public as Record<string, string>
// Skip initialization if no API key is configured
if (!publicConfig.firebaseApiKey) {
console.warn(
- "[firebase] No FIREBASE_API_KEY configured. Auth will not work.",
- );
+ '[firebase] No FIREBASE_API_KEY configured. Auth will not work.',
+ )
// Resolve auth readiness so route middleware doesn't hang forever.
- useAuthStore().onAuthStateChanged(null);
- return;
+ useAuthStore().onAuthStateChanged(null)
+ return
}
const firebaseConfig = {
@@ -25,23 +25,23 @@ export default defineNuxtPlugin(() => {
messagingSenderId: publicConfig.firebaseMessagingSenderId,
appId: publicConfig.firebaseAppId,
measurementId: publicConfig.firebaseMeasurementId,
- };
+ }
// Initialise Firebase (only once)
const app: FirebaseApp =
- getApps().length === 0 ? initializeApp(firebaseConfig) : getApps()[0]!;
- const auth = getAuth(app);
+ getApps().length === 0 ? initializeApp(firebaseConfig) : getApps()[0]!
+ const auth = getAuth(app)
// Listen for auth state changes and update the auth store
- const authStore = useAuthStore();
+ const authStore = useAuthStore()
onAuthStateChanged(auth, (user) => {
- authStore.onAuthStateChanged(user);
- });
+ authStore.onAuthStateChanged(user)
+ })
return {
provide: {
firebaseApp: app,
firebaseAuth: auth,
},
- };
-});
+ }
+})
diff --git a/web/app/plugins/highlightjs.client.ts b/web/app/plugins/highlightjs.client.ts
index 96be9cab..cc22a3af 100644
--- a/web/app/plugins/highlightjs.client.ts
+++ b/web/app/plugins/highlightjs.client.ts
@@ -1,45 +1,45 @@
-import hljs from "highlight.js/lib/core";
-import javascript from "highlight.js/lib/languages/javascript";
-import python from "highlight.js/lib/languages/python";
-import php from "highlight.js/lib/languages/php";
-import go from "highlight.js/lib/languages/go";
-import java from "highlight.js/lib/languages/java";
-import bash from "highlight.js/lib/languages/bash";
-import csharp from "highlight.js/lib/languages/csharp";
-import json from "highlight.js/lib/languages/json";
-import "highlight.js/styles/github-dark.css";
+import hljs from 'highlight.js/lib/core'
+import javascript from 'highlight.js/lib/languages/javascript'
+import python from 'highlight.js/lib/languages/python'
+import php from 'highlight.js/lib/languages/php'
+import go from 'highlight.js/lib/languages/go'
+import java from 'highlight.js/lib/languages/java'
+import bash from 'highlight.js/lib/languages/bash'
+import csharp from 'highlight.js/lib/languages/csharp'
+import json from 'highlight.js/lib/languages/json'
+import 'highlight.js/styles/github-dark.css'
-hljs.registerLanguage("javascript", javascript);
-hljs.registerLanguage("python", python);
-hljs.registerLanguage("php", php);
-hljs.registerLanguage("go", go);
-hljs.registerLanguage("java", java);
-hljs.registerLanguage("bash", bash);
-hljs.registerLanguage("csharp", csharp);
-hljs.registerLanguage("json", json);
+hljs.registerLanguage('javascript', javascript)
+hljs.registerLanguage('python', python)
+hljs.registerLanguage('php', php)
+hljs.registerLanguage('go', go)
+hljs.registerLanguage('java', java)
+hljs.registerLanguage('bash', bash)
+hljs.registerLanguage('csharp', csharp)
+hljs.registerLanguage('json', json)
export default defineNuxtPlugin((nuxtApp) => {
- nuxtApp.vueApp.directive("highlight", {
+ nuxtApp.vueApp.directive('highlight', {
mounted(el: HTMLElement) {
- el.querySelectorAll("pre code").forEach((block) => {
- hljs.highlightElement(block as HTMLElement);
- });
+ el.querySelectorAll('pre code').forEach((block) => {
+ hljs.highlightElement(block as HTMLElement)
+ })
},
updated(el: HTMLElement) {
- el.querySelectorAll("pre code").forEach((block) => {
- delete (block as HTMLElement).dataset.highlighted;
- hljs.highlightElement(block as HTMLElement);
- });
+ el.querySelectorAll('pre code').forEach((block) => {
+ delete (block as HTMLElement).dataset.highlighted
+ hljs.highlightElement(block as HTMLElement)
+ })
},
- });
+ })
// Override hljs background to use Vuetify surface variant
- const style = document.createElement("style");
+ const style = document.createElement('style')
style.textContent = `
pre code.hljs {
background: transparent;
padding: 0;
}
- `;
- document.head.appendChild(style);
-});
+ `
+ document.head.appendChild(style)
+})
diff --git a/web/app/plugins/vPhoneInput.client.ts b/web/app/plugins/vPhoneInput.client.ts
index 4ac09c3e..1ebe1a95 100644
--- a/web/app/plugins/vPhoneInput.client.ts
+++ b/web/app/plugins/vPhoneInput.client.ts
@@ -1,18 +1,18 @@
-import "flag-icons/css/flag-icons.min.css";
-import "v-phone-input/styles";
+import 'flag-icons/css/flag-icons.min.css'
+import 'v-phone-input/styles'
import {
createVPhoneInput,
autocompletePhoneCountryInput,
VPhoneCountryFlagSvg,
-} from "v-phone-input";
-import type { Plugin } from "vue";
+} from 'v-phone-input'
+import type { Plugin } from 'vue'
export default defineNuxtPlugin((nuxtApp) => {
const vPhoneInput: Plugin = createVPhoneInput({
...autocompletePhoneCountryInput,
countryDisplayComponent: VPhoneCountryFlagSvg,
validate: null,
- });
+ })
- nuxtApp.vueApp.use(vPhoneInput);
-});
+ nuxtApp.vueApp.use(vPhoneInput)
+})
diff --git a/web/app/plugins/vue-glow.client.ts b/web/app/plugins/vue-glow.client.ts
index c0b71359..c517d001 100644
--- a/web/app/plugins/vue-glow.client.ts
+++ b/web/app/plugins/vue-glow.client.ts
@@ -2,4 +2,4 @@ export default defineNuxtPlugin(() => {
// vue-glow is a client-side only visual effect plugin
// In Nuxt 4 we handle this as a no-op placeholder
// since the original plugin had minimal functionality
-});
+})
diff --git a/web/app/stores/app.ts b/web/app/stores/app.ts
index 3303e3ae..2de45e22 100644
--- a/web/app/stores/app.ts
+++ b/web/app/stores/app.ts
@@ -1,23 +1,23 @@
-import { defineStore } from "pinia";
+import { defineStore } from 'pinia'
export interface AppData {
- url: string;
- name: string;
- env: string;
- appDownloadUrl: string;
- documentationUrl: string;
- githubUrl: string;
+ url: string
+ name: string
+ env: string
+ appDownloadUrl: string
+ documentationUrl: string
+ githubUrl: string
}
-export const useAppStore = defineStore("app", () => {
- const config = useRuntimeConfig();
- const polling = ref(false);
+export const useAppStore = defineStore('app', () => {
+ const config = useRuntimeConfig()
+ const polling = ref(false)
const appData = computed<AppData>(() => {
- const publicConfig = config.public as Record<string, string>;
- let url = publicConfig.appUrl || "";
- if (url.endsWith("/")) {
- url = url.substring(0, url.length - 1);
+ const publicConfig = config.public as Record<string, string>
+ let url = publicConfig.appUrl || ''
+ if (url.endsWith('/')) {
+ url = url.substring(0, url.length - 1)
}
return {
url,
@@ -26,15 +26,15 @@ export const useAppStore = defineStore("app", () => {
documentationUrl: publicConfig.appDocumentationUrl,
githubUrl: publicConfig.appGithubUrl,
name: publicConfig.appName,
- };
- });
+ }
+ })
const isLocal = computed(
- () => (config.public as Record<string, string>).appEnv === "local",
- );
+ () => (config.public as Record<string, string>).appEnv === 'local',
+ )
function setPolling(value: boolean) {
- polling.value = value;
+ polling.value = value
}
return {
@@ -42,5 +42,5 @@ export const useAppStore = defineStore("app", () => {
appData,
isLocal,
setPolling,
- };
-});
+ }
+})
diff --git a/web/app/stores/auth.ts b/web/app/stores/auth.ts
index 805445fc..a58d66a9 100644
--- a/web/app/stores/auth.ts
+++ b/web/app/stores/auth.ts
@@ -1,106 +1,107 @@
-import { defineStore } from "pinia";
-import { setAuthHeader, setApiKey } from "~/composables/useApi";
-import type { User } from "~~/shared/types/user";
+import { defineStore } from 'pinia'
+import type { User as FirebaseUser } from 'firebase/auth'
+import { setAuthHeader, setApiKey } from '~/composables/useApi'
+import type { User } from '~~/shared/types/user'
export interface AuthUser {
- email: string | null;
- displayName: string | null;
- id: string;
+ email: string | null
+ displayName: string | null
+ id: string
}
-export const useAuthStore = defineStore("auth", () => {
- const authStateChanged = ref(false);
- const authUser = ref<AuthUser | null>(null);
- const user = ref<User | null>(null);
- const { apiFetch } = useApi();
+export const useAuthStore = defineStore('auth', () => {
+ const authStateChanged = ref(false)
+ const authUser = ref<AuthUser | null>(null)
+ const user = ref<User | null>(null)
+ const { apiFetch } = useApi()
async function setAuthUserAction(newUser: AuthUser | null | undefined) {
- const userChanged = newUser?.id !== authUser.value?.id;
- authUser.value = newUser ?? null;
- authStateChanged.value = true;
+ const userChanged = newUser?.id !== authUser.value?.id
+ authUser.value = newUser ?? null
+ authStateChanged.value = true
if (userChanged && newUser !== null) {
- await Promise.all([loadUser(), loadPhones()]);
+ await Promise.all([loadUser(), loadPhones()])
}
}
- async function onAuthStateChanged(firebaseUser: any) {
+ async function onAuthStateChanged(firebaseUser: FirebaseUser | null) {
if (firebaseUser == null) {
- authUser.value = null;
- user.value = null;
- authStateChanged.value = true;
- setApiKey("");
- return;
+ authUser.value = null
+ user.value = null
+ authStateChanged.value = true
+ setApiKey('')
+ return
}
- setAuthHeader(await firebaseUser.getIdToken());
- const { uid, email, displayName } = firebaseUser;
- authUser.value = { id: uid, email, displayName };
- authStateChanged.value = true;
+ setAuthHeader(await firebaseUser.getIdToken())
+ const { uid, email, displayName } = firebaseUser
+ authUser.value = { id: uid, email, displayName }
+ authStateChanged.value = true
}
- async function onIdTokenChanged(firebaseUser: any) {
+ async function onIdTokenChanged(firebaseUser: FirebaseUser | null) {
if (firebaseUser == null) {
- setApiKey("");
- return;
+ setApiKey('')
+ return
}
- setAuthHeader(await firebaseUser.getIdToken());
+ setAuthHeader(await firebaseUser.getIdToken())
}
async function loadUser() {
- const response = await apiFetch<{ data: User }>("/v1/users/me");
- user.value = response.data;
+ const response = await apiFetch<{ data: User }>('/v1/users/me')
+ user.value = response.data
}
async function updateUser(payload: { owner?: string; timezone?: string }) {
- const phonesStore = usePhonesStore();
+ const phonesStore = usePhonesStore()
if (payload.owner) {
- phonesStore.setOwner(payload.owner);
+ phonesStore.setOwner(payload.owner)
}
- const activePhone = phonesStore.activePhone;
- if (!activePhone) return;
+ const activePhone = phonesStore.activePhone
+ if (!activePhone) return
- const response = await apiFetch<{ data: User }>("/v1/users/me", {
- method: "PUT",
+ const response = await apiFetch<{ data: User }>('/v1/users/me', {
+ method: 'PUT',
body: {
active_phone_id: activePhone.id,
timezone: payload.timezone ?? user.value?.timezone,
},
- });
+ })
- setApiKey(response.data.api_key);
- user.value = response.data;
+ setApiKey(response.data.api_key)
+ user.value = response.data
}
async function deleteUserAccount(): Promise<string> {
- const response = await apiFetch<{ message: string }>("/v1/users/me", {
- method: "DELETE",
- });
- return response.message;
+ const response = await apiFetch<{ message: string }>('/v1/users/me', {
+ method: 'DELETE',
+ })
+ return response.message
}
async function rotateApiKey(userId: string): Promise<User> {
const response = await apiFetch<{ data: User }>(
`/v1/users/${userId}/api-keys`,
{
- method: "DELETE",
+ method: 'DELETE',
},
- );
- user.value = response.data;
- setApiKey(response.data.api_key);
- return response.data;
+ )
+ user.value = response.data
+ setApiKey(response.data.api_key)
+ return response.data
}
function resetState() {
- user.value = null;
- authUser.value = null;
- authStateChanged.value = true;
- setApiKey("");
+ user.value = null
+ authUser.value = null
+ authStateChanged.value = true
+ setApiKey('')
}
function loadPhones() {
- const phonesStore = usePhonesStore();
- return phonesStore.loadPhones(false);
+ const phonesStore = usePhonesStore()
+ return phonesStore.loadPhones(false)
}
return {
@@ -115,5 +116,5 @@ export const useAuthStore = defineStore("auth", () => {
deleteUserAccount,
rotateApiKey,
resetState,
- };
-});
+ }
+})
diff --git a/web/app/stores/billing.ts b/web/app/stores/billing.ts
index e280d2ba..a9fd9395 100644
--- a/web/app/stores/billing.ts
+++ b/web/app/stores/billing.ts
@@ -1,5 +1,6 @@
-import { defineStore } from "pinia";
-import type { BillingUsage } from "~~/shared/types/billing";
+import { defineStore } from 'pinia'
+import type { BillingUsage } from '~~/shared/types/billing'
+import type { User } from '~~/shared/types/user'
import type {
EntitiesWebhook,
EntitiesDiscord,
@@ -13,51 +14,49 @@ import type {
RequestsUserNotificationUpdate,
RequestsUserPaymentInvoice,
ResponsesUserSubscriptionPaymentsResponse,
-} from "~~/shared/types/api";
+} from '~~/shared/types/api'
-export const useBillingStore = defineStore("billing", () => {
- const billingUsage = ref<BillingUsage | null>(null);
- const billingUsageHistory = ref<BillingUsage[]>([]);
- const { apiFetch } = useApi();
- const notificationsStore = useNotificationsStore();
+export const useBillingStore = defineStore('billing', () => {
+ const billingUsage = ref<BillingUsage | null>(null)
+ const billingUsageHistory = ref<BillingUsage[]>([])
+ const { apiFetch } = useApi()
+ const notificationsStore = useNotificationsStore()
async function loadBillingUsage() {
- const response = await apiFetch<{ data: BillingUsage }>(
- "/v1/billing/usage",
- );
- billingUsage.value = response.data;
+ const response = await apiFetch<{ data: BillingUsage }>('/v1/billing/usage')
+ billingUsage.value = response.data
}
async function loadBillingUsageHistory() {
const response = await apiFetch<{ data: BillingUsage[] }>(
- "/v1/billing/usage-history",
- );
- billingUsageHistory.value = response.data;
+ '/v1/billing/usage-history',
+ )
+ billingUsageHistory.value = response.data
}
async function getSubscriptionUpdateLink(): Promise<string> {
const response = await apiFetch<{ data: string }>(
- "/v1/users/subscription-update-url",
- );
- return response.data;
+ '/v1/users/subscription-update-url',
+ )
+ return response.data
}
async function cancelSubscription(): Promise<string> {
const response = await apiFetch<{ message: string }>(
- "/v1/users/subscription",
+ '/v1/users/subscription',
{
- method: "DELETE",
+ method: 'DELETE',
},
- );
- return response.message;
+ )
+ return response.message
}
async function indexSubscriptionPayments(): Promise<ResponsesUserSubscriptionPaymentsResponse> {
const response = await apiFetch<ResponsesUserSubscriptionPaymentsResponse>(
- "/v1/users/subscription/payments",
+ '/v1/users/subscription/payments',
{ params: { limit: 100 } },
- );
- return response;
+ )
+ return response
}
async function generateSubscriptionPaymentInvoice(
@@ -67,42 +66,42 @@ export const useBillingStore = defineStore("billing", () => {
const response = await apiFetch(
`/v1/users/subscription/invoices/${subscriptionInvoiceId}`,
{
- method: "POST",
+ method: 'POST',
body: request,
- responseType: "blob",
+ responseType: 'blob',
},
- );
+ )
- const pdfBlob = new Blob([response as any], { type: "application/pdf" });
- const url = window.URL.createObjectURL(pdfBlob);
- const tempLink = document.createElement("a");
- tempLink.href = url;
- tempLink.setAttribute("download", "Invoice.pdf");
- document.body.appendChild(tempLink);
- tempLink.click();
- document.body.removeChild(tempLink);
- window.URL.revokeObjectURL(url);
+ const pdfBlob = new Blob([response as Blob], { type: 'application/pdf' })
+ const url = window.URL.createObjectURL(pdfBlob)
+ const tempLink = document.createElement('a')
+ tempLink.href = url
+ tempLink.setAttribute('download', 'Invoice.pdf')
+ document.body.appendChild(tempLink)
+ tempLink.click()
+ document.body.removeChild(tempLink)
+ window.URL.revokeObjectURL(url)
}
// Webhooks
async function createWebhook(
payload: RequestsWebhookStore,
): Promise<EntitiesWebhook> {
- const response = await apiFetch<{ data: EntitiesWebhook }>("/v1/webhooks", {
- method: "POST",
+ const response = await apiFetch<{ data: EntitiesWebhook }>('/v1/webhooks', {
+ method: 'POST',
body: payload,
- });
- return response.data;
+ })
+ return response.data
}
async function getWebhooks(): Promise<EntitiesWebhook[]> {
const response = await apiFetch<{ data: EntitiesWebhook[] }>(
- "/v1/webhooks",
+ '/v1/webhooks',
{
params: { limit: 100 },
},
- );
- return response.data;
+ )
+ return response.data
}
async function updateWebhook(
@@ -111,15 +110,15 @@ export const useBillingStore = defineStore("billing", () => {
const response = await apiFetch<{ data: EntitiesWebhook }>(
`/v1/webhooks/${payload.id}`,
{
- method: "PUT",
+ method: 'PUT',
body: payload,
},
- );
- return response.data;
+ )
+ return response.data
}
async function deleteWebhook(id: string): Promise<void> {
- await apiFetch(`/v1/webhooks/${id}`, { method: "DELETE" });
+ await apiFetch(`/v1/webhooks/${id}`, { method: 'DELETE' })
}
// Discord
@@ -127,23 +126,23 @@ export const useBillingStore = defineStore("billing", () => {
payload: RequestsDiscordStore,
): Promise<EntitiesDiscord> {
const response = await apiFetch<{ data: EntitiesDiscord }>(
- "/v1/discord-integrations",
+ '/v1/discord-integrations',
{
- method: "POST",
+ method: 'POST',
body: payload,
},
- );
- return response.data;
+ )
+ return response.data
}
async function getDiscordIntegrations(): Promise<EntitiesDiscord[]> {
const response = await apiFetch<{ data: EntitiesDiscord[] }>(
- "/v1/discord-integrations",
+ '/v1/discord-integrations',
{
params: { limit: 100 },
},
- );
- return response.data;
+ )
+ return response.data
}
async function updateDiscordIntegration(
@@ -152,36 +151,36 @@ export const useBillingStore = defineStore("billing", () => {
const response = await apiFetch<{ data: EntitiesDiscord }>(
`/v1/discord-integrations/${payload.id}`,
{
- method: "PUT",
+ method: 'PUT',
body: payload,
},
- );
- return response.data;
+ )
+ return response.data
}
async function deleteDiscordIntegration(id: string): Promise<void> {
- await apiFetch(`/v1/discord-integrations/${id}`, { method: "DELETE" });
+ await apiFetch(`/v1/discord-integrations/${id}`, { method: 'DELETE' })
}
// Send Schedules
async function getSendSchedules(): Promise<EntitiesMessageSendSchedule[]> {
const response = await apiFetch<{ data: EntitiesMessageSendSchedule[] }>(
- "/v1/send-schedules",
- );
- return response.data;
+ '/v1/send-schedules',
+ )
+ return response.data
}
async function createSendSchedule(
payload: RequestsMessageSendScheduleStore,
): Promise<EntitiesMessageSendSchedule> {
const response = await apiFetch<{ data: EntitiesMessageSendSchedule }>(
- "/v1/send-schedules",
+ '/v1/send-schedules',
{
- method: "POST",
+ method: 'POST',
body: payload,
},
- );
- return response.data;
+ )
+ return response.data
}
async function updateSendSchedule(
@@ -190,52 +189,52 @@ export const useBillingStore = defineStore("billing", () => {
const response = await apiFetch<{ data: EntitiesMessageSendSchedule }>(
`/v1/send-schedules/${payload.id}`,
{
- method: "PUT",
+ method: 'PUT',
body: payload,
},
- );
- return response.data;
+ )
+ return response.data
}
async function deleteSendSchedule(id: string): Promise<void> {
- await apiFetch(`/v1/send-schedules/${id}`, { method: "DELETE" });
+ await apiFetch(`/v1/send-schedules/${id}`, { method: 'DELETE' })
}
// Phone API Keys
async function storePhoneApiKey(name: string): Promise<EntitiesPhoneAPIKey> {
const response = await apiFetch<{
- data: EntitiesPhoneAPIKey;
- message: string;
- }>("/v1/phone-api-keys", {
- method: "POST",
+ data: EntitiesPhoneAPIKey
+ message: string
+ }>('/v1/phone-api-keys', {
+ method: 'POST',
body: { name },
- });
+ })
notificationsStore.addNotification({
message: response.message,
- type: "success",
- });
- return response.data;
+ type: 'success',
+ })
+ return response.data
}
async function indexPhoneApiKeys(): Promise<EntitiesPhoneAPIKey[]> {
const response = await apiFetch<{ data: EntitiesPhoneAPIKey[] }>(
- "/v1/phone-api-keys",
+ '/v1/phone-api-keys',
{
params: { limit: 100 },
},
- );
- return response.data;
+ )
+ return response.data
}
async function deletePhoneApiKey(id: string): Promise<void> {
const response = await apiFetch<{ message: string }>(
`/v1/phone-api-keys/${id}`,
- { method: "DELETE" },
- );
+ { method: 'DELETE' },
+ )
notificationsStore.addNotification({
message: response.message,
- type: "success",
- });
+ type: 'success',
+ })
}
async function deletePhoneFromPhoneApiKey(
@@ -244,12 +243,12 @@ export const useBillingStore = defineStore("billing", () => {
): Promise<void> {
const response = await apiFetch<{ message: string }>(
`/v1/phone-api-keys/${phoneApiKeyId}/phones/${phoneId}`,
- { method: "DELETE" },
- );
+ { method: 'DELETE' },
+ )
notificationsStore.addNotification({
message: response.message,
- type: "success",
- });
+ type: 'success',
+ })
}
// Email notifications
@@ -257,15 +256,15 @@ export const useBillingStore = defineStore("billing", () => {
userId: string,
payload: RequestsUserNotificationUpdate,
): Promise<void> {
- const authStore = useAuthStore();
- const response = await apiFetch<{ data: any }>(
+ const authStore = useAuthStore()
+ const response = await apiFetch<{ data: User }>(
`/v1/users/${userId}/notifications`,
{
- method: "PUT",
+ method: 'PUT',
body: payload,
},
- );
- authStore.user = response.data;
+ )
+ authStore.user = response.data
}
return {
@@ -294,5 +293,5 @@ export const useBillingStore = defineStore("billing", () => {
deletePhoneApiKey,
deletePhoneFromPhoneApiKey,
saveEmailNotifications,
- };
-});
+ }
+})
diff --git a/web/app/stores/messages.ts b/web/app/stores/messages.ts
index 86955d62..b56cd36d 100644
--- a/web/app/stores/messages.ts
+++ b/web/app/stores/messages.ts
@@ -1,85 +1,89 @@
-import { defineStore } from "pinia";
-import type { EntitiesMessage } from "~~/shared/types/api";
-import type { SearchMessagesRequest } from "~~/shared/types/message";
+import { defineStore } from 'pinia'
+import type { EntitiesMessage } from '~~/shared/types/api'
+import type { SearchMessagesRequest } from '~~/shared/types/message'
+import type { BulkMessageOrder } from '~~/shared/types/bulk-message'
+import { getApiErrorMessage } from '~/utils/api-error'
-export type SIM = "SIM1" | "SIM2" | "DEFAULT";
+export type SIM = 'SIM1' | 'SIM2' | 'DEFAULT'
export interface SendMessageRequest {
- from: string;
- to: string;
- content: string;
- sim: SIM;
- request_id?: string;
+ from: string
+ to: string
+ content: string
+ sim: SIM
+ request_id?: string
}
-export const useMessagesStore = defineStore("messages", () => {
- const { apiFetch } = useApi();
- const notificationsStore = useNotificationsStore();
+export const useMessagesStore = defineStore('messages', () => {
+ const { apiFetch } = useApi()
+ const notificationsStore = useNotificationsStore()
async function sendMessage(request: SendMessageRequest) {
try {
const response = await apiFetch<{ message: string }>(
- "/v1/messages/send",
+ '/v1/messages/send',
{
- method: "POST",
+ method: 'POST',
body: request,
},
- );
+ )
notificationsStore.addNotification({
message: response.message,
- type: "success",
- });
- } catch (e: any) {
+ type: 'success',
+ })
+ } catch (e: unknown) {
notificationsStore.addNotification({
- message: e?.data?.message ?? "Error while sending message",
- type: "error",
- });
+ message: getApiErrorMessage(e, 'Error while sending message'),
+ type: 'error',
+ })
}
- const threadsStore = useThreadsStore();
- await threadsStore.loadThreads();
+ const threadsStore = useThreadsStore()
+ await threadsStore.loadThreads()
}
async function deleteMessage(messageId: string) {
- await apiFetch(`/v1/messages/${messageId}`, { method: "DELETE" });
+ await apiFetch(`/v1/messages/${messageId}`, { method: 'DELETE' })
notificationsStore.addNotification({
- message: "The message has been deleted successfully",
- type: "success",
- });
+ message: 'The message has been deleted successfully',
+ type: 'success',
+ })
}
async function searchMessages(
payload: SearchMessagesRequest,
): Promise<EntitiesMessage[]> {
- const token = payload.token;
- const params = { ...payload };
- delete params.token;
+ const token = payload.token
+ const params = { ...payload }
+ delete params.token
const response = await apiFetch<{ data: EntitiesMessage[] }>(
- "/v1/messages/search",
+ '/v1/messages/search',
{
params,
headers: token ? { token } : undefined,
},
- );
- return response.data;
+ )
+ return response.data
}
async function sendBulkMessages(document: File): Promise<void> {
- const formData = new FormData();
- formData.append("document", document);
- const response = await apiFetch<{ message?: string }>("/v1/bulk-messages", {
- method: "POST",
+ const formData = new FormData()
+ formData.append('document', document)
+ const response = await apiFetch<{ message?: string }>('/v1/bulk-messages', {
+ method: 'POST',
body: formData,
- });
+ })
notificationsStore.addNotification({
- message: response.message ?? "Bulk messages sent successfully",
- type: "success",
- });
+ message: response.message ?? 'Bulk messages sent successfully',
+ type: 'success',
+ })
}
- async function fetchBulkMessageOrders(): Promise<any[]> {
- const response = await apiFetch<{ data: any[] }>("/v1/bulk-messages");
- return response.data ?? [];
+ async function fetchBulkMessageOrders(): Promise<BulkMessageOrder[]> {
+ const response = await apiFetch<{ data: BulkMessageOrder[] }>(
+ '/v1/bulk-messages',
+ )
+ return response.data ?? []
}
return {
@@ -88,5 +92,5 @@ export const useMessagesStore = defineStore("messages", () => {
searchMessages,
sendBulkMessages,
fetchBulkMessageOrders,
- };
-});
+ }
+})
diff --git a/web/app/stores/notifications.ts b/web/app/stores/notifications.ts
index 9ce85e7a..0d721d38 100644
--- a/web/app/stores/notifications.ts
+++ b/web/app/stores/notifications.ts
@@ -1,28 +1,28 @@
-import { defineStore } from "pinia";
+import { defineStore } from 'pinia'
-export type NotificationType = "error" | "success" | "info";
+export type NotificationType = 'error' | 'success' | 'info'
export interface Notification {
- message: string;
- timeout: number;
- active: boolean;
- type: NotificationType;
+ message: string
+ timeout: number
+ active: boolean
+ type: NotificationType
}
export interface NotificationRequest {
- message: string;
- type: NotificationType;
+ message: string
+ type: NotificationType
}
-const DEFAULT_TIMEOUT = 3000;
+const DEFAULT_TIMEOUT = 3000
-export const useNotificationsStore = defineStore("notifications", () => {
+export const useNotificationsStore = defineStore('notifications', () => {
const notification = ref<Notification>({
active: false,
- message: "",
- type: "success",
+ message: '',
+ type: 'success',
timeout: DEFAULT_TIMEOUT,
- });
+ })
function addNotification(request: NotificationRequest) {
notification.value = {
@@ -30,16 +30,16 @@ export const useNotificationsStore = defineStore("notifications", () => {
message: request.message,
type: request.type,
timeout: Math.floor(Math.random() * 100) + DEFAULT_TIMEOUT,
- };
+ }
}
function disableNotification() {
- notification.value.active = false;
+ notification.value.active = false
}
return {
notification,
addNotification,
disableNotification,
- };
-});
+ }
+})
diff --git a/web/app/stores/phones.ts b/web/app/stores/phones.ts
index 0ddea017..2a0bb3a2 100644
--- a/web/app/stores/phones.ts
+++ b/web/app/stores/phones.ts
@@ -1,54 +1,55 @@
-import { defineStore } from "pinia";
-import type { EntitiesPhone } from "~~/shared/types/api";
-import type { Heartbeat } from "~~/shared/types/heartbeat";
+import { defineStore } from 'pinia'
+import type { EntitiesPhone } from '~~/shared/types/api'
+import type { Heartbeat } from '~~/shared/types/heartbeat'
+import { getApiErrorMessage } from '~/utils/api-error'
-export const usePhonesStore = defineStore("phones", () => {
- const phones = ref<EntitiesPhone[]>([]);
- const owner = ref<string | null>(null);
- const heartbeat = ref<Heartbeat | null>(null);
- const { apiFetch } = useApi();
- const notificationsStore = useNotificationsStore();
+export const usePhonesStore = defineStore('phones', () => {
+ const phones = ref<EntitiesPhone[]>([])
+ const owner = ref<string | null>(null)
+ const heartbeat = ref<Heartbeat | null>(null)
+ const { apiFetch } = useApi()
+ const notificationsStore = useNotificationsStore()
const activePhone = computed<EntitiesPhone | null>(() => {
- return phones.value.find((x) => x.phone_number === owner.value) ?? null;
- });
+ return phones.value.find((x) => x.phone_number === owner.value) ?? null
+ })
function setOwner(value: string) {
- owner.value = value;
+ owner.value = value
}
async function loadPhones(force: boolean = false) {
- if (phones.value.length > 0 && !force) return;
+ if (phones.value.length > 0 && !force) return
- const response = await apiFetch<{ data: EntitiesPhone[] }>("/v1/phones", {
+ const response = await apiFetch<{ data: EntitiesPhone[] }>('/v1/phones', {
params: { limit: 100 },
- });
- phones.value = response.data;
+ })
+ phones.value = response.data
- const authStore = useAuthStore();
+ const authStore = useAuthStore()
if (authStore.user?.active_phone_id) {
const phone = response.data.find(
(x) => x.id === authStore.user?.active_phone_id,
- );
+ )
if (phone) {
- owner.value = phone.phone_number;
+ owner.value = phone.phone_number
}
}
if (!owner.value && phones.value.length > 0) {
- owner.value = phones.value[0]!.phone_number;
+ owner.value = phones.value[0]!.phone_number
}
}
async function deletePhone(phoneID: string) {
- await apiFetch(`/v1/phones/${phoneID}`, { method: "DELETE" });
- await loadPhones(true);
+ await apiFetch(`/v1/phones/${phoneID}`, { method: 'DELETE' })
+ await loadPhones(true)
}
async function updatePhone(phone: EntitiesPhone) {
try {
- const response = await apiFetch<{ message: string }>("/v1/phones", {
- method: "PUT",
+ const response = await apiFetch<{ message: string }>('/v1/phones', {
+ method: 'PUT',
body: {
fcm_token: phone.fcm_token,
sim: phone.sim,
@@ -61,36 +62,36 @@ export const usePhonesStore = defineStore("phones", () => {
messages_per_minute: parseInt(phone.messages_per_minute.toString()),
message_send_schedule_id: phone.message_send_schedule_id ?? null,
},
- });
+ })
notificationsStore.addNotification({
message: response.message,
- type: "success",
- });
- await loadPhones(true);
- } catch (error: any) {
+ type: 'success',
+ })
+ await loadPhones(true)
+ } catch (error: unknown) {
notificationsStore.addNotification({
- message: error?.data?.message ?? "Error while updating phone",
- type: "error",
- });
+ message: getApiErrorMessage(error, 'Error while updating phone'),
+ type: 'error',
+ })
}
}
async function getHeartbeat(limit = 1): Promise<Heartbeat[]> {
- const response = await apiFetch<{ data: Heartbeat[] }>("/v1/heartbeats", {
+ const response = await apiFetch<{ data: Heartbeat[] }>('/v1/heartbeats', {
query: { limit, owner: owner.value },
- });
+ })
if (response.data.length > 0) {
- heartbeat.value = response.data[0]!;
+ heartbeat.value = response.data[0]!
} else {
- heartbeat.value = null;
+ heartbeat.value = null
}
- return response.data;
+ return response.data
}
function resetState() {
- phones.value = [];
- owner.value = null;
- heartbeat.value = null;
+ phones.value = []
+ owner.value = null
+ heartbeat.value = null
}
return {
@@ -104,5 +105,5 @@ export const usePhonesStore = defineStore("phones", () => {
updatePhone,
getHeartbeat,
resetState,
- };
-});
+ }
+})
diff --git a/web/app/stores/threads.ts b/web/app/stores/threads.ts
index c30b6d8a..61c84473 100644
--- a/web/app/stores/threads.ts
+++ b/web/app/stores/threads.ts
@@ -1,36 +1,36 @@
-import { defineStore } from "pinia";
-import type { MessageThread } from "~~/shared/types/message-thread";
-import type { Message } from "~~/shared/types/message";
+import { defineStore } from 'pinia'
+import type { MessageThread } from '~~/shared/types/message-thread'
+import type { Message } from '~~/shared/types/message'
-export const useThreadsStore = defineStore("threads", () => {
- const threads = ref<MessageThread[]>([]);
- const threadId = ref<string | null>(null);
- const loadingThreads = ref(true);
- const archivedThreads = ref(false);
- const { apiFetch } = useApi();
- const notificationsStore = useNotificationsStore();
+export const useThreadsStore = defineStore('threads', () => {
+ const threads = ref<MessageThread[]>([])
+ const threadId = ref<string | null>(null)
+ const loadingThreads = ref(true)
+ const archivedThreads = ref(false)
+ const { apiFetch } = useApi()
+ const notificationsStore = useNotificationsStore()
const currentThread = computed<MessageThread | null>(() => {
- return threads.value.find((x) => x.id === threadId.value) ?? null;
- });
+ return threads.value.find((x) => x.id === threadId.value) ?? null
+ })
const hasThread = computed(
() => threadId.value != null && !loadingThreads.value,
- );
+ )
function hasThreadId(id: string): boolean {
- return threads.value.find((x) => x.id === id) !== undefined;
+ return threads.value.find((x) => x.id === id) !== undefined
}
async function loadThreads() {
- const phonesStore = usePhonesStore();
+ const phonesStore = usePhonesStore()
if (phonesStore.owner === null && phonesStore.phones.length === 0) {
- loadingThreads.value = false;
- return;
+ loadingThreads.value = false
+ return
}
const response = await apiFetch<{ data: MessageThread[] }>(
- "/v1/message-threads",
+ '/v1/message-threads',
{
params: {
owner: phonesStore.owner ?? phonesStore.phones[0]?.phone_number,
@@ -38,62 +38,62 @@ export const useThreadsStore = defineStore("threads", () => {
is_archived: archivedThreads.value,
},
},
- );
+ )
- phonesStore.getHeartbeat().catch(console.error);
- threads.value = [...response.data];
- loadingThreads.value = false;
+ phonesStore.getHeartbeat().catch(console.error)
+ threads.value = [...response.data]
+ loadingThreads.value = false
}
async function loadThreadMessages(id: string | null): Promise<Message[]> {
- threadId.value = id;
- const thread = currentThread.value;
- if (!thread) throw new Error(`Cannot find thread with id ${id}`);
+ threadId.value = id
+ const thread = currentThread.value
+ if (!thread) throw new Error(`Cannot find thread with id ${id}`)
- const response = await apiFetch<{ data: Message[] }>("/v1/messages", {
+ const response = await apiFetch<{ data: Message[] }>('/v1/messages', {
params: {
contact: thread.contact,
owner: thread.owner,
limit: 50,
},
- });
- return response.data;
+ })
+ return response.data
}
function setThreadId(id: string | null) {
- threadId.value = id;
+ threadId.value = id
}
function toggleArchive() {
- archivedThreads.value = !archivedThreads.value;
+ archivedThreads.value = !archivedThreads.value
}
async function updateThread(payload: {
- threadId: string;
- isArchived: boolean;
+ threadId: string
+ isArchived: boolean
}) {
await apiFetch(`/v1/message-threads/${payload.threadId}`, {
- method: "PUT",
+ method: 'PUT',
body: { is_archived: payload.isArchived },
- });
- archivedThreads.value = payload.isArchived;
- await loadThreads();
+ })
+ archivedThreads.value = payload.isArchived
+ await loadThreads()
}
async function deleteThread(id: string) {
- await apiFetch(`/v1/message-threads/${id}`, { method: "DELETE" });
- threadId.value = null;
+ await apiFetch(`/v1/message-threads/${id}`, { method: 'DELETE' })
+ threadId.value = null
notificationsStore.addNotification({
- message: "The message thread has been deleted successfully",
- type: "success",
- });
+ message: 'The message thread has been deleted successfully',
+ type: 'success',
+ })
}
function resetState() {
- threads.value = [];
- threadId.value = null;
- archivedThreads.value = false;
- loadingThreads.value = true;
+ threads.value = []
+ threadId.value = null
+ archivedThreads.value = false
+ loadingThreads.value = true
}
return {
@@ -111,5 +111,5 @@ export const useThreadsStore = defineStore("threads", () => {
updateThread,
deleteThread,
resetState,
- };
-});
+ }
+})
diff --git a/web/app/types/nuxt-shims.d.ts b/web/app/types/nuxt-shims.d.ts
index 7bd26f63..a70a892e 100644
--- a/web/app/types/nuxt-shims.d.ts
+++ b/web/app/types/nuxt-shims.d.ts
@@ -5,36 +5,36 @@
* without running the Nuxt build pipeline.
*/
-import type { $Fetch } from "ofetch";
-import type { App } from "vue";
+import type { $Fetch } from 'ofetch'
+import type { App } from 'vue'
declare global {
// Nuxt composables
function useRuntimeConfig(): {
- public: Record<string, string>;
- [key: string]: unknown;
- };
+ public: Record<string, string>
+ [key: string]: unknown
+ }
// Nuxt fetch utility
- const $fetch: $Fetch;
+ const $fetch: $Fetch
// Nuxt plugin helper
function defineNuxtPlugin(
- plugin: (nuxtApp: { vueApp: App }) => void | Record<string, unknown>,
- ): unknown;
+ plugin: (nuxtApp: { vueApp: App }) => Record<string, unknown> | undefined,
+ ): unknown
// Nuxt route middleware helper
function defineNuxtRouteMiddleware(
middleware: (to: {
- path: string;
- query?: Record<string, string>;
+ path: string
+ query?: Record<string, string>
}) => unknown,
- ): unknown;
+ ): unknown
// Nuxt navigation
function navigateTo(
to: string | { path: string; query?: Record<string, string | undefined> },
- ): unknown;
+ ): unknown
}
-export {};
+export {}
diff --git a/web/app/utils/api-error.ts b/web/app/utils/api-error.ts
new file mode 100644
index 00000000..73934dd7
--- /dev/null
+++ b/web/app/utils/api-error.ts
@@ -0,0 +1,21 @@
+/**
+ * Shape of the error object thrown by ofetch/$fetch for failed API requests.
+ */
+export interface ApiError {
+ status?: number
+ data?: {
+ message?: string
+ data?: Record<string, string[]>
+ }
+}
+
+export function toApiError(error: unknown): ApiError {
+ if (error !== null && typeof error === 'object') {
+ return error as ApiError
+ }
+ return {}
+}
+
+export function getApiErrorMessage(error: unknown, fallback: string): string {
+ return toApiError(error).data?.message ?? fallback
+}
diff --git a/web/app/utils/bag.ts b/web/app/utils/bag.ts
index 02d9691a..73c46dd1 100644
--- a/web/app/utils/bag.ts
+++ b/web/app/utils/bag.ts
@@ -1,63 +1,63 @@
export default class Bag<T> {
- private items = new Map<string, Array<T>>();
+ private items = new Map<string, Array<T>>()
serialize(): Record<string, Array<T>> {
- const result: Record<string, Array<T>> = {};
+ const result: Record<string, Array<T>> = {}
this.items.forEach((value: T[], key) => {
- result[key] = value;
- });
- return result;
+ result[key] = value
+ })
+ return result
}
static fromObject<T>(items: Record<string, Array<T>>): Bag<T> {
- const result = new Bag<T>();
+ const result = new Bag<T>()
Object.keys(items).forEach((key) => {
- result.addMany(key, items[key]);
- });
- return result;
+ result.addMany(key, items[key])
+ })
+ return result
}
add(key: string, value: T): this {
- let messages: Array<T> | undefined = this.items.get(key);
+ let messages: Array<T> | undefined = this.items.get(key)
if (messages === undefined) {
- messages = [];
+ messages = []
}
if (!messages.includes(value)) {
- messages.push(value);
+ messages.push(value)
}
- this.items.set(key, messages);
- return this;
+ this.items.set(key, messages)
+ return this
}
addMany(key: string, values: Array<T>): this {
values.forEach((value: T) => {
- this.add(key, value);
- });
- return this;
+ this.add(key, value)
+ })
+ return this
}
has(key: string): boolean {
- return this.items.has(key);
+ return this.items.has(key)
}
first(key: string): T | undefined {
if (this.has(key)) {
- return this.get(key)[0] ?? undefined;
+ return this.get(key)[0] ?? undefined
}
- return undefined;
+ return undefined
}
get(key: string): Array<T> {
- const result = this.items.get(key);
+ const result = this.items.get(key)
if (result === undefined) {
- return [];
+ return []
}
- return result;
+ return result
}
size(): number {
- return this.items.size;
+ return this.items.size
}
}
diff --git a/web/app/utils/capitalize.ts b/web/app/utils/capitalize.ts
index 3b1ed092..9944ef64 100644
--- a/web/app/utils/capitalize.ts
+++ b/web/app/utils/capitalize.ts
@@ -1,8 +1,8 @@
export function capitalize(value: string | null): string {
if (!value) {
- return "";
+ return ''
}
- return value.charAt(0).toUpperCase() + value.slice(1);
+ return value.charAt(0).toUpperCase() + value.slice(1)
}
-export default capitalize;
+export default capitalize
diff --git a/web/app/utils/countries.ts b/web/app/utils/countries.ts
index ab2e8f38..d5419ca1 100644
--- a/web/app/utils/countries.ts
+++ b/web/app/utils/countries.ts
@@ -1,335 +1,335 @@
export type SelectOption = {
- title: string;
- value: string;
-};
+ title: string
+ value: string
+}
export const countries: SelectOption[] = [
- { title: "Afghanistan", value: "AF" },
- { title: "Åland Islands", value: "AX" },
- { title: "Albania", value: "AL" },
- { title: "Algeria", value: "DZ" },
- { title: "American Samoa", value: "AS" },
- { title: "Andorra", value: "AD" },
- { title: "Angola", value: "AO" },
- { title: "Anguilla", value: "AI" },
- { title: "Antarctica", value: "AQ" },
- { title: "Antigua and Barbuda", value: "AG" },
- { title: "Argentina", value: "AR" },
- { title: "Armenia", value: "AM" },
- { title: "Aruba", value: "AW" },
- { title: "Australia", value: "AU" },
- { title: "Austria", value: "AT" },
- { title: "Azerbaijan", value: "AZ" },
- { title: "Bahamas", value: "BS" },
- { title: "Bahrain", value: "BH" },
- { title: "Bangladesh", value: "BD" },
- { title: "Barbados", value: "BB" },
- { title: "Belarus", value: "BY" },
- { title: "Belgium", value: "BE" },
- { title: "Belize", value: "BZ" },
- { title: "Benin", value: "BJ" },
- { title: "Bermuda", value: "BM" },
- { title: "Bhutan", value: "BT" },
- { title: "Bolivia", value: "BO" },
- { title: "Bonaire", value: "BQ" },
- { title: "Bosnia and Herzegovina", value: "BA" },
- { title: "Botswana", value: "BW" },
- { title: "Bouvet Island", value: "BV" },
- { title: "Brazil", value: "BR" },
- { title: "British Indian Ocean", value: "IO" },
- { title: "Brunei Darussalam", value: "BN" },
- { title: "Bulgaria", value: "BG" },
- { title: "Burkina Faso", value: "BF" },
- { title: "Burundi", value: "BI" },
- { title: "Cabo Verde", value: "CV" },
- { title: "Cambodia", value: "KH" },
- { title: "Cameroon", value: "CM" },
- { title: "Canada", value: "CA" },
- { title: "Cayman Islands", value: "KY" },
- { title: "Central African Republic", value: "CF" },
- { title: "Chad", value: "TD" },
- { title: "Chile", value: "CL" },
- { title: "China", value: "CN" },
- { title: "Christmas Island", value: "CX" },
- { title: "Cocos (Keeling) Islands", value: "CC" },
- { title: "Colombia", value: "CO" },
- { title: "Comoros", value: "KM" },
- { title: "Congo", value: "CG" },
- { title: "Congo", value: "CD" },
- { title: "Cook Islands", value: "CK" },
- { title: "Costa Rica", value: "CR" },
- { title: "Côte d'Ivoire", value: "CI" },
- { title: "Cuba", value: "CU" },
- { title: "Curaçao", value: "CW" },
- { title: "Cyprus", value: "CY" },
- { title: "Czechia", value: "CZ" },
- { title: "Denmark", value: "DK" },
- { title: "Djibouti", value: "DJ" },
- { title: "Dominica", value: "DM" },
- { title: "Dominican Republic", value: "DO" },
- { title: "Ecuador", value: "EC" },
- { title: "Egypt", value: "EG" },
- { title: "El Salvador", value: "SV" },
- { title: "Equatorial Guinea", value: "GQ" },
- { title: "Eritrea", value: "ER" },
- { title: "Estonia", value: "EE" },
- { title: "Eswatini", value: "SZ" },
- { title: "Ethiopia", value: "ET" },
- { title: "Falkland Islands", value: "FK" },
- { title: "Faroe Islands", value: "FO" },
- { title: "Fiji", value: "FJ" },
- { title: "Finland", value: "FI" },
- { title: "France", value: "FR" },
- { title: "French Guiana", value: "GF" },
- { title: "French Polynesia", value: "PF" },
- { title: "French Southern Territories", value: "TF" },
- { title: "Gabon", value: "GA" },
- { title: "Gambia", value: "GM" },
- { title: "Georgia", value: "GE" },
- { title: "Germany", value: "DE" },
- { title: "Ghana", value: "GH" },
- { title: "Gibraltar", value: "GI" },
- { title: "Greece", value: "GR" },
- { title: "Greenland", value: "GL" },
- { title: "Grenada", value: "GD" },
- { title: "Guadeloupe", value: "GP" },
- { title: "Guam", value: "GU" },
- { title: "Guatemala", value: "GT" },
- { title: "Guernsey", value: "GG" },
- { title: "Guinea", value: "GN" },
- { title: "Guinea-Bissau", value: "GW" },
- { title: "Guyana", value: "GY" },
- { title: "Haiti", value: "HT" },
- { title: "Heard Island and McDonald Islands", value: "HM" },
- { title: "Holy See", value: "VA" },
- { title: "Honduras", value: "HN" },
- { title: "Hong Kong", value: "HK" },
- { title: "Hungary", value: "HU" },
- { title: "Iceland", value: "IS" },
- { title: "India", value: "IN" },
- { title: "Indonesia", value: "ID" },
- { title: "Iran", value: "IR" },
- { title: "Iraq", value: "IQ" },
- { title: "Ireland", value: "IE" },
- { title: "Isle of Man", value: "IM" },
- { title: "Israel", value: "IL" },
- { title: "Italy", value: "IT" },
- { title: "Jamaica", value: "JM" },
- { title: "Japan", value: "JP" },
- { title: "Jersey", value: "JE" },
- { title: "Jordan", value: "JO" },
- { title: "Kazakhstan", value: "KZ" },
- { title: "Kenya", value: "KE" },
- { title: "Kiribati", value: "KI" },
- { title: "North Korea", value: "KP" },
- { title: "South Korea", value: "KR" },
- { title: "Kuwait", value: "KW" },
- { title: "Kyrgyzstan", value: "KG" },
- { title: "Lao People's Democratic Republic", value: "LA" },
- { title: "Latvia", value: "LV" },
- { title: "Lebanon", value: "LB" },
- { title: "Lesotho", value: "LS" },
- { title: "Liberia", value: "LR" },
- { title: "Libya", value: "LY" },
- { title: "Liechtenstein", value: "LI" },
- { title: "Lithuania", value: "LT" },
- { title: "Luxembourg", value: "LU" },
- { title: "Macao", value: "MO" },
- { title: "Madagascar", value: "MG" },
- { title: "Malawi", value: "MW" },
- { title: "Malaysia", value: "MY" },
- { title: "Maldives", value: "MV" },
- { title: "Mali", value: "ML" },
- { title: "Malta", value: "MT" },
- { title: "Marshall Islands", value: "MH" },
- { title: "Martinique", value: "MQ" },
- { title: "Mauritania", value: "MR" },
- { title: "Mauritius", value: "MU" },
- { title: "Mayotte", value: "YT" },
- { title: "Mexico", value: "MX" },
- { title: "Micronesia", value: "FM" },
- { title: "Moldova", value: "MD" },
- { title: "Monaco", value: "MC" },
- { title: "Mongolia", value: "MN" },
- { title: "Montenegro", value: "ME" },
- { title: "Montserrat", value: "MS" },
- { title: "Morocco", value: "MA" },
- { title: "Mozambique", value: "MZ" },
- { title: "Myanmar", value: "MM" },
- { title: "Namibia", value: "NA" },
- { title: "Nauru", value: "NR" },
- { title: "Nepal", value: "NP" },
- { title: "Netherlands", value: "NL" },
- { title: "New Caledonia", value: "NC" },
- { title: "New Zealand", value: "NZ" },
- { title: "Nicaragua", value: "NI" },
- { title: "Niger", value: "NE" },
- { title: "Nigeria", value: "NG" },
- { title: "Niue", value: "NU" },
- { title: "Norfolk Island", value: "NF" },
- { title: "North Macedonia", value: "MK" },
- { title: "Northern Mariana Islands", value: "MP" },
- { title: "Norway", value: "NO" },
- { title: "Oman", value: "OM" },
- { title: "Pakistan", value: "PK" },
- { title: "Palau", value: "PW" },
- { title: "Panama", value: "PA" },
- { title: "Papua New Guinea", value: "PG" },
- { title: "Paraguay", value: "PY" },
- { title: "Peru", value: "PE" },
- { title: "Philippines", value: "PH" },
- { title: "Pitcairn", value: "PN" },
- { title: "Poland", value: "PL" },
- { title: "Portugal", value: "PT" },
- { title: "Puerto Rico", value: "PR" },
- { title: "Qatar", value: "QA" },
- { title: "Réunion", value: "RE" },
- { title: "Romania", value: "RO" },
- { title: "Russian Federation", value: "RU" },
- { title: "Rwanda", value: "RW" },
- { title: "Saint Barthélemy", value: "BL" },
- { title: "Saint Helena, Ascension and Tristan da Cunha", value: "SH" },
- { title: "Saint Kitts and Nevis", value: "KN" },
- { title: "Saint Lucia", value: "LC" },
- { title: "Saint Martin (French part)", value: "MF" },
- { title: "Saint Pierre and Miquelon", value: "PM" },
- { title: "Saint Vincent and the Grenadines", value: "VC" },
- { title: "Samoa", value: "WS" },
- { title: "San Marino", value: "SM" },
- { title: "Sao Tome and Principe", value: "ST" },
- { title: "Saudi Arabia", value: "SA" },
- { title: "Senegal", value: "SN" },
- { title: "Serbia", value: "RS" },
- { title: "Seychelles", value: "SC" },
- { title: "Sierra Leone", value: "SL" },
- { title: "Singapore", value: "SG" },
- { title: "Slovakia", value: "SK" },
- { title: "Slovenia", value: "SI" },
- { title: "Solomon Islands", value: "SB" },
- { title: "Somalia", value: "SO" },
- { title: "South Africa", value: "ZA" },
- { title: "South Georgia and the South Sandwich Islands", value: "GS" },
- { title: "South Sudan", value: "SS" },
- { title: "Spain", value: "ES" },
- { title: "Sri Lanka", value: "LK" },
- { title: "Sudan", value: "SD" },
- { title: "Suriname", value: "SR" },
- { title: "Svalbard and Jan Mayen", value: "SJ" },
- { title: "Sweden", value: "SE" },
- { title: "Switzerland", value: "CH" },
- { title: "Syrian Arab Republic", value: "SY" },
- { title: "Taiwan, Province of China", value: "TW" },
- { title: "Tajikistan", value: "TJ" },
- { title: "Tanzania, United Republic of", value: "TZ" },
- { title: "Thailand", value: "TH" },
- { title: "Timor-Leste", value: "TL" },
- { title: "Togo", value: "TG" },
- { title: "Tokelau", value: "TK" },
- { title: "Tonga", value: "TO" },
- { title: "Trinidad and Tobago", value: "TT" },
- { title: "Tunisia", value: "TN" },
- { title: "Turkey", value: "TR" },
- { title: "Turkmenistan", value: "TM" },
- { title: "Turks and Caicos Islands", value: "TC" },
- { title: "Tuvalu", value: "TV" },
- { title: "Uganda", value: "UG" },
- { title: "Ukraine", value: "UA" },
- { title: "United Arab Emirates", value: "AE" },
- { title: "United Kingdom", value: "GB" },
- { title: "United States", value: "US" },
- { title: "United States Minor Outlying Islands", value: "UM" },
- { title: "Uruguay", value: "UY" },
- { title: "Uzbekistan", value: "UZ" },
- { title: "Vanuatu", value: "VU" },
- { title: "Venezuela", value: "VE" },
- { title: "Viet Nam", value: "VN" },
- { title: "Virgin Islands (British)", value: "VG" },
- { title: "Virgin Islands (U.S.)", value: "VI" },
- { title: "Wallis and Futuna", value: "WF" },
- { title: "Western Sahara", value: "EH" },
- { title: "Yemen", value: "YE" },
- { title: "Zambia", value: "ZM" },
- { title: "Zimbabwe", value: "ZW" },
-];
+ { title: 'Afghanistan', value: 'AF' },
+ { title: 'Åland Islands', value: 'AX' },
+ { title: 'Albania', value: 'AL' },
+ { title: 'Algeria', value: 'DZ' },
+ { title: 'American Samoa', value: 'AS' },
+ { title: 'Andorra', value: 'AD' },
+ { title: 'Angola', value: 'AO' },
+ { title: 'Anguilla', value: 'AI' },
+ { title: 'Antarctica', value: 'AQ' },
+ { title: 'Antigua and Barbuda', value: 'AG' },
+ { title: 'Argentina', value: 'AR' },
+ { title: 'Armenia', value: 'AM' },
+ { title: 'Aruba', value: 'AW' },
+ { title: 'Australia', value: 'AU' },
+ { title: 'Austria', value: 'AT' },
+ { title: 'Azerbaijan', value: 'AZ' },
+ { title: 'Bahamas', value: 'BS' },
+ { title: 'Bahrain', value: 'BH' },
+ { title: 'Bangladesh', value: 'BD' },
+ { title: 'Barbados', value: 'BB' },
+ { title: 'Belarus', value: 'BY' },
+ { title: 'Belgium', value: 'BE' },
+ { title: 'Belize', value: 'BZ' },
+ { title: 'Benin', value: 'BJ' },
+ { title: 'Bermuda', value: 'BM' },
+ { title: 'Bhutan', value: 'BT' },
+ { title: 'Bolivia', value: 'BO' },
+ { title: 'Bonaire', value: 'BQ' },
+ { title: 'Bosnia and Herzegovina', value: 'BA' },
+ { title: 'Botswana', value: 'BW' },
+ { title: 'Bouvet Island', value: 'BV' },
+ { title: 'Brazil', value: 'BR' },
+ { title: 'British Indian Ocean', value: 'IO' },
+ { title: 'Brunei Darussalam', value: 'BN' },
+ { title: 'Bulgaria', value: 'BG' },
+ { title: 'Burkina Faso', value: 'BF' },
+ { title: 'Burundi', value: 'BI' },
+ { title: 'Cabo Verde', value: 'CV' },
+ { title: 'Cambodia', value: 'KH' },
+ { title: 'Cameroon', value: 'CM' },
+ { title: 'Canada', value: 'CA' },
+ { title: 'Cayman Islands', value: 'KY' },
+ { title: 'Central African Republic', value: 'CF' },
+ { title: 'Chad', value: 'TD' },
+ { title: 'Chile', value: 'CL' },
+ { title: 'China', value: 'CN' },
+ { title: 'Christmas Island', value: 'CX' },
+ { title: 'Cocos (Keeling) Islands', value: 'CC' },
+ { title: 'Colombia', value: 'CO' },
+ { title: 'Comoros', value: 'KM' },
+ { title: 'Congo', value: 'CG' },
+ { title: 'Congo', value: 'CD' },
+ { title: 'Cook Islands', value: 'CK' },
+ { title: 'Costa Rica', value: 'CR' },
+ { title: "Côte d'Ivoire", value: 'CI' },
+ { title: 'Cuba', value: 'CU' },
+ { title: 'Curaçao', value: 'CW' },
+ { title: 'Cyprus', value: 'CY' },
+ { title: 'Czechia', value: 'CZ' },
+ { title: 'Denmark', value: 'DK' },
+ { title: 'Djibouti', value: 'DJ' },
+ { title: 'Dominica', value: 'DM' },
+ { title: 'Dominican Republic', value: 'DO' },
+ { title: 'Ecuador', value: 'EC' },
+ { title: 'Egypt', value: 'EG' },
+ { title: 'El Salvador', value: 'SV' },
+ { title: 'Equatorial Guinea', value: 'GQ' },
+ { title: 'Eritrea', value: 'ER' },
+ { title: 'Estonia', value: 'EE' },
+ { title: 'Eswatini', value: 'SZ' },
+ { title: 'Ethiopia', value: 'ET' },
+ { title: 'Falkland Islands', value: 'FK' },
+ { title: 'Faroe Islands', value: 'FO' },
+ { title: 'Fiji', value: 'FJ' },
+ { title: 'Finland', value: 'FI' },
+ { title: 'France', value: 'FR' },
+ { title: 'French Guiana', value: 'GF' },
+ { title: 'French Polynesia', value: 'PF' },
+ { title: 'French Southern Territories', value: 'TF' },
+ { title: 'Gabon', value: 'GA' },
+ { title: 'Gambia', value: 'GM' },
+ { title: 'Georgia', value: 'GE' },
+ { title: 'Germany', value: 'DE' },
+ { title: 'Ghana', value: 'GH' },
+ { title: 'Gibraltar', value: 'GI' },
+ { title: 'Greece', value: 'GR' },
+ { title: 'Greenland', value: 'GL' },
+ { title: 'Grenada', value: 'GD' },
+ { title: 'Guadeloupe', value: 'GP' },
+ { title: 'Guam', value: 'GU' },
+ { title: 'Guatemala', value: 'GT' },
+ { title: 'Guernsey', value: 'GG' },
+ { title: 'Guinea', value: 'GN' },
+ { title: 'Guinea-Bissau', value: 'GW' },
+ { title: 'Guyana', value: 'GY' },
+ { title: 'Haiti', value: 'HT' },
+ { title: 'Heard Island and McDonald Islands', value: 'HM' },
+ { title: 'Holy See', value: 'VA' },
+ { title: 'Honduras', value: 'HN' },
+ { title: 'Hong Kong', value: 'HK' },
+ { title: 'Hungary', value: 'HU' },
+ { title: 'Iceland', value: 'IS' },
+ { title: 'India', value: 'IN' },
+ { title: 'Indonesia', value: 'ID' },
+ { title: 'Iran', value: 'IR' },
+ { title: 'Iraq', value: 'IQ' },
+ { title: 'Ireland', value: 'IE' },
+ { title: 'Isle of Man', value: 'IM' },
+ { title: 'Israel', value: 'IL' },
+ { title: 'Italy', value: 'IT' },
+ { title: 'Jamaica', value: 'JM' },
+ { title: 'Japan', value: 'JP' },
+ { title: 'Jersey', value: 'JE' },
+ { title: 'Jordan', value: 'JO' },
+ { title: 'Kazakhstan', value: 'KZ' },
+ { title: 'Kenya', value: 'KE' },
+ { title: 'Kiribati', value: 'KI' },
+ { title: 'North Korea', value: 'KP' },
+ { title: 'South Korea', value: 'KR' },
+ { title: 'Kuwait', value: 'KW' },
+ { title: 'Kyrgyzstan', value: 'KG' },
+ { title: "Lao People's Democratic Republic", value: 'LA' },
+ { title: 'Latvia', value: 'LV' },
+ { title: 'Lebanon', value: 'LB' },
+ { title: 'Lesotho', value: 'LS' },
+ { title: 'Liberia', value: 'LR' },
+ { title: 'Libya', value: 'LY' },
+ { title: 'Liechtenstein', value: 'LI' },
+ { title: 'Lithuania', value: 'LT' },
+ { title: 'Luxembourg', value: 'LU' },
+ { title: 'Macao', value: 'MO' },
+ { title: 'Madagascar', value: 'MG' },
+ { title: 'Malawi', value: 'MW' },
+ { title: 'Malaysia', value: 'MY' },
+ { title: 'Maldives', value: 'MV' },
+ { title: 'Mali', value: 'ML' },
+ { title: 'Malta', value: 'MT' },
+ { title: 'Marshall Islands', value: 'MH' },
+ { title: 'Martinique', value: 'MQ' },
+ { title: 'Mauritania', value: 'MR' },
+ { title: 'Mauritius', value: 'MU' },
+ { title: 'Mayotte', value: 'YT' },
+ { title: 'Mexico', value: 'MX' },
+ { title: 'Micronesia', value: 'FM' },
+ { title: 'Moldova', value: 'MD' },
+ { title: 'Monaco', value: 'MC' },
+ { title: 'Mongolia', value: 'MN' },
+ { title: 'Montenegro', value: 'ME' },
+ { title: 'Montserrat', value: 'MS' },
+ { title: 'Morocco', value: 'MA' },
+ { title: 'Mozambique', value: 'MZ' },
+ { title: 'Myanmar', value: 'MM' },
+ { title: 'Namibia', value: 'NA' },
+ { title: 'Nauru', value: 'NR' },
+ { title: 'Nepal', value: 'NP' },
+ { title: 'Netherlands', value: 'NL' },
+ { title: 'New Caledonia', value: 'NC' },
+ { title: 'New Zealand', value: 'NZ' },
+ { title: 'Nicaragua', value: 'NI' },
+ { title: 'Niger', value: 'NE' },
+ { title: 'Nigeria', value: 'NG' },
+ { title: 'Niue', value: 'NU' },
+ { title: 'Norfolk Island', value: 'NF' },
+ { title: 'North Macedonia', value: 'MK' },
+ { title: 'Northern Mariana Islands', value: 'MP' },
+ { title: 'Norway', value: 'NO' },
+ { title: 'Oman', value: 'OM' },
+ { title: 'Pakistan', value: 'PK' },
+ { title: 'Palau', value: 'PW' },
+ { title: 'Panama', value: 'PA' },
+ { title: 'Papua New Guinea', value: 'PG' },
+ { title: 'Paraguay', value: 'PY' },
+ { title: 'Peru', value: 'PE' },
+ { title: 'Philippines', value: 'PH' },
+ { title: 'Pitcairn', value: 'PN' },
+ { title: 'Poland', value: 'PL' },
+ { title: 'Portugal', value: 'PT' },
+ { title: 'Puerto Rico', value: 'PR' },
+ { title: 'Qatar', value: 'QA' },
+ { title: 'Réunion', value: 'RE' },
+ { title: 'Romania', value: 'RO' },
+ { title: 'Russian Federation', value: 'RU' },
+ { title: 'Rwanda', value: 'RW' },
+ { title: 'Saint Barthélemy', value: 'BL' },
+ { title: 'Saint Helena, Ascension and Tristan da Cunha', value: 'SH' },
+ { title: 'Saint Kitts and Nevis', value: 'KN' },
+ { title: 'Saint Lucia', value: 'LC' },
+ { title: 'Saint Martin (French part)', value: 'MF' },
+ { title: 'Saint Pierre and Miquelon', value: 'PM' },
+ { title: 'Saint Vincent and the Grenadines', value: 'VC' },
+ { title: 'Samoa', value: 'WS' },
+ { title: 'San Marino', value: 'SM' },
+ { title: 'Sao Tome and Principe', value: 'ST' },
+ { title: 'Saudi Arabia', value: 'SA' },
+ { title: 'Senegal', value: 'SN' },
+ { title: 'Serbia', value: 'RS' },
+ { title: 'Seychelles', value: 'SC' },
+ { title: 'Sierra Leone', value: 'SL' },
+ { title: 'Singapore', value: 'SG' },
+ { title: 'Slovakia', value: 'SK' },
+ { title: 'Slovenia', value: 'SI' },
+ { title: 'Solomon Islands', value: 'SB' },
+ { title: 'Somalia', value: 'SO' },
+ { title: 'South Africa', value: 'ZA' },
+ { title: 'South Georgia and the South Sandwich Islands', value: 'GS' },
+ { title: 'South Sudan', value: 'SS' },
+ { title: 'Spain', value: 'ES' },
+ { title: 'Sri Lanka', value: 'LK' },
+ { title: 'Sudan', value: 'SD' },
+ { title: 'Suriname', value: 'SR' },
+ { title: 'Svalbard and Jan Mayen', value: 'SJ' },
+ { title: 'Sweden', value: 'SE' },
+ { title: 'Switzerland', value: 'CH' },
+ { title: 'Syrian Arab Republic', value: 'SY' },
+ { title: 'Taiwan, Province of China', value: 'TW' },
+ { title: 'Tajikistan', value: 'TJ' },
+ { title: 'Tanzania, United Republic of', value: 'TZ' },
+ { title: 'Thailand', value: 'TH' },
+ { title: 'Timor-Leste', value: 'TL' },
+ { title: 'Togo', value: 'TG' },
+ { title: 'Tokelau', value: 'TK' },
+ { title: 'Tonga', value: 'TO' },
+ { title: 'Trinidad and Tobago', value: 'TT' },
+ { title: 'Tunisia', value: 'TN' },
+ { title: 'Turkey', value: 'TR' },
+ { title: 'Turkmenistan', value: 'TM' },
+ { title: 'Turks and Caicos Islands', value: 'TC' },
+ { title: 'Tuvalu', value: 'TV' },
+ { title: 'Uganda', value: 'UG' },
+ { title: 'Ukraine', value: 'UA' },
+ { title: 'United Arab Emirates', value: 'AE' },
+ { title: 'United Kingdom', value: 'GB' },
+ { title: 'United States', value: 'US' },
+ { title: 'United States Minor Outlying Islands', value: 'UM' },
+ { title: 'Uruguay', value: 'UY' },
+ { title: 'Uzbekistan', value: 'UZ' },
+ { title: 'Vanuatu', value: 'VU' },
+ { title: 'Venezuela', value: 'VE' },
+ { title: 'Viet Nam', value: 'VN' },
+ { title: 'Virgin Islands (British)', value: 'VG' },
+ { title: 'Virgin Islands (U.S.)', value: 'VI' },
+ { title: 'Wallis and Futuna', value: 'WF' },
+ { title: 'Western Sahara', value: 'EH' },
+ { title: 'Yemen', value: 'YE' },
+ { title: 'Zambia', value: 'ZM' },
+ { title: 'Zimbabwe', value: 'ZW' },
+]
const usStates: SelectOption[] = [
- { title: "Alabama", value: "AL" },
- { title: "Alaska", value: "AK" },
- { title: "Arizona", value: "AZ" },
- { title: "Arkansas", value: "AR" },
- { title: "California", value: "CA" },
- { title: "Colorado", value: "CO" },
- { title: "Connecticut", value: "CT" },
- { title: "Delaware", value: "DE" },
- { title: "Florida", value: "FL" },
- { title: "Georgia", value: "GA" },
- { title: "Hawaii", value: "HI" },
- { title: "Idaho", value: "ID" },
- { title: "Illinois", value: "IL" },
- { title: "Indiana", value: "IN" },
- { title: "Iowa", value: "IA" },
- { title: "Kansas", value: "KS" },
- { title: "Kentucky", value: "KY" },
- { title: "Louisiana", value: "LA" },
- { title: "Maine", value: "ME" },
- { title: "Maryland", value: "MD" },
- { title: "Massachusetts", value: "MA" },
- { title: "Michigan", value: "MI" },
- { title: "Minnesota", value: "MN" },
- { title: "Mississippi", value: "MS" },
- { title: "Missouri", value: "MO" },
- { title: "Montana", value: "MT" },
- { title: "Nebraska", value: "NE" },
- { title: "Nevada", value: "NV" },
- { title: "New Hampshire", value: "NH" },
- { title: "New Jersey", value: "NJ" },
- { title: "New Mexico", value: "NM" },
- { title: "New York", value: "NY" },
- { title: "North Carolina", value: "NC" },
- { title: "North Dakota", value: "ND" },
- { title: "Ohio", value: "OH" },
- { title: "Oklahoma", value: "OK" },
- { title: "Oregon", value: "OR" },
- { title: "Pennsylvania", value: "PA" },
- { title: "Rhode Island", value: "RI" },
- { title: "South Carolina", value: "SC" },
- { title: "South Dakota", value: "SD" },
- { title: "Tennessee", value: "TN" },
- { title: "Texas", value: "TX" },
- { title: "Utah", value: "UT" },
- { title: "Vermont", value: "VT" },
- { title: "Virginia", value: "VA" },
- { title: "Washington", value: "WA" },
- { title: "West Virginia", value: "WV" },
- { title: "Wisconsin", value: "WI" },
- { title: "Wyoming", value: "WY" },
- { title: "District of Columbia", value: "DC" },
-];
+ { title: 'Alabama', value: 'AL' },
+ { title: 'Alaska', value: 'AK' },
+ { title: 'Arizona', value: 'AZ' },
+ { title: 'Arkansas', value: 'AR' },
+ { title: 'California', value: 'CA' },
+ { title: 'Colorado', value: 'CO' },
+ { title: 'Connecticut', value: 'CT' },
+ { title: 'Delaware', value: 'DE' },
+ { title: 'Florida', value: 'FL' },
+ { title: 'Georgia', value: 'GA' },
+ { title: 'Hawaii', value: 'HI' },
+ { title: 'Idaho', value: 'ID' },
+ { title: 'Illinois', value: 'IL' },
+ { title: 'Indiana', value: 'IN' },
+ { title: 'Iowa', value: 'IA' },
+ { title: 'Kansas', value: 'KS' },
+ { title: 'Kentucky', value: 'KY' },
+ { title: 'Louisiana', value: 'LA' },
+ { title: 'Maine', value: 'ME' },
+ { title: 'Maryland', value: 'MD' },
+ { title: 'Massachusetts', value: 'MA' },
+ { title: 'Michigan', value: 'MI' },
+ { title: 'Minnesota', value: 'MN' },
+ { title: 'Mississippi', value: 'MS' },
+ { title: 'Missouri', value: 'MO' },
+ { title: 'Montana', value: 'MT' },
+ { title: 'Nebraska', value: 'NE' },
+ { title: 'Nevada', value: 'NV' },
+ { title: 'New Hampshire', value: 'NH' },
+ { title: 'New Jersey', value: 'NJ' },
+ { title: 'New Mexico', value: 'NM' },
+ { title: 'New York', value: 'NY' },
+ { title: 'North Carolina', value: 'NC' },
+ { title: 'North Dakota', value: 'ND' },
+ { title: 'Ohio', value: 'OH' },
+ { title: 'Oklahoma', value: 'OK' },
+ { title: 'Oregon', value: 'OR' },
+ { title: 'Pennsylvania', value: 'PA' },
+ { title: 'Rhode Island', value: 'RI' },
+ { title: 'South Carolina', value: 'SC' },
+ { title: 'South Dakota', value: 'SD' },
+ { title: 'Tennessee', value: 'TN' },
+ { title: 'Texas', value: 'TX' },
+ { title: 'Utah', value: 'UT' },
+ { title: 'Vermont', value: 'VT' },
+ { title: 'Virginia', value: 'VA' },
+ { title: 'Washington', value: 'WA' },
+ { title: 'West Virginia', value: 'WV' },
+ { title: 'Wisconsin', value: 'WI' },
+ { title: 'Wyoming', value: 'WY' },
+ { title: 'District of Columbia', value: 'DC' },
+]
const canadaProvinces: SelectOption[] = [
- { title: "Alberta", value: "AB" },
- { title: "British Columbia", value: "BC" },
- { title: "Manitoba", value: "MB" },
- { title: "New Brunswick", value: "NB" },
- { title: "Newfoundland and Labrador", value: "NL" },
- { title: "Nova Scotia", value: "NS" },
- { title: "Ontario", value: "ON" },
- { title: "Prince Edward Island", value: "PE" },
- { title: "Quebec", value: "QC" },
- { title: "Saskatchewan", value: "SK" },
- { title: "Northwest Territories", value: "NT" },
- { title: "Nunavut", value: "NU" },
- { title: "Yukon", value: "YT" },
-];
+ { title: 'Alberta', value: 'AB' },
+ { title: 'British Columbia', value: 'BC' },
+ { title: 'Manitoba', value: 'MB' },
+ { title: 'New Brunswick', value: 'NB' },
+ { title: 'Newfoundland and Labrador', value: 'NL' },
+ { title: 'Nova Scotia', value: 'NS' },
+ { title: 'Ontario', value: 'ON' },
+ { title: 'Prince Edward Island', value: 'PE' },
+ { title: 'Quebec', value: 'QC' },
+ { title: 'Saskatchewan', value: 'SK' },
+ { title: 'Northwest Territories', value: 'NT' },
+ { title: 'Nunavut', value: 'NU' },
+ { title: 'Yukon', value: 'YT' },
+]
export function getStateOptions(country: string): SelectOption[] {
- if (country === "US") {
- return usStates;
+ if (country === 'US') {
+ return usStates
}
- if (country === "CA") {
- return canadaProvinces;
+ if (country === 'CA') {
+ return canadaProvinces
}
- return [];
+ return []
}
-export default countries;
+export default countries
diff --git a/web/app/utils/errors.ts b/web/app/utils/errors.ts
index c80b1d95..b72bfbf3 100644
--- a/web/app/utils/errors.ts
+++ b/web/app/utils/errors.ts
@@ -1,5 +1,5 @@
-import Bag from "~/utils/bag";
-import { capitalize } from "~/utils/capitalize";
+import Bag from '~/utils/bag'
+import { capitalize } from '~/utils/capitalize'
export class ErrorMessages extends Bag<string> {}
@@ -8,40 +8,40 @@ const sanitize = (key: string, values: Array<string>): Array<string> => {
return capitalize(
value
.split(key)
- .join(key.replace("_", " "))
- .split("_")
- .join(" ")
- .split("-")
- .join(" ")
- .split(" char")
- .join(" character")
- .split(" field ")
- .join(" "),
- );
- });
-};
+ .join(key.replace('_', ' '))
+ .split('_')
+ .join(' ')
+ .split('-')
+ .join(' ')
+ .split(' char')
+ .join(' character')
+ .split(' field ')
+ .join(' '),
+ )
+ })
+}
interface AxiosLikeError {
response?: {
- data?: { data?: Record<string, string[]> };
- status?: number;
- };
+ data?: { data?: Record<string, string[]> }
+ status?: number
+ }
}
export const getErrorMessages = (error: AxiosLikeError): ErrorMessages => {
- const errors = new ErrorMessages();
+ const errors = new ErrorMessages()
if (
error === null ||
- typeof error.response?.data?.data !== "object" ||
+ typeof error.response?.data?.data !== 'object' ||
error.response?.data?.data === null ||
error.response?.status !== 422
) {
- return errors;
+ return errors
}
Object.keys(error.response.data.data).forEach((key: string) => {
- errors.addMany(key, sanitize(key, error.response!.data!.data![key]));
- });
+ errors.addMany(key, sanitize(key, error.response!.data!.data![key]))
+ })
- return errors;
-};
+ return errors
+}
diff --git a/web/app/utils/filters.ts b/web/app/utils/filters.ts
index 863cbdab..2a8e6556 100644
--- a/web/app/utils/filters.ts
+++ b/web/app/utils/filters.ts
@@ -1,75 +1,75 @@
-import { intervalToDuration, formatDuration } from "date-fns";
-import { parsePhoneNumber, isValidPhoneNumber } from "libphonenumber-js";
+import { intervalToDuration, formatDuration } from 'date-fns'
+import { parsePhoneNumber, isValidPhoneNumber } from 'libphonenumber-js'
export function formatPhoneNumber(value: string): string {
- if (!value || typeof value !== "string") {
- return value ?? "";
+ if (!value || typeof value !== 'string') {
+ return value ?? ''
}
if (!isValidPhoneNumber(value)) {
- return value;
+ return value
}
- const phoneNumber = parsePhoneNumber(value);
+ const phoneNumber = parsePhoneNumber(value)
if (phoneNumber) {
- return phoneNumber.formatInternational();
+ return phoneNumber.formatInternational()
}
- return value;
+ return value
}
export function phoneCountry(value: string): string {
- const phoneNumber = parsePhoneNumber(value);
+ const phoneNumber = parsePhoneNumber(value)
if (phoneNumber && phoneNumber.country) {
- const regionNames = new Intl.DisplayNames(undefined, { type: "region" });
- return regionNames.of(phoneNumber.country) ?? "Earth";
+ const regionNames = new Intl.DisplayNames(undefined, { type: 'region' })
+ return regionNames.of(phoneNumber.country) ?? 'Earth'
}
- return "Earth";
+ return 'Earth'
}
export function formatTimestamp(value: string): string {
- return new Date(value).toLocaleString();
+ return new Date(value).toLocaleString()
}
export function formatMoney(value: string | number): string {
- return new Intl.NumberFormat("en-US", {
- style: "currency",
- currency: "USD",
- }).format(typeof value === "string" ? parseInt(value) : value);
+ return new Intl.NumberFormat('en-US', {
+ style: 'currency',
+ currency: 'USD',
+ }).format(typeof value === 'string' ? parseInt(value) : value)
}
export function formatDecimal(value: string | number): string {
- return new Intl.NumberFormat("en-US", {
- style: "decimal",
- }).format(typeof value === "string" ? parseInt(value) : value);
+ return new Intl.NumberFormat('en-US', {
+ style: 'decimal',
+ }).format(typeof value === 'string' ? parseInt(value) : value)
}
export function formatBillingPeriod(value: string): string {
- return new Date(value).toLocaleDateString("en-US", {
- year: "numeric",
- month: "long",
- });
+ return new Date(value).toLocaleDateString('en-US', {
+ year: 'numeric',
+ month: 'long',
+ })
}
export function formatBillingPeriodDateOrdinal(value: string): string {
- const date = new Date(value);
- const day = date.getDate();
- const month = date.toLocaleDateString("en-US", { month: "long" });
- const year = date.getFullYear();
+ const date = new Date(value)
+ const day = date.getDate()
+ const month = date.toLocaleDateString('en-US', { month: 'long' })
+ const year = date.getFullYear()
const suffix =
day % 10 === 1 && day !== 11
- ? "st"
+ ? 'st'
: day % 10 === 2 && day !== 12
- ? "nd"
+ ? 'nd'
: day % 10 === 3 && day !== 13
- ? "rd"
- : "th";
+ ? 'rd'
+ : 'th'
- return `${month} ${day}<sup>${suffix}</sup> ${year}`;
+ return `${month} ${day}<sup>${suffix}</sup> ${year}`
}
export function humanizeTime(value: string): string {
const durations = intervalToDuration({
start: new Date(),
end: new Date(value),
- });
- return formatDuration(durations);
+ })
+ return formatDuration(durations)
}
diff --git a/web/public/integrations.js b/web/public/integrations.js
index 660159cb..4fe4b5ae 100644
--- a/web/public/integrations.js
+++ b/web/public/integrations.js
@@ -1,15 +1,15 @@
-(function (c, l, a, r, i, t, y) {
+;(function (c, l, a, r, i, t, y) {
c[a] =
c[a] ||
function () {
- (c[a].q = c[a].q || []).push(arguments);
- };
- t = l.createElement(r);
- t.async = 1;
- t.src = "https://www.clarity.ms/tag/" + i;
- y = l.getElementsByTagName(r)[0];
- y.parentNode.insertBefore(t, y);
-})(window, document, "clarity", "script", "f3xyl9wf6t");
+ ;(c[a].q = c[a].q || []).push(arguments)
+ }
+ t = l.createElement(r)
+ t.async = 1
+ t.src = 'https://www.clarity.ms/tag/' + i
+ y = l.getElementsByTagName(r)[0]
+ y.parentNode.insertBefore(t, y)
+})(window, document, 'clarity', 'script', 'f3xyl9wf6t')
// LemonSqueezy
-window.lemonSqueezyAffiliateConfig = { store: "httpsms" };
+window.lemonSqueezyAffiliateConfig = { store: 'httpsms' }
diff --git a/web/shared/types/billing.ts b/web/shared/types/billing.ts
index 09da8a3b..5943b81e 100644
--- a/web/shared/types/billing.ts
+++ b/web/shared/types/billing.ts
@@ -1,10 +1,10 @@
export interface BillingUsage {
- id: string;
- user_id: string;
- start_timestamp: string;
- end_timestamp: string;
- sent_messages: number;
- received_messages: number;
- total_cost: number;
- created_at: string;
+ id: string
+ user_id: string
+ start_timestamp: string
+ end_timestamp: string
+ sent_messages: number
+ received_messages: number
+ total_cost: number
+ created_at: string
}
diff --git a/web/shared/types/bulk-message.ts b/web/shared/types/bulk-message.ts
new file mode 100644
index 00000000..9946967c
--- /dev/null
+++ b/web/shared/types/bulk-message.ts
@@ -0,0 +1,11 @@
+export interface BulkMessageOrder {
+ request_id: string
+ created_at: string
+ total: number
+ pending_count: number
+ scheduled_count: number
+ sent_count: number
+ delivered_count: number
+ failed_count: number
+ expired_count: number
+}
diff --git a/web/shared/types/heartbeat.ts b/web/shared/types/heartbeat.ts
index 0ba29f92..c1d08265 100644
--- a/web/shared/types/heartbeat.ts
+++ b/web/shared/types/heartbeat.ts
@@ -1,7 +1,7 @@
export interface Heartbeat {
- id: string;
- owner: string;
- phone_number: string;
- charging: boolean;
- timestamp: string;
+ id: string
+ owner: string
+ phone_number: string
+ charging: boolean
+ timestamp: string
}
diff --git a/web/shared/types/message-thread.ts b/web/shared/types/message-thread.ts
index fc5fd68f..9efd8193 100644
--- a/web/shared/types/message-thread.ts
+++ b/web/shared/types/message-thread.ts
@@ -1,13 +1,13 @@
export interface MessageThread {
- color: string;
- contact: string;
- created_at: string;
- id: string;
- last_message_content: string;
- last_message_id: string;
- is_archived: boolean;
- order_timestamp: string;
- owner: string;
- status: string;
- updated_at: string;
+ color: string
+ contact: string
+ created_at: string
+ id: string
+ last_message_content: string
+ last_message_id: string
+ is_archived: boolean
+ order_timestamp: string
+ owner: string
+ status: string
+ updated_at: string
}
diff --git a/web/shared/types/message.ts b/web/shared/types/message.ts
index 0761c623..b17b53ec 100644
--- a/web/shared/types/message.ts
+++ b/web/shared/types/message.ts
@@ -1,30 +1,30 @@
export interface Message {
- contact: string;
- content: string;
- attachments: Array<string> | null;
- created_at: string;
- failure_reason: string;
- id: string;
- last_attempted_at: string | null;
- order_timestamp: string;
- owner: string;
- received_at: string | null;
- request_received_at: string | null;
- send_time: number | null;
- sent_at: string;
- status: string;
- type: string;
- updated_at: string;
+ contact: string
+ content: string
+ attachments: Array<string> | null
+ created_at: string
+ failure_reason: string
+ id: string
+ last_attempted_at: string | null
+ order_timestamp: string
+ owner: string
+ received_at: string | null
+ request_received_at: string | null
+ send_time: number | null
+ sent_at: string
+ status: string
+ type: string
+ updated_at: string
}
export interface SearchMessagesRequest {
- owners: string[];
- types: string[];
- statuses: string[];
- query: string;
- sort_by: string;
- token?: string;
- sort_descending: boolean;
- skip: number;
- limit: number;
+ owners: string[]
+ types: string[]
+ statuses: string[]
+ query: string
+ sort_by: string
+ token?: string
+ sort_descending: boolean
+ skip: number
+ limit: number
}
diff --git a/web/shared/types/user.ts b/web/shared/types/user.ts
index b2b29b03..8a034f44 100644
--- a/web/shared/types/user.ts
+++ b/web/shared/types/user.ts
@@ -1,16 +1,16 @@
export interface User {
- id: string;
- email: string;
- api_key: string;
- active_phone_id: string | null;
- timezone: string;
- subscription_id: string | null;
- subscription_name: string | null;
- subscription_status: string | null;
- subscription_renews_at: string | null;
- subscription_ends_at: string | null;
- notification_heartbeat_enabled: boolean;
- notification_message_status_enabled: boolean;
- notification_newsletter_enabled: boolean;
- notification_webhook_enabled: boolean;
+ id: string
+ email: string
+ api_key: string
+ active_phone_id: string | null
+ timezone: string
+ subscription_id: string | null
+ subscription_name: string | null
+ subscription_status: string | null
+ subscription_renews_at: string | null
+ subscription_ends_at: string | null
+ notification_heartbeat_enabled: boolean
+ notification_message_status_enabled: boolean
+ notification_newsletter_enabled: boolean
+ notification_webhook_enabled: boolean
}