Skip to content

Commit

Permalink
chore(T-251): update Website Update Input Endpoint (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
vacom authored Oct 13, 2024
1 parent 52243e8 commit efdc59e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Install dependencies
run: yarn

- name: Build packages
run: yarn build:packages

- name: Lint
run: yarn lint

Expand Down
2 changes: 1 addition & 1 deletion apps/landing-page/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NEXT_PUBLIC_EMAIL_SERVICE=
NEXT_PUBLIC_UMAMI_WEBSITE_ID=
NEXT_PUBLIC_FORM_UPDATES_ENDPOINT=
33 changes: 10 additions & 23 deletions apps/landing-page/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,19 @@ const Footer = () => {
});

const onSubmit: SubmitHandler<FormInputs> = async (input: FormInputs) => {
try {
const params = new URLSearchParams({
includeListId: "4",
email: input.email,
templateId: "1", // Default Template Double opt-in confirmation
redirectionUrl: "https://basestack.co",
});
if (!process.env.NEXT_PUBLIC_FORM_UPDATES_ENDPOINT) return;

const res = await fetch(
`${
process.env.NEXT_PUBLIC_EMAIL_SERVICE
}/email/subscribe?${params.toString()}`,
{
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
try {
const res = await fetch(process.env.NEXT_PUBLIC_FORM_UPDATES_ENDPOINT, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
);

const data = await res.json();
body: JSON.stringify({ email: input.email }),
});

if (data.code === "permission_denied" || data.error) {
throw new Error(data.message);
}
await res.json();

events.landing.newsletter(
"Subscribe Success",
Expand Down

0 comments on commit efdc59e

Please sign in to comment.