-
Notifications
You must be signed in to change notification settings - Fork 12
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
Embedded contribution form #325
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3e692e4
style(Contribute): add form elements
newick ce8cb82
feat(contribution): setup sendinblue for contribution forward
JalilArfaoui 2091ba0
feat(form): add redux-form
lutangar ee2a8ea
feat(form): add Fields adapter
lutangar e188cb5
feat(submit-notice): implement submit notice screen and success redir…
lutangar aecbf0a
fix(sendinblue): handle all 2xx codes
lutangar 835646e
chore(forms): refactor with new conventions
lutangar c152a04
fix(stories): fix AddNoticeLink story
lutangar a7d2426
feat(contribution-form): show form errors when a field is touched and…
lutangar 2501aa7
feat(contribution-form): find global error manually depending on each…
lutangar 69de70e
chore(contribution-form): remove unused prop
lutangar 9edb128
chore(contribution-form): move form related side effects to condition
lutangar 6a93b21
chore(contribution-form): fix requiredPaths typing
lutangar b06a690
chore(form): rename `Errors` model to `ValidationErrors`
lutangar 710e252
chore(contribution-form): add space between preview buttons
lutangar 45352cb
fix(contribution): show contributor name on preview screen
lutangar b5e4d31
fix(contribution): fix global error not showing up anymore on the pre…
lutangar 4a17a7e
chore(contribution): update lockfile after rebase
lutangar b95b018
style(contribution): fix typing issue
JalilArfaoui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,4 @@ | ||
SEND_CONTRIBUTION_TO=contact@lmem.net | ||
SEND_CONTRIBUTION_FROM=contact@lmem.net | ||
SEND_IN_BLUE_TOKEN=token | ||
SENTRY_DSN=https://ID@sentry.io/PROJECT |
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 |
---|---|---|
|
@@ -15,3 +15,4 @@ platforms/ | |
.ftppass | ||
storybook-static/* | ||
.sentryclirc | ||
.env |
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,8 @@ | ||
import { combineReducers, createStore } from 'redux'; | ||
import { reducer as form } from 'redux-form'; | ||
|
||
export default createStore( | ||
combineReducers({ | ||
form | ||
}) | ||
); |
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,25 @@ | ||
import fetch from 'isomorphic-fetch'; | ||
|
||
type Method = 'GET' | 'POST'; | ||
|
||
const call = (path: string, data?: {} | [], method: Method = 'GET') => | ||
fetch(`https://api.sendinblue.com/v3/${path}`, { | ||
method, | ||
body: JSON.stringify(data), | ||
headers: { | ||
'api-key': process.env.SEND_IN_BLUE_TOKEN as string, | ||
'Content-Type': 'application/json' | ||
} | ||
}).then(response => { | ||
if (response.status >= 400) { | ||
throw new Error('Bad response from server'); | ||
} | ||
if (response.status >= 200 && response.status < 300) { | ||
return true; | ||
} | ||
return response.json(); | ||
}); | ||
|
||
export const get = (path: string) => call(path); | ||
|
||
export const post = (path: string, data: {} | []) => call(path, data, 'POST'); |
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 @@ | ||
import { post } from './call'; | ||
import { TransactionEmail } from 'SendInBlue'; | ||
|
||
const sendEmail = (email: TransactionEmail) => post('smtp/email', email); | ||
|
||
export default sendEmail; |
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,34 @@ | ||
declare module 'SendInBlue' { | ||
export interface PersonEmail { | ||
name?: string; | ||
email: string; | ||
} | ||
export interface Sender extends PersonEmail {} | ||
export interface Recipient extends PersonEmail {} | ||
|
||
export interface UrlAttachment { | ||
name?: string; | ||
url: string; | ||
} | ||
export interface Base64Attachment { | ||
name: string; | ||
content: string; | ||
} | ||
export type Attachment = UrlAttachment | Base64Attachment; | ||
|
||
export interface TransactionEmail { | ||
sender?: Sender; // Mandatory if 'templateId' is not passed. Pass name (optional) and email of sender from which emails will be sent. For example, {'name':'Mary from MyShop', 'email':'no-reply@myshop.com'} | ||
to: Recipient[]; // List of email addresses and names (optional) of the recipients. For example, [{'name':'Jimmy', 'email':'jimmy98@example.com'}, {'name':'Joe', 'email':'joe@example.com'}] | ||
bcc?: Recipient[]; // List of email addresses and names (optional) of the recipients in bcc | ||
cc?: Recipient[]; // List of email addresses and names (optional) of the recipients in cc | ||
htmlContent?: string; // HTML body of the message ( Mandatory if 'templateId' is not passed, ignored if 'templateId' is passed ) | ||
textContent?: string; // Plain Text body of the message ( Ignored if 'templateId' is passed ) | ||
subject?: string; // Subject of the message. Mandatory if 'templateId' is not passed | ||
replyTo?: Sender; // Email (required), along with name (optional), on which transactional mail recipients will be able to reply back. For example, {'email':'ann6533@example.com', 'name':'Ann'}. | ||
attachment?: Attachment[]; // Pass the absolute URL (no local file) or the base64 content of the attachment along with the attachment name (Mandatory if attachment content is passed). For example, [{"url":"https://attachment.domain.com/myAttachmentFromUrl.jpg", "name":"My attachment 1"}, {"content":"base64 exmaple content", "name":"My attachment 2"}]. Allowed extensions for attachment file: xlsx, xls, ods, docx, docm, doc, csv, pdf, txt, gif, jpg, jpeg, png, tif, tiff, rtf, bmp, cgm, css, shtml, html, htm, zip, xml, ppt, pptx, tar, ez, ics, mobi, msg, pub, eps, odt, mp3, m4a, m4v, wma, ogg, flac, wav, aif, aifc, aiff, mp4, mov, avi, mkv, mpeg, mpg and wmv ( If 'templateId' is passed and is in New Template Language format then only attachment url is accepted. If template is in Old template Language format, then 'attachment' is ignored ) | ||
headers?: { [key: string]: string }; // Pass the set of headers that shall be sent along the mail headers in the original email. 'sender.ip' header can be set (only for dedicated ip users) to mention the IP to be used for sending transactional emails. For example, {'Content-Type':'text/html', 'charset':'iso-8859-1', 'sender.ip':'1.2.3.4'} | ||
templateId?: number; // int64 Id of the template | ||
params?: {}; // Pass the set of attributes to customize the template. For example, {'FNAME':'Joe', 'LNAME':'Doe'}. It's considered only if template is in New Template Language format. | ||
tags?: string[]; // Tag your emails to find them more ea | ||
} | ||
} |
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,44 @@ | ||
import { Contribution } from 'app/lmem/notice'; | ||
import { BaseAction, FormAction, FormMeta, ErrorAction } from '.'; | ||
|
||
export interface SubmitContributionAction extends FormAction { | ||
type: 'CONTRIBUTION/SUBMIT'; | ||
payload: Contribution; | ||
} | ||
export const submitContribution = ( | ||
notice: Contribution, | ||
meta: FormMeta | ||
): SubmitContributionAction => ({ | ||
type: 'CONTRIBUTION/SUBMIT', | ||
payload: notice, | ||
meta | ||
}); | ||
|
||
export interface ContributionSubmittedAction extends BaseAction { | ||
type: 'CONTRIBUTION/SUBMITTED'; | ||
payload: Contribution; | ||
} | ||
export const contributionSubmitted = ( | ||
contribution: Contribution | ||
): ContributionSubmittedAction => ({ | ||
type: 'CONTRIBUTION/SUBMITTED', | ||
payload: contribution | ||
}); | ||
|
||
export interface ContributionSubmissionFailed extends ErrorAction { | ||
type: 'CONTRIBUTION/SUBMISSION_FAILED'; | ||
} | ||
export const contributionSubmissionFailed = ( | ||
e: Error | ||
): ContributionSubmissionFailed => ({ | ||
type: 'CONTRIBUTION/SUBMISSION_FAILED', | ||
payload: e, | ||
error: true | ||
}); | ||
|
||
export interface ContributionSubmissionCanceled extends BaseAction { | ||
type: 'CONTRIBUTION/SUBMISSION_CANCELED'; | ||
} | ||
export const contributionSubmissionCanceled = (): ContributionSubmissionCanceled => ({ | ||
type: 'CONTRIBUTION/SUBMISSION_CANCELED' | ||
}); |
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
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
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,25 @@ | ||
import { Contribution } from 'app/lmem/notice'; | ||
import { | ||
formatContributionHtmlEmail, | ||
formatContributionTextEmail | ||
} from 'app/lmem/format/contribution'; | ||
import { truncateWords } from '../../utils/truncate'; | ||
import { TransactionEmail } from 'SendInBlue'; | ||
|
||
const { SEND_CONTRIBUTION_FROM, SEND_CONTRIBUTION_TO } = process.env as AppEnv; | ||
|
||
const createContributionEmail = ( | ||
contribution: Contribution | ||
): TransactionEmail => ({ | ||
sender: { email: SEND_CONTRIBUTION_FROM }, | ||
to: [{ email: SEND_CONTRIBUTION_TO }], | ||
replyTo: contribution.contributor, | ||
subject: `${contribution.contributor.name}: ${truncateWords( | ||
8, | ||
contribution.message | ||
)} !`, | ||
htmlContent: formatContributionHtmlEmail(contribution), | ||
textContent: formatContributionTextEmail(contribution) | ||
}); | ||
|
||
export default createContributionEmail; |
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
13 changes: 13 additions & 0 deletions
13
src/app/content/App/Contribute/ContributeScreen/ContributeScreen.stories.tsx
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,13 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { MemoryRouter as Router } from 'react-router-dom'; | ||
import Notification from 'components/organisms/Notification'; | ||
import ContributeScreen from './ContributeScreen'; | ||
|
||
storiesOf('screens/Contribute/Submit', module) | ||
.addDecorator(getStory => ( | ||
<Router> | ||
<Notification title="créer une bulle ici">{getStory()}</Notification> | ||
</Router> | ||
)) | ||
.add('normal', () => <ContributeScreen />); |
12 changes: 12 additions & 0 deletions
12
src/app/content/App/Contribute/ContributeScreen/ContributeScreen.tsx
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,12 @@ | ||
import React from 'react'; | ||
|
||
import { ContentWrapper } from 'components/atoms'; | ||
import SubmitContributionForm from './SubmitContributionForm'; | ||
|
||
export const ContributeScreen = () => ( | ||
<ContentWrapper> | ||
<SubmitContributionForm /> | ||
</ContentWrapper> | ||
); | ||
|
||
export default ContributeScreen; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WTF I just had this problem in another branch when attempting to push.... isn't that supposed to be in develop?