Skip to content

Commit 27aa86e

Browse files
committed
Fix newsletter signup form actions and source metadata
1 parent f4cce41 commit 27aa86e

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

src/app/(thank-you-pages)/app-purchase-thank-you/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ export default function AppPurchaseThankYouPage() {
5959
<ContentCard
6060
title="Join the mailing list now, so you don't miss new features & releases"
6161
text="There's a lot of new HTTP Toolkit features coming soon, like full scripting support, gRPC & GraphQL integration, and request diffing tools. Keep yourself up to date:"
62-
$isNewsletter
63-
action={NEWSLETTER_URLS.download}
62+
newsletter={{ action: NEWSLETTER_URLS.default, source: 'app-purchase-thank-you' }}
6463
/>
6564
</Stack>
6665
</StyledTextContent>

src/app/(thank-you-pages)/web-purchase-thank-you/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ export default function WebPurchaseThankYouPage() {
6767
<ContentCard
6868
title="Join the mailing list now, so you don't miss new features & releases"
6969
text="There's a lot of new HTTP Toolkit features coming soon, like full scripting support, gRPC & GraphQL integration, and request diffing tools. Keep yourself up to date:"
70-
$isNewsletter
71-
action={NEWSLETTER_URLS.download}
70+
newsletter={{ action: NEWSLETTER_URLS.default, source: 'web-purchase-thank-you' }}
7271
/>
7372
</Stack>
7473
</StyledTextContent>

src/app/download/[slug]/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ export default async function DownloadPage({ params }: DownloadPageProps) {
104104
<ContentCard
105105
title="Join the mailing list now, so you don't miss new features & releases"
106106
text="There's a lot of new HTTP Toolkit features coming soon, like full scripting support, gRPC & GraphQL integration, and request diffing tools. Keep yourself up to date:"
107-
$isNewsletter
108-
action={NEWSLETTER_URLS.download}
107+
newsletter={{ action: NEWSLETTER_URLS.default, source: 'download-thank-you' }}
109108
/>
110109
</StyledDownloadaColumns>
111110
</Container>

src/components/modules/content-card/content-card.types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ export interface ContentCardProps extends StyledContentCardProps {
88
title: string;
99
text?: string;
1010
button?: ButtonProps;
11-
action?: string;
11+
newsletter?: {
12+
action: string;
13+
source: string;
14+
}
1215
}

src/components/modules/content-card/form/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
import { Input } from '../../input';
44
import { StyledNewsletterSuccess } from '../../newsletter/newsletter.styles';
55
import { StyledContentCardForm } from '../content-card.styles';
6-
import type { ContentCardProps } from '../content-card.types';
76

87
import { Button } from '@/components/elements/button';
98
import { Text } from '@/components/elements/text';
109
import { useNewsletterSubmit } from '@/lib/hooks/use-newsletter-submit';
1110

12-
export const ContentCardForm = ({ action }: Pick<ContentCardProps, 'action'>) => {
11+
export const NewsletterForm = ({ action, source }: { action: string, source: string }) => {
1312
const [isSuccess, handleSubmit] = useNewsletterSubmit();
1413
return (
1514
<>
@@ -24,6 +23,10 @@ export const ContentCardForm = ({ action }: Pick<ContentCardProps, 'action'>) =>
2423
<div className="visually-hidden">
2524
<label htmlFor="extra-info">An extra form field you should ignore</label>
2625
<input type="text" id="extra-info" name="first-name" tab-index="-1" autoComplete="nope" />
26+
27+
{ source &&
28+
<input type="hidden" name="attributes[source]" value={source} />
29+
}
2730
</div>
2831
<Input id="email" placeholder="Email address" type="email" required />
2932
<Button as="button" type="submit" $variant="primary" $small>

src/components/modules/content-card/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { StyledContentCardContent, StyledContentCardTitle, StyledContentCardWrapper } from './content-card.styles';
22
import type { ContentCardProps } from './content-card.types';
3-
import { ContentCardForm } from './form';
3+
import { NewsletterForm } from './form';
44

55
import { Button } from '@/components/elements/button';
66
import { Text } from '@/components/elements/text';
77

8-
export const ContentCard = ({ title, text, button, action, $isNewsletter }: ContentCardProps) => {
8+
export const ContentCard = ({ title, text, button, newsletter }: ContentCardProps) => {
99
return (
10-
<StyledContentCardWrapper $isNewsletter={$isNewsletter}>
10+
<StyledContentCardWrapper $isNewsletter={!!newsletter}>
1111
<StyledContentCardContent>
1212
<StyledContentCardTitle fontSize="l" fontWeight="bold" color="white" textAlign="left">
1313
{title}
@@ -18,7 +18,7 @@ export const ContentCard = ({ title, text, button, action, $isNewsletter }: Cont
1818
</Text>
1919
)}
2020
</StyledContentCardContent>
21-
{$isNewsletter && <ContentCardForm action={action} />}
21+
{!!newsletter && <NewsletterForm action={newsletter.action} source={newsletter.source} />}
2222
{button?.href && (
2323
<Button as="link" target="_blank" $variant="secondary" {...button}>
2424
{button.children}

0 commit comments

Comments
 (0)