This commit is contained in:
Damodar Lohani committed 2023-04-18 11:47:07 +05:45
1 parent b8d248309c
commit f7044ce7cc
2 files changed
+22 -17

No files matched your search

@@ -44,8 +44,6 @@
loadEmailTemplate('invitation', 'en-us');
});
async function loadEmailTemplate(type: string, locale: string) {
const path = '/projects/' + projectId + '/templates/email/' + type + '/' + locale;
try {
emailTemplates[type] = await sdk.forConsole.projects.getEmailTemplate(
projectId,
@@ -61,24 +59,27 @@
}
async function saveEmailTemplate(type: string, data: any) {
console.log(data);
const path = '/projects/' + projectId + '/templates/email/' + type + '/' + data.locale;
if (!data.locale) {
addNotification({
type: 'error',
message: 'Locale is required'
});
return;
}
try {
emailTemplates[type] = await sdk.forConsole.client.call(
'PATCH',
new URL(sdk.forConsole.client.config.endpoint + path),
{ 'content-type': 'application/json' },
{
senderName: data.senderName,
senderEmail: data.senderEmail,
subject: data.subject,
message: data.message
}
emailTemplates[type] = await sdk.forConsole.projects.updateEmailTemplate(
projectId,
type,
data.locale,
data.senderName,
data.senderEmail,
data.subject,
data.message,
data.replyTo
);
addNotification({
type: 'success',
message: 'Template updated'
message: `Email ${type} template for ${data.locale} updated`
});
} catch (e) {
addNotification({
@@ -18,7 +18,10 @@
<div class="u-flex u-main-space-between">
<div>
<span class="icon-translate" />
<span class="text">{value}</span>
<span class="text"
>{value
? localeCodes.find((locale) => locale.code === value).name
: 'Select a language'}</span>
</div>
<InputSelectSearch
on:select
@@ -28,6 +31,7 @@
name="locale"
bind:value
bind:search
required
stretch={false}
showLabel={false}
interactiveOutput