diff --git a/docs/.env.example b/docs/.env.example index 56b26dafb5..22f6e715ff 100644 --- a/docs/.env.example +++ b/docs/.env.example @@ -3,5 +3,4 @@ UMAMI_PROJECT_API_KEY=xxxx UMAMI_APP_URL=xxxx ALGOLIA_API_KEY=xxxx ALGOLIA_APP_ID=xxxx -GITHUB_ACCESS_TOKEN=xxxx -API_KEY_BREVO=xxxx \ No newline at end of file +GITHUB_ACCESS_TOKEN=xxxx \ No newline at end of file diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 60d2cd7af2..f66feaeab2 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -119,7 +119,7 @@ const config = { }, { from: '/integrations/tensorrt', - to: '/guides/providers/tensorrt-llm' + to: '/guides/providers/tensorrt-llm', }, ], }, @@ -408,11 +408,6 @@ const config = { }, }, - // Put your custom environment here - customFields: { - apiKeyBrevo: process.env.API_KEY_BREVO, - }, - themes: ['@docusaurus/theme-live-codeblock', '@docusaurus/theme-mermaid'], } diff --git a/docs/src/containers/Footer/index.js b/docs/src/containers/Footer/index.js index fa7bf83e7c..a33caa2c8c 100644 --- a/docs/src/containers/Footer/index.js +++ b/docs/src/containers/Footer/index.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useState } from 'react' import useDocusaurusContext from '@docusaurus/useDocusaurusContext' import { AiOutlineGithub, AiOutlineTwitter } from 'react-icons/ai' @@ -130,15 +130,13 @@ export default function Footer() { siteConfig: { customFields }, } = useDocusaurusContext() + const [formMessage, setFormMessage] = useState('') + const onSubmit = (data) => { const { email } = data const options = { method: 'POST', - headers: { - 'accept': 'application/json', - 'content-type': 'application/json', - 'api-key': customFields.apiKeyBrevo, - }, + body: JSON.stringify({ updateEnabled: false, email, @@ -147,12 +145,18 @@ export default function Footer() { } if (email) { - fetch('https://api.brevo.com/v3/contacts', options) + fetch('https://brevo.jan.ai/', options) .then((response) => response.json()) .then((response) => { if (response.id) { - reset() + setFormMessage('You have successfully joined our newsletter') + } else { + setFormMessage(response.message) } + reset() + setTimeout(() => { + setFormMessage('') + }, 5000) }) .catch((err) => console.error(err)) } @@ -203,6 +207,7 @@ export default function Footer() { + {formMessage &&

{formMessage}

} diff --git a/docs/src/pages/index.js b/docs/src/pages/index.js index 7dc41ce3a2..4f0f4bd6d5 100644 --- a/docs/src/pages/index.js +++ b/docs/src/pages/index.js @@ -1,5 +1,5 @@ -import React, { useState, useEffect } from 'react' -import DownloadApp from '@site/src/containers/DownloadApp' +import React, { useState } from 'react' + import { useForm } from 'react-hook-form' import useBaseUrl from '@docusaurus/useBaseUrl' @@ -86,6 +86,7 @@ export default function Home() { const isBrowser = useIsBrowser() const { stargazers } = useAppStars() const { data } = useDiscordWidget() + const [formMessage, setFormMessage] = useState('') const userAgent = isBrowser && navigator.userAgent const isBrowserChrome = isBrowser && userAgent.includes('Chrome') @@ -104,11 +105,6 @@ export default function Home() { const { email } = data const options = { method: 'POST', - headers: { - 'accept': 'application/json', - 'content-type': 'application/json', - 'api-key': customFields.apiKeyBrevo, - }, body: JSON.stringify({ updateEnabled: false, email, @@ -117,12 +113,18 @@ export default function Home() { } if (email) { - fetch('https://api.brevo.com/v3/contacts', options) + fetch('https://brevo.jan.ai/', options) .then((response) => response.json()) .then((response) => { if (response.id) { - reset() + setFormMessage('You have successfully joined our newsletter') + } else { + setFormMessage(response.message) } + reset() + setTimeout(() => { + setFormMessage('') + }, 5000) }) .catch((err) => console.error(err)) } @@ -748,6 +750,9 @@ export default function Home() { Subscribe + {formMessage && ( +

{formMessage}

+ )}