fix: apikey brevo newsletter (#2430)

* fix: temprary-newsletter

* fix apikey brevo
This commit is contained in:
Faisal Amir 2024-03-20 00:05:23 +07:00 committed by GitHub
parent d33caba311
commit 16bd263fa6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 25 deletions

View File

@ -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
GITHUB_ACCESS_TOKEN=xxxx

View File

@ -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'],
}

View File

@ -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() {
</svg>
</button>
</form>
{formMessage && <p className="text-left mt-4">{formMessage}</p>}
</div>
</div>
</div>

View File

@ -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
</button>
</form>
{formMessage && (
<p className="text-left mt-4">{formMessage}</p>
)}
</div>
</div>
</div>