Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hot-fix: apikey brevo newsletter (#2430) #2431

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 1 addition & 6 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const config = {
},
{
from: '/integrations/tensorrt',
to: '/guides/providers/tensorrt-llm'
to: '/guides/providers/tensorrt-llm',
},
],
},
Expand Down Expand Up @@ -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'],
}

Expand Down
21 changes: 13 additions & 8 deletions docs/src/containers/Footer/index.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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,
Expand All @@ -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))
}
Expand Down Expand Up @@ -203,6 +207,7 @@ export default function Footer() {
</svg>
</button>
</form>
{formMessage && <p className="text-left mt-4">{formMessage}</p>}
</div>
</div>
</div>
Expand Down
23 changes: 14 additions & 9 deletions docs/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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')
Expand All @@ -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,
Expand All @@ -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))
}
Expand Down Expand Up @@ -748,6 +750,9 @@ export default function Home() {
Subscribe
</button>
</form>
{formMessage && (
<p className="text-left mt-4">{formMessage}</p>
)}
</div>
</div>
</div>
Expand Down
Loading