From 339c6957fe92c4ec1809159f09c55201d3794c18 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 6 May 2022 18:21:16 +0200 Subject: chore: add a Contact page --- src/services/graphql/contact.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/services/graphql/contact.ts (limited to 'src/services/graphql/contact.ts') diff --git a/src/services/graphql/contact.ts b/src/services/graphql/contact.ts new file mode 100644 index 0000000..fca718f --- /dev/null +++ b/src/services/graphql/contact.ts @@ -0,0 +1,26 @@ +import { fetchAPI, getAPIUrl, sendMailVars } from './api'; +import { sendMailMutation } from './contact.mutation'; + +export type SentEmail = { + clientMutationId: string; + message: string; + origin: string; + replyTo: string; + sent: boolean; +}; + +/** + * Send an email using GraphQL API. + * + * @param {sendMailVars} data - The mail data. + * @returns {Promise} The mutation response. + */ +export const sendMail = async (data: sendMailVars): Promise => { + const response = await fetchAPI({ + api: getAPIUrl(), + query: sendMailMutation, + variables: { ...data }, + }); + + return response.sendEmail; +}; -- cgit v1.2.3