diff --git a/components/HomePage/Letter.tsx b/components/HomePage/Letter.tsx index a8bf6a8..832d8d9 100644 --- a/components/HomePage/Letter.tsx +++ b/components/HomePage/Letter.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { useCallback, useMemo, useRef, useState } from "react"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { @@ -7,7 +7,6 @@ import { PetitionFormSchema, } from "../../data/petition"; import ky from "ky"; -import { SonomaCities } from "../../data/zipcodes"; import { Alert, AlertDescription, AlertTitle } from "../ui/alert"; import { LoaderIcon, MailCheckIcon } from "lucide-react"; import { @@ -20,14 +19,6 @@ import { FormMessage, } from "../ui/form"; import { Input } from "../ui/input"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "../ui/select"; -import { cn } from "../../utils"; import { Checkbox } from "../ui/checkbox"; import { Textarea } from "../ui/textarea"; import { Button } from "../ui/button"; @@ -73,7 +64,6 @@ export const LetterForm = () => { phone: "", outsideUS: false, zip: "", - city: "", message: DEFAULT_MESSAGE, }, }); @@ -117,7 +107,6 @@ export const LetterForm = () => { email: data.email, ...(data.phone && { phone: data.phone }), ...(data.zip && { zip: data.zip }), - ...(data.city && { city: data.city }), ...(!data.outsideUS && { country: "United States" }), fullHref: window.location.href, }), @@ -138,9 +127,8 @@ export const LetterForm = () => { ...(data.phone && { phone: data.phone }), outside_us: data.outsideUS, ...(data.zip && { zip: data.zip }), - ...(data.city && { city: data.city }), message: data.message, - campaign: "sonoma", + campaign: "ridglan", token, }, headers: { @@ -160,31 +148,12 @@ export const LetterForm = () => { ); const outsideUS = watch("outsideUS"); - const zip = watch("zip"); - const isInSonomaCounty = useMemo(() => { - return zip && zip in SonomaCities; - }, [zip]); - const cities = useMemo(() => { - if (!isInSonomaCounty) { - return []; - } - return SonomaCities[zip as keyof typeof SonomaCities]; - }, [isInSonomaCounty, zip]); - - // When cities change, just select it if there's only one. Else, reset the city. - useEffect(() => { - if (cities.length === 1) { - setValue("city", cities[0]); - } else { - setValue("city", ""); - } - }, [cities, setValue]); const injectValuesIntoMessage = useCallback( - (name: string | undefined, city: string | undefined) => { + (name: string | undefined) => { if (dirtyFields.message) { console.log( - "Skipped updating message with name or city since it has been customized." + "Skipped updating message with name since it has been customized." ); return; } @@ -192,7 +161,7 @@ export const LetterForm = () => { defaultValue: DEFAULT_MESSAGE.replace( "[Your name]", name || "[Your name]" - ).replace("[Your city if you live in Sonoma County]", city || ""), + ), }); }, [dirtyFields.message, resetField] @@ -231,7 +200,7 @@ export const LetterForm = () => { {...field} onBlur={() => { field.onBlur(); - injectValuesIntoMessage(field.value, getValues("city")); + injectValuesIntoMessage(field.value); }} /> @@ -285,10 +254,7 @@ export const LetterForm = () => { {...field} onBlur={() => { field.onBlur(); - injectValuesIntoMessage( - getValues("name"), - getValues("city") - ); + injectValuesIntoMessage(getValues("name")); }} /> @@ -296,48 +262,12 @@ export const LetterForm = () => { )} /> - ( - - City - - - - )} - /> ( - + { }} > Your support allows us to stand up to legal repression and - continue our groundbreaking work.

- + continue our groundbreaking work. +
+
All monthly donations are being matched with $100 from an anonymous donor. diff --git a/data/petition.ts b/data/petition.ts index 6e3d30a..fe7c9b0 100644 --- a/data/petition.ts +++ b/data/petition.ts @@ -1,5 +1,4 @@ import { z } from "zod"; -import { SonomaCities } from "./zipcodes"; const EmptyStringToUndefined = z.literal("").transform(() => undefined); @@ -26,11 +25,6 @@ export const PetitionFormSchema = z .length(5, { message: "Zip code must be 5 digits or empty" }) .or(EmptyStringToUndefined) .optional(), - city: z - .string() - .max(255, { message: "City too long" }) - .or(EmptyStringToUndefined) - .optional(), message: z .string() .min(10, { message: "Message must be at least 10 characters" }) @@ -50,28 +44,11 @@ export const PetitionFormSchema = z }); } } - const isInSonoma = !!( - data.zip && - data.zip in SonomaCities && - SonomaCities[data.zip as keyof typeof SonomaCities] - ); - // If outside of Sonoma, throw away the city. - if (!isInSonoma) { - data.city = undefined; - } - // If in Sonoma, city is required. - if (isInSonoma && !data.city) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: "City is required", - path: ["city"], - }); - } }); export type PetitionForm = z.infer; -export const DEFAULT_MESSAGE = `Dear District Attorney Rodriguez, +export const DEFAULT_MESSAGE = `Dear District Attorney Ozanne, I urge you to prosecute animal cruelty, not animal rescue. National polls consistently show overwhelming public support for strong legal protection for animals. Yet, countless investigations have shown that animal-using industries routinely violate animal welfare laws with no repercussions. It is time for a change. Your office should be working with whistleblowers and rescuers to protect animals from abuse. Prosecuting these good samaritans who expose animal mistreatment is wildly out of line with the values of the public. A 2015 Gallup poll¹ found that a third of Americans believe “animals deserve the exact same rights as people to be free from harm and exploitation,” a 2022 YouGov poll² found that nearly half of Americans believe that animal cruelty laws in the U.S. are not strict enough, and a 2024 poll by Positive Sum Strategies³ found that 68% of Americans believe it should not be a crime to take an animal out of an environment where they are being mistreated. The same sentiments are evidenced by two recent acquittals of animal rescuers. In October 2022, a Utah jury issued a groundbreaking “not guilty” verdict⁴ for two DxE investigators who openly rescued sick piglets from a Smithfield Foods factory pig farm. In March 2023, a California jury acquitted⁵ two more DxE investigators of theft charges for rescuing two sick chickens from a slaughter truck. @@ -84,7 +61,6 @@ Your office’s resources could be much better spent investigating and stopping Sincerely, [Your name] -[Your city if you live in Sonoma County] References: 1. https://news.gallup.com/poll/183275/say-animals-rights-people.aspx diff --git a/data/zipcodes.ts b/data/zipcodes.ts deleted file mode 100644 index bc8778c..0000000 --- a/data/zipcodes.ts +++ /dev/null @@ -1,52 +0,0 @@ -export const SonomaCities = { - "94922": ["Bodega"], - "94923": ["Bodega Bay"], - "94927": ["Cotati", "Rohnert Park"], - "94928": ["Cotati", "Rohnert Park"], - "94931": ["Cotati"], - "94951": ["Penngrove"], - "94952": ["Petaluma"], - "94953": ["Petaluma"], - "94954": ["Petaluma"], - "94955": ["Petaluma"], - "94972": ["Valley Ford"], - "94975": ["Petaluma"], - "94999": ["Petaluma"], - "95401": ["Santa Rosa"], - "95402": ["Santa Rosa"], - "95403": ["Larkfield", "Santa Rosa"], - "95404": ["Santa Rosa"], - "95405": ["Santa Rosa"], - "95406": ["Santa Rosa"], - "95407": ["Santa Rosa"], - "95408": ["Santa Rosa"], - "95409": ["Santa Rosa"], - "95412": ["Annapolis"], - "95416": ["Boyes Hot Springs"], - "95419": ["Camp Meeker"], - "95421": ["Cazadero"], - "95425": ["Cloverdale"], - "95430": ["Duncans Mills"], - "95431": ["Eldridge"], - "95433": ["El Verano"], - "95436": ["Forestville"], - "95439": ["Fulton"], - "95441": ["Geyserville"], - "95442": ["Glen Ellen"], - "95444": ["Graton"], - "95446": ["Guerneville"], - "95448": ["Healdsburg"], - "95450": ["Jenner"], - "95452": ["Kenwood"], - "95462": ["Russian River Mdws", "Monte Rio"], - "95465": ["Occidental"], - "95471": ["Rio Nido"], - "95472": ["Freestone", "Sebastopol"], - "95473": ["Sebastopol"], - "95476": ["Sonoma"], - "95480": ["Stewarts Point"], - "95486": ["Villa Grande"], - "95487": ["Vineburg"], - "95492": ["Windsor"], - "95497": ["The Sea Ranch"], -}; diff --git a/package.json b/package.json index 8bace63..f38960d 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "start": "next start", "lint": "next lint", "fmt": "npx prettier --write .", + "typecheck": "tsc --noEmit", "analyze": "cross-env ANALYZE=true next build", "analyze:server": "cross-env BUNDLE_ANALYZE=server next build", "analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build"