diff --git a/packages/builder/src/pages/builder/portal/manage/email/[template].svelte b/packages/builder/src/pages/builder/portal/manage/email/[template].svelte
index fdee7e80b7..54b317a6f0 100644
--- a/packages/builder/src/pages/builder/portal/manage/email/[template].svelte
+++ b/packages/builder/src/pages/builder/portal/manage/email/[template].svelte
@@ -16,21 +16,16 @@
import Editor from "components/integration/QueryEditor.svelte"
import TemplateBindings from "./_components/TemplateBindings.svelte"
- const ConfigTypes = {
- SMTP: "smtp",
- }
-
export let template
let selected = "Edit"
- let selectedBindingTab = "Template"
let htmlEditor
- $: selectedTemplate = $email.templates.find(
+ $: selectedTemplate = $email?.templates?.find(
({ purpose }) => purpose === template
)
$: templateBindings =
- $email.definitions?.bindings[selectedTemplate.purpose] || []
+ $email.definitions?.bindings?.[selectedTemplate.purpose] || []
async function saveTemplate() {
try {
@@ -80,7 +75,7 @@
on:change={e => {
selectedTemplate.contents = e.detail.value
}}
- value={selectedTemplate.contents}
+ value={selectedTemplate?.contents}
/>
Bindings
@@ -95,7 +90,7 @@
@@ -105,7 +100,7 @@
>
- {@html selectedTemplate.contents}
+ {@html selectedTemplate?.contents}
diff --git a/packages/builder/src/pages/builder/portal/manage/email/_layout.svelte b/packages/builder/src/pages/builder/portal/manage/email/_layout.svelte
new file mode 100644
index 0000000000..188f0bb016
--- /dev/null
+++ b/packages/builder/src/pages/builder/portal/manage/email/_layout.svelte
@@ -0,0 +1,6 @@
+
+
+
diff --git a/packages/builder/src/pages/builder/portal/manage/email/index.svelte b/packages/builder/src/pages/builder/portal/manage/email/index.svelte
index 6b1036486b..0e2e2e98fd 100644
--- a/packages/builder/src/pages/builder/portal/manage/email/index.svelte
+++ b/packages/builder/src/pages/builder/portal/manage/email/index.svelte
@@ -12,7 +12,6 @@
Body,
Table,
} from "@budibase/bbui"
- import { onMount } from "svelte"
import { email } from "stores/portal"
import TemplateLink from "./_components/TemplateLink.svelte"
import api from "builderStore/api"
@@ -36,9 +35,6 @@
]
let smtpConfig
- let bindingsOpen = false
- let htmlModal
- let htmlEditor
let loading
async function saveSmtp() {
@@ -56,16 +52,8 @@
}
}
- async function saveTemplate() {
- try {
- await email.templates.save(selectedTemplate)
- notifications.success(`Template saved.`)
- } catch (err) {
- notifications.error(`Failed to update template settings. ${err}`)
- }
- }
-
async function fetchSmtp() {
+ loading = true
// fetch the configs for smtp
const smtpResponse = await api.get(`/api/admin/configs/${ConfigTypes.SMTP}`)
const smtpDoc = await smtpResponse.json()
@@ -82,14 +70,10 @@
} else {
smtpConfig = smtpDoc
}
+ loading = false
}
- onMount(async () => {
- loading = true
- await fetchSmtp()
- await email.templates.fetch()
- loading = false
- })
+ fetchSmtp()