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

feat(certification): Optionally email certifier #628

Merged
merged 4 commits into from
May 11, 2020
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
70 changes: 39 additions & 31 deletions app/containers/Applications/ApplicationWizardConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ interface Target extends EventTarget {
email: {
value: string;
};
sendEmailChecked: {
checked: boolean;
};
}

export const ApplicationWizardConfirmationComponent: React.FunctionComponent<Props> = (
Expand All @@ -45,6 +48,7 @@ export const ApplicationWizardConfirmationComponent: React.FunctionComponent<Pro
e.preventDefault();
e.persist();
const email = (e.target as Target).email.value;
const sendEmail = (e.target as Target).sendEmailChecked.checked;
const {environment} = props.relay;
const variables = {
input: {
Expand Down Expand Up @@ -80,7 +84,8 @@ export const ApplicationWizardConfirmationComponent: React.FunctionComponent<Pro
}/certifier/certification-redirect?rowId=${encodeURIComponent(
response.createCertificationUrl.certificationUrl.rowId
)}&id=${encodeURIComponent(props.application.id)}`,
certificationRequestSentTo: email
certifierEmail: email,
sendCertificationRequest: sendEmail
}
}
};
Expand All @@ -97,27 +102,38 @@ export const ApplicationWizardConfirmationComponent: React.FunctionComponent<Pro
const generateCertification = (
<>
<br />
<Form onSubmit={handleClickGenerateCertificationUrl}>
<Form.Row>
<Col md={6}>
<Form.Group controlId="certifierEmail">
<Form.Control
name="email"
type="email"
placeholder="Enter email"
<Card>
<Card.Header>Application Certification</Card.Header>
<Card.Body>
<Card.Text>
Once you have reviewed the application and ensured all the data is
correct, the application has to be certified.
</Card.Text>
<Form onSubmit={handleClickGenerateCertificationUrl}>
<Form.Row>
<Form.Group as={Col} md="4" controlId="certifierEmail">
<Form.Control
name="email"
type="email"
placeholder="Certifier Email"
/>
</Form.Group>
</Form.Row>
<Form.Group>
<Form.Check
className="text-muted"
name="sendEmailChecked"
type="checkbox"
label="Notify certifier via email that this application is ready for certification"
/>
<Form.Text className="text-muted">
Send URL to certifier
</Form.Text>
</Form.Group>
</Col>
<Col md={2}>
<Button variant="primary" type="submit">
Send to Certifier
<Button variant="info" type="submit">
Submit for Certification
</Button>
</Col>
</Form.Row>
</Form>
</Form>
</Card.Body>
<Card.Footer />
</Card>
</>
);

Expand All @@ -141,20 +157,12 @@ export const ApplicationWizardConfirmationComponent: React.FunctionComponent<Pro
);

if (!revision.certificationUrl) {
certificationMessage = (
certificationMessage = url ? (
<>
<h5>
Thank you for reviewing the application information. You may now send
a generated Certification url to be signed prior to submission.
</h5>
{url ? (
<>
<span style={{color: 'green'}}>{copySuccess}</span> {copyUrl}
</>
) : (
generateCertification
)}
<span style={{color: 'green'}}>{copySuccess}</span> {copyUrl}
</>
) : (
generateCertification
);
} else if (
!revision.certificationUrl.certificationSignature &&
Expand Down
6 changes: 4 additions & 2 deletions app/cypress/integration/email.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ if (Cypress.env('NO_MAIL')) {
);
cy.url().should('include', '/reporter/ciip-application');
cy.get('#certifierEmail').clear().type('certifier@certi.fy');
cy.get('.btn').contains('Send to Certifier').click();
cy.get('.form-check-input').click();
cy.get('.btn').contains('Submit for Certification').click();
cy.wait(1000);
cy.request('localhost:8025/api/v1/messages').then((response) => {
// eslint-disable-next-line jest/valid-expect
Expand Down Expand Up @@ -84,7 +85,8 @@ if (Cypress.env('NO_MAIL')) {
);
cy.url().should('include', '/reporter/ciip-application');
cy.get('#certifierEmail').clear().type('certifier@certi.fy');
cy.get('.btn').contains('Send to Certifier').click();
cy.get('.form-check-input').click();
cy.get('.btn').contains('Submit for Certification').click();
cy.wait(500);
cy.request('DELETE', 'localhost:8025/api/v1/messages');
cy.get('input')
Expand Down
2 changes: 1 addition & 1 deletion app/cypress/integration/reporter-access-all-pages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('When logged in as a reporter', () => {
`/reporter/ciip-application?applicationId=${applicationId}&confirmationPage=true&version=1`
);
cy.url().should('include', '/reporter/ciip-application');
cy.get('.btn').contains('Send to Certifier').click();
cy.get('.btn').contains('Submit for Certification').click();
cy.wait(500); // Wait for half second (otherwise cypress gets the input before the value has been set)
cy.get('input').invoke('val').should('contain', 'localhost');
cy.get('input')
Expand Down
52 changes: 36 additions & 16 deletions app/server/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1249,9 +1249,6 @@ type CertificationUrl implements Node {
"""The time at which the certification request was sent"""
certificationRequestSentAt: Datetime

"""The email that the certification request was sent to"""
certificationRequestSentTo: String

"""The base64 representation of the certifier's signature"""
certificationSignature: String

Expand All @@ -1261,6 +1258,9 @@ type CertificationUrl implements Node {
"""The user id of the certifier references ggircs_portal.ciip_user"""
certifiedBy: Int

"""The email that the certification request was sent to"""
certifierEmail: String

"""The URL sent to the certifier"""
certifierUrl: String

Expand Down Expand Up @@ -1313,6 +1313,11 @@ type CertificationUrl implements Node {
"""Unique ID for the certification_url"""
rowId: String!

"""
User defined boolean indicates whether to send an email to the certifier
"""
sendCertificationRequest: Boolean!

"""Last update date of row"""
updatedAt: Datetime!

Expand All @@ -1338,11 +1343,6 @@ input CertificationUrlCondition {
"""
certificationRequestSentAt: Datetime

"""
Checks for equality with the object’s `certificationRequestSentTo` field.
"""
certificationRequestSentTo: String

"""Checks for equality with the object’s `certificationSignature` field."""
certificationSignature: String

Expand All @@ -1352,6 +1352,9 @@ input CertificationUrlCondition {
"""Checks for equality with the object’s `certifiedBy` field."""
certifiedBy: Int

"""Checks for equality with the object’s `certifierEmail` field."""
certifierEmail: String

"""Checks for equality with the object’s `certifierUrl` field."""
certifierUrl: String

Expand Down Expand Up @@ -1381,6 +1384,11 @@ input CertificationUrlCondition {
"""Checks for equality with the object’s `rowId` field."""
rowId: String

"""
Checks for equality with the object’s `sendCertificationRequest` field.
"""
sendCertificationRequest: Boolean

"""Checks for equality with the object’s `updatedAt` field."""
updatedAt: Datetime

Expand All @@ -1399,9 +1407,6 @@ input CertificationUrlInput {
"""The time at which the certification request was sent"""
certificationRequestSentAt: Datetime

"""The email that the certification request was sent to"""
certificationRequestSentTo: String

"""The base64 representation of the certifier's signature"""
certificationSignature: String

Expand All @@ -1411,6 +1416,9 @@ input CertificationUrlInput {
"""The user id of the certifier references ggircs_portal.ciip_user"""
certifiedBy: Int

"""The email that the certification request was sent to"""
certifierEmail: String

"""The URL sent to the certifier"""
certifierUrl: String

Expand Down Expand Up @@ -1440,6 +1448,11 @@ input CertificationUrlInput {
"""Unique ID for the certification_url"""
rowId: String!

"""
User defined boolean indicates whether to send an email to the certifier
"""
sendCertificationRequest: Boolean

"""Last update date of row"""
updatedAt: Datetime

Expand All @@ -1462,9 +1475,6 @@ input CertificationUrlPatch {
"""The time at which the certification request was sent"""
certificationRequestSentAt: Datetime

"""The email that the certification request was sent to"""
certificationRequestSentTo: String

"""The base64 representation of the certifier's signature"""
certificationSignature: String

Expand All @@ -1474,6 +1484,9 @@ input CertificationUrlPatch {
"""The user id of the certifier references ggircs_portal.ciip_user"""
certifiedBy: Int

"""The email that the certification request was sent to"""
certifierEmail: String

"""The URL sent to the certifier"""
certifierUrl: String

Expand Down Expand Up @@ -1503,6 +1516,11 @@ input CertificationUrlPatch {
"""Unique ID for the certification_url"""
rowId: String

"""
User defined boolean indicates whether to send an email to the certifier
"""
sendCertificationRequest: Boolean

"""Last update date of row"""
updatedAt: Datetime

Expand Down Expand Up @@ -1549,14 +1567,14 @@ enum CertificationUrlsOrderBy {
APPLICATION_ID_DESC
CERTIFICATION_REQUEST_SENT_AT_ASC
CERTIFICATION_REQUEST_SENT_AT_DESC
CERTIFICATION_REQUEST_SENT_TO_ASC
CERTIFICATION_REQUEST_SENT_TO_DESC
CERTIFICATION_SIGNATURE_ASC
CERTIFICATION_SIGNATURE_DESC
CERTIFIED_AT_ASC
CERTIFIED_AT_DESC
CERTIFIED_BY_ASC
CERTIFIED_BY_DESC
CERTIFIER_EMAIL_ASC
CERTIFIER_EMAIL_DESC
CERTIFIER_URL_ASC
CERTIFIER_URL_DESC
CREATED_AT_ASC
Expand All @@ -1578,6 +1596,8 @@ enum CertificationUrlsOrderBy {
PRIMARY_KEY_DESC
RECERTIFICATION_REQUEST_SENT_ASC
RECERTIFICATION_REQUEST_SENT_DESC
SEND_CERTIFICATION_REQUEST_ASC
SEND_CERTIFICATION_REQUEST_DESC
UPDATED_AT_ASC
UPDATED_AT_DESC
UPDATED_BY_ASC
Expand Down
Loading