This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #41 from SocialGouv/feat/newsletter
feat: newsletter
- Loading branch information
Showing
16 changed files
with
9,565 additions
and
6,556 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: app-configmap | ||
data: | ||
NODE_ENV: 'production' |
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,15 @@ | ||
apiVersion: bitnami.com/v1alpha1 | ||
kind: SealedSecret | ||
metadata: | ||
annotations: | ||
sealedsecrets.bitnami.com/cluster-wide: 'true' | ||
name: app-sealed-secret | ||
spec: | ||
encryptedData: | ||
NOTION_INTEGRATION_TOKEN: AgDG6FAYWxGNN0usFWJdBk78CACGUsikw8D5sC3AEAFxNn2abYckeZA6YZaJT/11yvHhChVWTWAGKb5Dng03WDt2sgUEM1GZHj9oBAVMQ/7ZIr/YYoBMbPWNI/BBkScTrREcdSk3geTnbLEAVWF+2Aks6tfKaLJxVh7+jEOPzwiUKOOufNEwuI7rO8Mfo+pT6Lu+0V8/x4UetNCQltvBMzjqT/Na3LUV4CiQMCzMH6yB8t9FoVQC9gNzuiQYRIqQETHV6XymMkq3UCkX/8c6Gp99OjJpi8j2bBAc8ydwkKn4Xp1F5PjR/OF3i/gokPhlQWI3jeVaYe7X2UNvWx2Sxkg3NcqUDN9kbBBEKkftodTHwUSFal7odzpj+wmUgHzNu3bpzFyP/Yen6qkH3iNYFGTmfu7Fsc2PtWTyAKcoI1LUP02unlkL/MjcZvlTRZYX78q3cBVuQQpr4R2UEvq9kehVuRHZjTcaZUiAVwV+cWuUaEzawSZodujt3Ghn0xwM+WLiUrxpo0xQozLT0ZKOsyVzO4aLoRTs0e5yPz0w1R3IZ8NonYMGkAepeeGN1r9EbQFc2szOqLGIXAzfI1QjOQ1ANC49mbqt/rRXr3zVsWhST4qBQgQv3kZKOzRLjWOxH8wCazlzGceGOgJxj3mpJSvaf6kyKyYEBEwON46IXjPJPC/WGv8vrxySARRmMGX54ilBSO8IL9hOdVEDCxVYboQkXcZOdxQoJ5q0imc+XhR6xQghSsJ+etsYS7ctDa5NK5R7Dg== | ||
template: | ||
metadata: | ||
annotations: | ||
sealedsecrets.bitnami.com/cluster-wide: 'true' | ||
name: app-sealed-secret | ||
type: Opaque |
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,6 @@ | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: app-configmap | ||
data: | ||
NODE_ENV: 'production' |
14 changes: 14 additions & 0 deletions
14
.kube-workflow/env/preprod/templates/app.sealed-secret.yaml
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,14 @@ | ||
apiVersion: bitnami.com/v1alpha1 | ||
kind: SealedSecret | ||
metadata: | ||
annotations: {} | ||
name: app-sealed-secret | ||
namespace: ressourcerie | ||
spec: | ||
encryptedData: | ||
NOTION_INTEGRATION_TOKEN: AgCq5fKtAlGYdIk3JRBmfm/basmo3rJralCTbxSBAtSn9tmDbGS3m16qiZhDr5QEdZLj2Sp+8bYc/dLoQuf3Oe6dGnTFSdgKYLH++5BWlg3WnQuToq2csOS96uRSWv7PQfSgy1pVYs1OjRIn08Vv9SWX/BCVajlss1+M/jXAuHpTXdppN5/EXrgc8H4/VvlzfWSryrKFL1xAr5PpeMBZACNZqTLKRU/oPOQuci4/bIKXUsfEd9iPgmMg0Bf0kc4CmSkdpmA0+bgOHyxEoYJyryKc5M20CyyKlhF0MrW9c8uwIwtjlzjsxo/EstJLz5UalvrW/KE5EOHK283a3pbsPscmTeJHL3466CVfaqlKOruAPtgr0ABrPNrYFOnWAZ51Fvt/uaMh2/FQcd+1bsrQspocMBRJGtoBzsndouGfe1jd4v4Som/DiV9fOeiCtJR3m3zJT4w7MojGNx2zEwcOQVx8kFJAAQ5gZ5nY8JOxj+py6kDpHjHL0lY9gHXmNprXBq30yhksfPnGngQAhxqPAkeE+eJWJSNbzzY3Tex742FwuAmzEbq9lJHK2m0ayxA/aUvXjPK9rnaOp7fuxl3VRVc/Vte8Nhmb6X7aJkg6/YqZ0PX5i8eTwGkrSiwVa+bYCf0WuSMCYFF+S9zOIrv6ZWYMe+MfeXjqKgE9EK0AFoPsB4uJF3zWBXP4101/F8oidUZxZ28I6jtOsoQ0jKtCLGKMN3dG2TB22c9Lrrvp/QiLieXB2loprq7wkOvEnbXp1+wcTw== | ||
template: | ||
metadata: | ||
annotations: {} | ||
name: app-sealed-secret | ||
type: Opaque |
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,6 @@ | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: app-configmap | ||
data: | ||
NODE_ENV: 'production' |
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,14 @@ | ||
apiVersion: bitnami.com/v1alpha1 | ||
kind: SealedSecret | ||
metadata: | ||
annotations: {} | ||
name: app-sealed-secret | ||
namespace: ressourcerie | ||
spec: | ||
encryptedData: | ||
NOTION_INTEGRATION_TOKEN: AgCq5fKtAlGYdIk3JRBmfm/basmo3rJralCTbxSBAtSn9tmDbGS3m16qiZhDr5QEdZLj2Sp+8bYc/dLoQuf3Oe6dGnTFSdgKYLH++5BWlg3WnQuToq2csOS96uRSWv7PQfSgy1pVYs1OjRIn08Vv9SWX/BCVajlss1+M/jXAuHpTXdppN5/EXrgc8H4/VvlzfWSryrKFL1xAr5PpeMBZACNZqTLKRU/oPOQuci4/bIKXUsfEd9iPgmMg0Bf0kc4CmSkdpmA0+bgOHyxEoYJyryKc5M20CyyKlhF0MrW9c8uwIwtjlzjsxo/EstJLz5UalvrW/KE5EOHK283a3pbsPscmTeJHL3466CVfaqlKOruAPtgr0ABrPNrYFOnWAZ51Fvt/uaMh2/FQcd+1bsrQspocMBRJGtoBzsndouGfe1jd4v4Som/DiV9fOeiCtJR3m3zJT4w7MojGNx2zEwcOQVx8kFJAAQ5gZ5nY8JOxj+py6kDpHjHL0lY9gHXmNprXBq30yhksfPnGngQAhxqPAkeE+eJWJSNbzzY3Tex742FwuAmzEbq9lJHK2m0ayxA/aUvXjPK9rnaOp7fuxl3VRVc/Vte8Nhmb6X7aJkg6/YqZ0PX5i8eTwGkrSiwVa+bYCf0WuSMCYFF+S9zOIrv6ZWYMe+MfeXjqKgE9EK0AFoPsB4uJF3zWBXP4101/F8oidUZxZ28I6jtOsoQ0jKtCLGKMN3dG2TB22c9Lrrvp/QiLieXB2loprq7wkOvEnbXp1+wcTw== | ||
template: | ||
metadata: | ||
annotations: {} | ||
name: app-sealed-secret | ||
type: Opaque |
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,67 @@ | ||
import React, { useState } from 'react'; | ||
import { ButtonLink } from '../../uiComponents'; | ||
|
||
const NewsLetterSection = () => { | ||
const [isSent, setIsSent] = useState(false); | ||
const [email, setEmail] = useState(''); | ||
const [message, setMessage] = useState('') | ||
|
||
const handleForm = (e: React.FormEvent<HTMLInputElement>): void => { | ||
setEmail(e.currentTarget.value); | ||
}; | ||
|
||
const validateEmail = (email: string): Boolean => { | ||
return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) | ||
} | ||
|
||
const addMailNotion = async (email: string) => { | ||
const response = await fetch(`/api/notion?email=${email}`) | ||
return response.ok | ||
} | ||
|
||
return ( | ||
<section id="newsletter-section"> | ||
<div className="fr-container"> | ||
<h2>Newsletter</h2> | ||
<div className="grid-newsletter"> | ||
<div className="text-nl"> | ||
<p> | ||
La newsletter de la Ressourcerie est orientée sur une thématique mensuelle et présente des cas d'usages et articles de vulgarisation sélectionnés parmi nos productions, | ||
une ressource technique en lien avec les productions sélectionnées, et notre veille sur les initiatives tech' de la sphère travail (pour élargir le spectre) ! | ||
</p> | ||
</div> | ||
<div className="cta-nl"> | ||
<div> | ||
<div className="div-input"> | ||
<input | ||
className="fr-input" | ||
type="text" | ||
id="newsletter-input" | ||
name="newsletter-input" | ||
onChange={handleForm} | ||
/> | ||
</div> | ||
{isSent ? <div>{message}</div> : <br />} | ||
<br /> | ||
<ButtonLink onClick={ | ||
() => { | ||
setIsSent(true) | ||
setMessage(validateEmail(email) ? 'Merci pour votre inscription!' : 'Cette adresse mail semble invalide') | ||
if(validateEmail(email)) { | ||
addMailNotion(email) | ||
} | ||
} | ||
} size="large" alt> | ||
<span className="layout-center"> | ||
Je m'inscris à la newsletter! | ||
</span> | ||
</ButtonLink> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<br /> | ||
</section> | ||
); | ||
}; | ||
export default NewsLetterSection; |
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,38 @@ | ||
#newsletter-section { | ||
|
||
padding: 50px 0; | ||
|
||
h2, | ||
h3 { | ||
text-align: center; | ||
} | ||
|
||
.grid-newsletter { | ||
margin-top: 2rem; | ||
display: grid; | ||
grid-template-columns: 50% 50%; | ||
|
||
.text-nl { | ||
padding-right:2rem; | ||
} | ||
|
||
.cta-nl { | ||
padding: 1rem; | ||
text-align: center; | ||
|
||
.div-input { | ||
max-width:350px; | ||
margin: 0 auto; | ||
} | ||
} | ||
|
||
} | ||
|
||
@media only screen and (min-width: 1px) and (max-width: 900px) { | ||
.grid-newsletter { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
} | ||
|
||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,61 @@ | ||
import type { NextApiHandler } from "next"; | ||
import { Client } from '@notionhq/client'; | ||
|
||
const handler: NextApiHandler = async (req, res) => { | ||
|
||
if (req.method == "GET") { | ||
await post(req, res); | ||
} else { | ||
res.status(405).end(); | ||
return; | ||
} | ||
}; | ||
|
||
const post: NextApiHandler = async (req, res) => { | ||
const email = req.query.email as string | ||
|
||
const notion = new Client({ auth: process.env.NOTION_INTEGRATION_TOKEN }); | ||
|
||
(async () => { | ||
const response = await notion.pages.create({ | ||
parent: { | ||
database_id: "e4e03e2676c54de09cc3fb46a56c90df", | ||
}, | ||
icon: { | ||
type: "emoji", | ||
emoji: "🥬" | ||
}, | ||
cover: { | ||
type: "external", | ||
external: { | ||
url: "https://upload.wikimedia.org/wikipedia/commons/6/62/Tuscankale.jpg" | ||
} | ||
}, | ||
properties: { | ||
Name: { | ||
title: [ | ||
{ | ||
text: { | ||
content: email, | ||
}, | ||
}, | ||
], | ||
}, | ||
email: { | ||
rich_text: [ | ||
{ | ||
text: { | ||
content: email, | ||
}, | ||
}, | ||
], | ||
} | ||
} | ||
}); | ||
console.log(response); | ||
})(); | ||
|
||
res.status(200).json({ message: "Commentaire ajouté" }); | ||
}; | ||
|
||
export default handler; |
Oops, something went wrong.