Skip to content

Commit

Permalink
add a feature flag for payments
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaqiuxy committed Jul 5, 2020
1 parent 225949f commit 0b9385a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LINKEDIN_CLIENT_ID=
LINKEDIN_CLIENT_SCOPES="r_liteprofile r_emailaddress"
NDAIFY_ENDPOINT_URL=http://localhost:8080
NDAIFY_LOG_LEVEL=info
NDAIFY_SOLICIT_PAYMENTS=on
NODE_ENV=development
SENTRY_DSN=https://@.ingest.sentry.io/id
SENTRY_SECRET_TOKEN=
Expand Down
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = () => withSourceMaps(withCSS(withImages({
LINKEDIN_CLIENT_SCOPES: process.env.LINKEDIN_CLIENT_SCOPES,
NDAIFY_ENDPOINT_URL: process.env.NDAIFY_ENDPOINT_URL,
NDAIFY_LOG_LEVEL: process.env.NDAIFY_LOG_LEVEL,
NDAIFY_SOLICIT_PAYMENTS: process.env.NDAIFY_SOLICIT_PAYMENTS,
SENTRY_DSN: process.env.SENTRY_DSN,
STRIPE_PUBLISHABLE_KEY: process.env.STRIPE_PUBLISHABLE_KEY,
},
Expand Down
36 changes: 24 additions & 12 deletions src/components/NDA/NDAComposer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useCallback, useState } from 'react';
import styled from 'styled-components';
import getConfig from 'next/config';

import {
Formik,
Expand Down Expand Up @@ -27,6 +28,10 @@ import HideImg from './images/hide.svg';

import getFullNameFromUser from './getFullNameFromUser';

import NdaifyService from '../../services/NdaifyService';

const { publicRuntimeConfig: { NDAIFY_SOLICIT_PAYMENTS } } = getConfig();

const HideIcon = styled(HideImg)`
color: var(--ndaify-fg);
`;
Expand Down Expand Up @@ -296,36 +301,43 @@ const NDAComposer = ({ ndaTemplate, user, nda }) => {
// clear all error messages before retrying
setStatus();

const ndaifyService = new NdaifyService();

if (!expandedBody) {
setStatus({ errorMessage: 'Please expand the NDA to read all terms' });
return;
}

try {
sessionStorage.setItem(
'nda',
{
...nda,
metadata: {
...nda.metadata,
ndaParamaters: {
...values,
},
const ndaPayload = {
...nda,
metadata: {
...nda.metadata,
ndaParamaters: {
...values,
},
},
);
};

sessionStorage.setItem('nda', ndaPayload);

// Pretend like we are doing some work before moving to next step
// This is much better UX than just navigating away from the form
await timeout(1000);

Router.replace('/nda/pay').then(scrollToTop);
if (NDAIFY_SOLICIT_PAYMENTS === 'on') {
Router.replace('/nda/pay').then(scrollToTop);
} else {
const response = await ndaifyService.createNda(ndaPayload);

Router.replace('/nda/sent/[ndaId]', `/nda/sent/${response.nda.ndaId}`).then(scrollToTop);
}
} catch (error) {
loggerClient.error(error);
setStatus({ errorMessage: error.message });
}
};
const onSubmit = useCallback(handleSubmit, [expandedBody]);
const onSubmit = useCallback(handleSubmit, [expandedBody, nda]);

const handleFormValidate = (values) => {
const errors = {};
Expand Down

0 comments on commit 0b9385a

Please sign in to comment.