This commit is contained in:
Viet An
2026-06-08 23:13:00 +07:00
parent c1fa84083f
commit 853f969921
26 changed files with 131 additions and 1410 deletions

View File

@@ -248,26 +248,19 @@
</template>
<script setup lang="ts">
import { useNuxtApp } from "nuxt/app";
import { nextTick } from "vue";
import { render } from "@vue-email/render";
const nuxtApp = useNuxtApp();
import Modal from "~/components/Modal.vue";
import Template1 from "~/components/marketing/email/Template1.vue";
import SvgIcon from "~/components/SvgIcon.vue";
import Editor from "~/components/common/Editor.vue";
const nuxtApp = useNuxtApp();
const $snackbar = nuxtApp.$snackbar as (message?: string) => void;
const $getpath = nuxtApp.$getpath as (message?: string) => void;
const $getEditRights = nuxtApp.$getEditRights as () => boolean;
// const { $getpath, $snackbar} = useNuxtApp()
import { ref, watch, nextTick } from "vue";
import axios from "axios";
import Modal from "~/components/Modal.vue";
import Template1 from "~/lib/email/templates/Template1.vue";
import SvgIcon from "~/components/SvgIcon.vue";
import Editor from "~/components/common/Editor.vue";
const apiUrl = `${$getpath()}data`;
const sendEmailUrl = `${$getpath()}send-email`;
const showmodal = ref();
// Types
@@ -566,11 +559,7 @@ const handleSendEmail = async () => {
}
} catch (error) {
console.error("Error sending email:", error);
const errorMsg = axios.isAxiosError(error)
? error.response?.data?.error || error.message
: "Unknown error occurred";
$snackbar(`Failed to send email: ${errorMsg}`);
$snackbar(`Failed to send email: ${error.message}`);
} finally {
loading.value = false;
}
@@ -618,15 +607,10 @@ const getData = async () => {
const emailListUrl = `${apiUrl}/Email_List/`;
try {
const response = await axios.get(emailListUrl);
if (response.status === 200) {
console.log(response);
dataEmails.value = response.data.rows;
console.log(dataEmails.value);
} else {
throw new Error("Failed to fetch email list");
}
const response = await $fetch(emailListUrl);
dataEmails.value = response.rows;
console.log(response);
console.log(dataEmails.value);
} catch (error) {
console.error("Error fetching email list:", error);
throw error;