-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1357 from near/newsletter
Newsletter
- Loading branch information
Showing
19 changed files
with
6,617 additions
and
5,428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Button } from '@near-pagoda/ui'; | ||
import { useEffect, useState } from 'react'; | ||
import styled, { keyframes } from 'styled-components'; | ||
|
||
const fadeIn = keyframes` | ||
0% { | ||
opacity: 0; | ||
} | ||
100% { | ||
opacity: 1; | ||
} | ||
`; | ||
|
||
const ScrollToTopButton = styled(Button)<{ isVisible: boolean }>` | ||
position: fixed; | ||
bottom: 15px; | ||
right: 30px; | ||
cursor: pointer; | ||
z-index: 1000; | ||
animation: ${fadeIn} 0.5s; | ||
`; | ||
|
||
export default function ScrollToTop() { | ||
const [isVisible, setIsVisible] = useState(false); | ||
|
||
const toggleVisibility = () => { | ||
if (window.scrollY > 300) { | ||
setIsVisible(true); | ||
} else { | ||
setIsVisible(false); | ||
} | ||
}; | ||
|
||
const scrollToTop = () => { | ||
window.scrollTo({ | ||
top: 0, | ||
behavior: 'smooth', | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
window.addEventListener('scroll', toggleVisibility); | ||
}, []); | ||
|
||
return <>{isVisible && <ScrollToTopButton label="back to top" isVisible={isVisible} onClick={scrollToTop} />}</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import mailchimp from '@mailchimp/mailchimp_marketing'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
import { mailchimpApiKey, mailchimpRegion } from '../../../config'; | ||
|
||
mailchimp.setConfig({ | ||
apiKey: mailchimpApiKey, | ||
server: mailchimpRegion, | ||
}); | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
const { id } = req.query; | ||
|
||
if (!id) { | ||
res.status(400).json({ error: 'Missing id parameter' }); | ||
return; | ||
} | ||
|
||
try { | ||
const response = await mailchimp.campaigns.getContent(id.toString()); | ||
if ('html' in response) { | ||
res.status(200).json(response.html); | ||
} else { | ||
res.status(500).json({ error: 'Invalid response from Mailchimp' }); | ||
} | ||
} catch (error) { | ||
res.status(500).json({ error: 'error' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import mailchimp from '@mailchimp/mailchimp_marketing'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
import { mailchimpApiKey, mailchimpRegion } from '../../../config'; | ||
|
||
mailchimp.setConfig({ | ||
apiKey: mailchimpApiKey, | ||
server: mailchimpRegion, | ||
}); | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
try { | ||
const response = await mailchimp.campaigns.list({ | ||
fields: ['campaigns.settings.subject_line', 'campaigns.send_time', 'campaigns.id'], | ||
count: 5, | ||
status: 'sent', | ||
sortField: 'send_time', | ||
sortDir: 'DESC', | ||
}); | ||
|
||
if ('campaigns' in response) { | ||
res.status(200).json(response.campaigns); | ||
} else { | ||
res.status(500).json({ error: 'Failed to fetch campaigns' }); | ||
} | ||
} catch (error) { | ||
res.status(500).json({ error: 'error' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import mailchimp from '@mailchimp/mailchimp_marketing'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
import { mailchimpApiKey, mailchimpAudienceId, mailchimpRegion } from '../../../config'; | ||
|
||
mailchimp.setConfig({ | ||
apiKey: mailchimpApiKey, | ||
server: mailchimpRegion, | ||
}); | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
if (req.method === 'POST') { | ||
const { email } = req.body; | ||
|
||
try { | ||
const response = await mailchimp.lists.addListMember(mailchimpAudienceId, { | ||
email_address: email, | ||
status: 'pending', | ||
}); | ||
|
||
console.log(`response: ${response}`); | ||
|
||
// Respond to the client | ||
res.status(200).json({ | ||
success: true, | ||
message: 'Form submitted successfully! Please confirm your email', | ||
}); | ||
} catch (error) { | ||
console.error('Error adding to list:', error); | ||
|
||
res.status(500).json({ | ||
success: false, | ||
message: 'An error occurred while processing your request.', | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.