Skip to content

Commit

Permalink
Merge pull request #938 from mbifulco/revert-936-f/localstorage-hook
Browse files Browse the repository at this point in the history
Revert "Newsletter signup gated by localstorage hook"
  • Loading branch information
mbifulco authored Jan 4, 2025
2 parents a4d7dcc + 60f9473 commit e45d640
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 129 deletions.
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"^@craftwork/(.*)$",
"^@components/(.*)$",
"^@data/(.*)$",
"^@hooks/(.*)$",
"^@layouts/(.*)$",
"^@lib/(.*)$",
"^@ui/(.*)$",
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/components/Analytics/Fathom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import { Suspense, useEffect } from 'react';
import { usePathname, useSearchParams } from 'next/navigation';
import { useRouter } from 'next/router';
import { useRouterType } from '@hooks/useRouterType';
import * as Fathom from 'fathom-client';
import posthog from 'posthog-js';

import { useRouterType } from '@hooks/useRouterType';

const FATHOM_DOMAINS = ['mikebifulco.com', 'www.mikebifulco.com'];

const FathomPagesRouter = ({ siteId }: { siteId: string }) => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/NewsletterSignup/SubscriberCount.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import NumberFlow from '@number-flow/react';

import useNewsletterStats from '@hooks/useNewsletterStats';
import NumberFlow from '@number-flow/react';

type SubscriberCountProps = {
label?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Post/mentionsSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from 'next/router';
import { useWebMentions } from '@hooks/useWebMentions';
import pluralize from 'pluralize';

import { useWebMentions } from '@hooks/useWebMentions';
import formatDate from '@utils/format-date';
import type { WebMention } from '@utils/webmentions';
import { Avatar, AvatarGroup } from '../Avatar';
Expand Down
35 changes: 6 additions & 29 deletions src/components/SubscriptionForm/SubscriptionForm.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
'use client';

import { useRef, useState } from 'react';
import Link from 'next/link';
import useNewsletterStats from '@hooks/useNewsletterStats';
import posthog from 'posthog-js';

import Button from '@components/Button';
import { useLocalStorage } from '@hooks/useLocalStorage';
import useNewsletterStats from '@hooks/useNewsletterStats';
import { trpc } from '@utils/trpc';

type SubscriptionFormProps = {
Expand All @@ -15,19 +12,11 @@ type SubscriptionFormProps = {
buttonText?: string;
};

type SubscriptionRecord = {
email?: string;
firstName?: string;
date?: string;
};

const SubscriptionForm: React.FC<SubscriptionFormProps> = ({
tags: _,
source,
buttonText = 'Subscribe',
}) => {
const [subscriptionRecord, setSubscriptionRecord] =
useLocalStorage<SubscriptionRecord>('tiny-improvements-subscribed', {});
const [getHoneypottedNerd, setGetHoneypottedNerd] = useState<boolean>(false);
const addSubscriberMutation = trpc.mailingList.subscribe.useMutation({
onSuccess: () => {
Expand All @@ -41,12 +30,6 @@ const SubscriptionForm: React.FC<SubscriptionFormProps> = ({
email,
firstName,
});

setSubscriptionRecord({
email,
firstName,
date: new Date().toISOString(),
});
},
onError: (error) => {
const email = emailRef.current?.value;
Expand Down Expand Up @@ -115,16 +98,12 @@ const SubscriptionForm: React.FC<SubscriptionFormProps> = ({
);
}

if (
addSubscriberMutation.isSuccess ||
getHoneypottedNerd ||
subscriptionRecord?.date
) {
if (addSubscriberMutation.isSuccess || getHoneypottedNerd) {
return (
<div className="flex flex-col gap-2">
<p className="text-xl font-medium text-inherit">
🪩 Thanks so much for subscribing. Don&apos;t forget to check your
spam folder for emails from{' '}
<p className="text-xl font-semibold text-inherit">
🪩 Success! Thanks so much for subscribing. Don&apos;t forget to check
your spam folder for emails from{' '}
<span className="text-pink-600">[email protected].</span>
</p>
</div>
Expand All @@ -136,9 +115,7 @@ const SubscriptionForm: React.FC<SubscriptionFormProps> = ({
<form ref={formRef} className="w-full" onSubmit={handleSubmission}>
<fieldset
disabled={
subscriptionRecord?.date !== undefined ||
addSubscriberMutation.isPending ||
addSubscriberMutation.isSuccess
addSubscriberMutation.isPending || addSubscriberMutation.isSuccess
}
>
<div data-style="clean">
Expand Down
85 changes: 0 additions & 85 deletions src/hooks/useLocalStorage.tsx

This file was deleted.

0 comments on commit e45d640

Please sign in to comment.