Update template endpoints

This commit is contained in:
Andrew Kingston 2024-12-10 13:03:43 +00:00
parent 610133551e
commit f93f27877f
No known key found for this signature in database
1 changed files with 14 additions and 8 deletions

View File

@ -1,13 +1,20 @@
import { FetchTemplateResponse, Template } from "@budibase/types" import {
FetchGlobalTemplateByTypeResponse,
FetchGlobalTemplateDefinitionResponse,
FetchTemplateResponse,
SaveGlobalTemplateRequest,
SaveGlobalTemplateResponse,
Template,
} from "@budibase/types"
import { BaseAPIClient } from "./types" import { BaseAPIClient } from "./types"
export interface TemplateEndpoints { export interface TemplateEndpoints {
getEmailTemplates: () => Promise<Template[]> getEmailTemplates: () => Promise<FetchGlobalTemplateByTypeResponse>
getAppTemplates: () => Promise<FetchTemplateResponse> getAppTemplates: () => Promise<FetchTemplateResponse>
getEmailTemplateDefinitions: () => Promise<FetchGlobalTemplateDefinitionResponse>
// Missing request or response types saveEmailTemplate: (
getEmailTemplateDefinitions: () => Promise<any> template: SaveGlobalTemplateRequest
saveEmailTemplate: (templaet: any) => Promise<any> ) => Promise<SaveGlobalTemplateResponse>
} }
export const buildTemplateEndpoints = ( export const buildTemplateEndpoints = (
@ -24,10 +31,9 @@ export const buildTemplateEndpoints = (
* Gets the list of email templates. * Gets the list of email templates.
*/ */
getEmailTemplates: async () => { getEmailTemplates: async () => {
const res = await API.get<Template | Template[]>({ return await API.get({
url: "/api/global/template/email", url: "/api/global/template/email",
}) })
return Array.isArray(res) ? res : [res]
}, },
/** /**