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

add subscription call on contact us page if user chose appropriate ch… #570

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 4 additions & 6 deletions src/components/SubscriptionForm/SubscriptionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createBemBlockBuilder, EMAIL_VALIDATION_REGEX } from '@app/utils';

import { EnvelopeIcon } from './icons';
import { SubscriptionFormCard } from './SubscriptionFormCard';
import { SUBSCRIPTION_URL } from './constants';

import './SubscriptionForm.scss';

Expand All @@ -32,12 +33,9 @@ export const SubscriptionForm: FC = () => {

const subscribeUser = (emailToSubscribe: string) => {
axios
.post(
`https://status.reportportal.io/mailchimp/lists/${process.env.GATSBY_MAILCHIMP_LIST_ID}/members`,
{
email_address: emailToSubscribe,
},
)
.post(SUBSCRIPTION_URL, {
email_address: emailToSubscribe,
})
.then(response => {
setValidation({
isValid: true,
Expand Down
1 change: 1 addition & 0 deletions src/components/SubscriptionForm/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SUBSCRIPTION_URL = `https://status.reportportal.io/mailchimp/lists/${process.env.GATSBY_MAILCHIMP_LIST_ID}/members`;
11 changes: 11 additions & 0 deletions src/containers/ContactUsPage/ContactUsForm/ContactUsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FormikProvider, useFormik } from 'formik';
import { useBoolean } from 'ahooks';
import isEmpty from 'lodash/isEmpty';
import { Link } from '@app/components/Link';
import { SUBSCRIPTION_URL } from '@app/components/SubscriptionForm/constants';
import { createBemBlockBuilder } from '@app/utils';

import { validate, getBaseSalesForceValues } from './utils';
Expand Down Expand Up @@ -44,6 +45,16 @@ export const ContactUsForm = ({ title, options, isDiscussFieldShown }) => {
...baseSalesForceValues,
};

if (values.wouldLikeToReceiveAds) {
fetch(SUBSCRIPTION_URL as string, {
ViktorSoroka07 marked this conversation as resolved.
Show resolved Hide resolved
method: 'POST',
body: JSON.stringify({ email_address: values.email }),
headers: {
'Content-Type': 'application/json',
},
});
}

fetch(process.env.CONTACT_US_URL as string, {
method: 'POST',
body: JSON.stringify(postData),
Expand Down