diff --git a/.eslintrc.json b/.eslintrc.json index 430bc5ac..3ef6d937 100755 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -26,46 +26,39 @@ "files": ["*.ts", "*.tsx"], "extends": ["plugin:@nx/typescript", "airbnb", "airbnb-typescript", "next", "prettier"], "rules": { - "prefer-arrow/prefer-arrow-functions": [ - "error", - { - "disallowPrototype": true, - "singleReturnOnly": false, - "classPropertiesAllowed": false - } - ], - "prefer-arrow-callback": [ - "error", - { - "allowNamedFunctions": true - } - ], - "func-style": [ - "error", - "expression", - { - "allowArrowFunctions": true - } - ], + // "prefer-arrow/prefer-arrow-functions": [ + // "error", + // { + // "disallowPrototype": true, + // "singleReturnOnly": false, + // "classPropertiesAllowed": false + // } + // ], + // "prefer-arrow-callback": [ + // "error", + // { + // "allowNamedFunctions": true + // } + // ], + // "func-style": [ + // "error", + // "expression", + // { + // "allowArrowFunctions": true + // } + // ], + "react/prop-types": "off", "import/prefer-default-export": "off", "import/no-extraneous-dependencies": "off", - "import/extensions": [ - "error", - "never", - { - "json": "always", - "svg": "always", - "css": "always" - } - ], - "react/function-component-definition": [ - 2, - { - "namedComponents": "arrow-function", - "unnamedComponents": "arrow-function" - } - ], + "import/extensions": 0, + // "react/function-component-definition": [ + // 2, + // { + // "namedComponents": "arrow-function", + // "unnamedComponents": "arrow-function" + // } + // ], "react/jsx-props-no-spreading": "off", "react/require-default-props": "off" } diff --git a/apps/trialanderror.org/.eslintrc.json b/apps/trialanderror.org/.eslintrc.json index 058d366f..2775063b 100644 --- a/apps/trialanderror.org/.eslintrc.json +++ b/apps/trialanderror.org/.eslintrc.json @@ -5,7 +5,10 @@ "next/core-web-vitals", "../../.eslintrc.json" ], - "ignorePatterns": ["!**/*", ".next/**/*"], + "parserOptions": { + "project": "apps/trialanderror.org/tsconfig.*json" + }, + "ignorePatterns": ["!**/*", ".next/**/*", "**/*jest.config.ts"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], @@ -23,7 +26,8 @@ } ], "rules": { - "@next/next/no-html-link-for-pages": "off" + "@next/next/no-html-link-for-pages": "off", + "@typescript-eslint/no-shadow": "off" }, "env": { "jest": true diff --git a/apps/trialanderror.org/src/app/[page]/page.tsx b/apps/trialanderror.org/src/app/[page]/page.tsx index 4027851e..cbd11714 100644 --- a/apps/trialanderror.org/src/app/[page]/page.tsx +++ b/apps/trialanderror.org/src/app/[page]/page.tsx @@ -31,17 +31,15 @@ export default async function AboutPage({ params: { page } }: Props) {

{title}

- {block?.map((block) => { - return ( -
- ) - })} + {block?.map((b) => ( +
+ ))}
diff --git a/apps/trialanderror.org/src/app/about/ShittyScrollHack.tsx b/apps/trialanderror.org/src/app/about/ShittyScrollHack.tsx index 0c79c9cf..c96eee61 100644 --- a/apps/trialanderror.org/src/app/about/ShittyScrollHack.tsx +++ b/apps/trialanderror.org/src/app/about/ShittyScrollHack.tsx @@ -1,15 +1,15 @@ -'use client'; +'use client' -import { useEffect } from 'react'; +import { useEffect } from 'react' export function ShittyScrollHack() { useEffect(() => { - const hash = window.location.hash; + const { hash } = window.location if (hash.length > 0) { - window.location.hash = ''; - window.location.hash = hash; + window.location.hash = '' + window.location.hash = hash } - }); + }) - return <>; + return null } diff --git a/apps/trialanderror.org/src/app/about/page.tsx b/apps/trialanderror.org/src/app/about/page.tsx index 80dc711c..1085744c 100644 --- a/apps/trialanderror.org/src/app/about/page.tsx +++ b/apps/trialanderror.org/src/app/about/page.tsx @@ -3,7 +3,6 @@ import { getTeam } from '../team/page' import { TeamMemberCard } from '../components/TeamMemberCard' import { OurMission } from '../components/OurMission' import { AboutUs } from '../components/AboutUs' -import { ShittyScrollHack } from './ShittyScrollHack' import { createMetadata } from '../../utils/createMetadata' export const revalidate = 3600 // revalidate every hour diff --git a/apps/trialanderror.org/src/app/components/AboutUs.tsx b/apps/trialanderror.org/src/app/components/AboutUs.tsx index 8ecbcfa0..1799ba7e 100644 --- a/apps/trialanderror.org/src/app/components/AboutUs.tsx +++ b/apps/trialanderror.org/src/app/components/AboutUs.tsx @@ -5,8 +5,7 @@ import { Frame } from './Frame' import { growFadeIn } from '../../utils/motionPresets' export function AboutUs() { - return ( -
+ return
- ) } diff --git a/apps/trialanderror.org/src/app/components/Analytics.tsx b/apps/trialanderror.org/src/app/components/Analytics.tsx index c1ec35ee..72c823be 100644 --- a/apps/trialanderror.org/src/app/components/Analytics.tsx +++ b/apps/trialanderror.org/src/app/components/Analytics.tsx @@ -1,4 +1,5 @@ 'use client' + import { Analytics } from '@vercel/analytics/react' export function AnalyticsWrapper() { diff --git a/apps/trialanderror.org/src/app/components/Card.tsx b/apps/trialanderror.org/src/app/components/Card.tsx index 6789c7b2..a753142b 100644 --- a/apps/trialanderror.org/src/app/components/Card.tsx +++ b/apps/trialanderror.org/src/app/components/Card.tsx @@ -1,17 +1,18 @@ 'use client' -import { Card } from '../../server/mixed' + import Image from 'next/image' import Link from 'next/link' import { motion } from 'framer-motion' import { format } from 'date-fns' +import type { Card as CardType } from '../../server/mixed' -function splitSentences(sentence: string) { - const regex = /[^.!?]+[.!?]/g - const matches = sentence.match(regex) - return matches ? matches.map((s) => s.trim()) : [sentence] -} +// function splitSentences(sentence: string) { +// const regex = /[^.!?]+[.!?]/g +// const matches = sentence.match(regex) +// return matches ? matches.map((s) => s.trim()) : [sentence] +// } -export function Card({ card, delay = 0 }: { card: Card; delay?: number }) { +export function Card({ card, delay = 0 }: { card: CardType; delay?: number }) { const { title, type } = card const titleWithoutAcronymsWithPeriods = title.replace(/([A-Z])\.([A-Z])\.?/g, '$1$2') @@ -20,7 +21,6 @@ export function Card({ card, delay = 0 }: { card: Card; delay?: number }) { const mainTitle = titleParts[1]?.replace(/[:.]/g, '') const subTitle = titleParts.slice(2).join(' ')?.replace(/[:.]/g, '').trim() const capitalizedSubTitle = subTitle.charAt(0).toUpperCase() + subTitle.slice(1) - const titleClass = subTitle ? 'text-2xl' : 'text-3xl' return ( {card?.image?.url ? ( {/* authors */} - {card.team?.length > 0 ? ( -
- {(card?.team ?? []).map((author) => ( - - {typeof author === 'object' ? `${author.firstName} ${author.lastName}` : author} + { + // eslint-disable-next-line no-nested-ternary + card.team?.length > 0 ? ( +
+ {(card?.team ?? []).map((author) => ( + + {typeof author === 'object' + ? `${author.firstName} ${author.lastName}` + : author} + + ))} +
+ ) : card.team.length > 3 ? ( +
+ + {typeof card.team[0] === 'object' + ? `${card.team[0].firstName} ${card.team[0].lastName} et al.` + : card.team[0]} - ))} -
- ) : card.team.length > 3 ? ( -
- - {typeof card.team[0] === 'object' - ? `${card.team[0].firstName} ${card.team[0].lastName} et al.` - : card.team[0]} - -
- ) : null} +
+ ) : null + }
diff --git a/apps/trialanderror.org/src/app/components/Footer.tsx b/apps/trialanderror.org/src/app/components/Footer.tsx index 34f8e5d0..632e0b7c 100644 --- a/apps/trialanderror.org/src/app/components/Footer.tsx +++ b/apps/trialanderror.org/src/app/components/Footer.tsx @@ -1,4 +1,3 @@ -import { EasyMenu } from '@/types' import Image from 'next/image' import Link from 'next/link' import { @@ -9,6 +8,7 @@ import { FaMastodon, FaTwitter, } from 'react-icons/fa' +import { EasyMenu } from '@/types' import { getNavigation } from '../../server/nav' import { SignUp } from './SignUp' @@ -120,28 +120,28 @@ export async function Footer() {
{navigation.items ?.slice(0, Math.floor((navigation.items ?? []).length / 2 + 0.9)) - ?.map(({ title }, idx) => ( + ?.map(({ title: t }, idx) => ( // {Object.entries(navigation).map(([name, links]) => ( -
+
{(navigation.items ?? []) ?.slice(idx * 2, idx * 2 + 2) - .map(({ title, children, url, target }) => ( + .map(({ title, children }) => (
+ key={title} // className={idx % 2 === 0 ? 'mt-12 md:mt-0' : ''}> className="mt-12 md:mt-0" >

{title}

-
    - {(children ?? []).map(({ title, url, target }) => ( -
  • +
      + {(children ?? []).map(({ title: nestedTitle, url, target }) => ( +
    • - {title} + {nestedTitle}
    • ))} diff --git a/apps/trialanderror.org/src/app/components/Frame.tsx b/apps/trialanderror.org/src/app/components/Frame.tsx index e2d29a36..4262281f 100644 --- a/apps/trialanderror.org/src/app/components/Frame.tsx +++ b/apps/trialanderror.org/src/app/components/Frame.tsx @@ -1,14 +1,15 @@ -'use client'; +'use client' + +import { motion, useInView } from 'framer-motion' +import { useRef } from 'react' -import { motion, useInView } from 'framer-motion'; -import { useRef, useState } from 'react'; export function Frame() { - const ref = useRef(null); + const ref = useRef(null) const isInView = useInView(ref, { // once: true, - }); - console.log(isInView); + }) + console.log(isInView) return ( //
      @@ -19,7 +20,7 @@ export function Frame() { className="absolute inset-6 -z-20 flex h-full w-[calc(100vw-3rem)] md:inset-20 md:w-[calc(100vw-10rem)]" preserveAspectRatio="none" ref={ref} - pointerEvents={'none'} + pointerEvents="none" // vectorEffect="non-scaling-stroke" > //
      //
      - ); + ) } diff --git a/apps/trialanderror.org/src/app/components/Hero.tsx b/apps/trialanderror.org/src/app/components/Hero.tsx index b147da22..e4579893 100644 --- a/apps/trialanderror.org/src/app/components/Hero.tsx +++ b/apps/trialanderror.org/src/app/components/Hero.tsx @@ -1,10 +1,10 @@ 'use client' -import { Frame } from './Frame' + import { motion } from 'framer-motion' +import { Frame } from './Frame' export function Hero() { - return ( -
      + return
      {/*
      */}
      @@ -38,5 +38,4 @@ export function Hero() {
      - ) } diff --git a/apps/trialanderror.org/src/app/components/InfiniteCards.tsx b/apps/trialanderror.org/src/app/components/InfiniteCards.tsx index 41108e0d..fa0f49c9 100644 --- a/apps/trialanderror.org/src/app/components/InfiniteCards.tsx +++ b/apps/trialanderror.org/src/app/components/InfiniteCards.tsx @@ -1,5 +1,5 @@ 'use client' -import Image from 'next/image' + import React from 'react' import { trpc } from '../../utils/trpcClient' import { Card } from './Card' @@ -16,6 +16,7 @@ export function useIsIntersecting() { } const observer = new IntersectionObserver(([entry]) => setIsIntersecting(entry.isIntersecting)) observer.observe(ref.current) + // eslint-disable-next-line consistent-return return () => { observer.disconnect() } @@ -23,12 +24,11 @@ export function useIsIntersecting() { return [isIntersecting, ref] as const } -export function InfiniteCards({ limit, cursor }: { limit?: number; cursor?: string }) { +export function InfiniteCards({ limit }: { limit?: number }) { const query = trpc.cards.infiniteCards.useInfiniteQuery( { limit }, { getNextPageParam(lastPage) { - console.log(lastPage) return lastPage.nextCursor }, }, @@ -44,25 +44,25 @@ export function InfiniteCards({ limit, cursor }: { limit?: number; cursor?: stri } }, [isLoadMoreVisible, query.hasNextPage, query.isFetching]) - console.log(query.data) return ( <> - {query.data?.pages.map((page) => { - return page.cards.map((card, idx) => { - return - }) - })} + {query.data?.pages.map((page) => + page.cards.map((card, idx) => ( + + )), + )}
      {query.isFetchingNextPage ? ( Loading ) : ( diff --git a/apps/trialanderror.org/src/app/components/MailForm.tsx b/apps/trialanderror.org/src/app/components/MailForm.tsx index fa77a682..88617a37 100644 --- a/apps/trialanderror.org/src/app/components/MailForm.tsx +++ b/apps/trialanderror.org/src/app/components/MailForm.tsx @@ -1,8 +1,11 @@ 'use client' + +/* eslint-disable jsx-a11y/label-has-associated-control */ + // -import { Fragment, useState } from 'react' +import { Fragment } from 'react' import { Dialog, Transition } from '@headlessui/react' -import { CheckIcon, ExclamationCircleIcon, XMarkIcon } from '@heroicons/react/24/outline/index' +import { CheckIcon, XMarkIcon } from '@heroicons/react/24/outline/index' import { useForm } from 'react-hook-form' import { Ring } from '@uiball/loaders' import fetchJsonp from 'fetch-jsonp' @@ -26,7 +29,7 @@ type FormData = { b_3b2e720baa7621e1bde91b1a2_13b78e80c7?: string } -export const MailForm = ({ +export function MailForm({ open, setOpen, email, @@ -34,7 +37,7 @@ export const MailForm = ({ open: boolean setOpen: (curr: boolean) => void email?: string -}) => { +}) { // const [open, setOpen] = useState(true) const { @@ -87,7 +90,7 @@ export const MailForm = ({ return ( -
      +
      */} -
      +
      {/*
      */} {/*
      */} - + )}
      @@ -339,7 +340,7 @@ export const MailForm = ({ acknowledge that your information will be transferred to Mailchimp for processing. - Learn more about Mailchimp's privacy practices here. + Learn more about Mailchimp's privacy practices here.

      diff --git a/apps/trialanderror.org/src/app/components/Navigation.tsx b/apps/trialanderror.org/src/app/components/Navigation.tsx index e20b3aba..c8df5c0e 100644 --- a/apps/trialanderror.org/src/app/components/Navigation.tsx +++ b/apps/trialanderror.org/src/app/components/Navigation.tsx @@ -1,60 +1,63 @@ -'use client'; -import { usePathname } from 'next/navigation'; -import Link from 'next/link'; -import { motion } from 'framer-motion'; +'use client' -import { Fragment, useRef, useState } from 'react'; -import { Popover, Transition } from '@headlessui/react'; -import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline'; -import { ChevronDownIcon } from '@heroicons/react/24/solid'; -import Image from 'next/image'; -import { Menu, MenuItem } from '@/types'; -import { useHideableNavbar } from '../../hooks/useHideableNavbar'; +/* eslint-disable @typescript-eslint/no-shadow */ +/* eslint-disable react/jsx-no-bind */ + +import { usePathname } from 'next/navigation' +import Link from 'next/link' +import { motion } from 'framer-motion' + +import { Fragment, useRef, useState } from 'react' +import { Popover, Transition } from '@headlessui/react' +import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline' +import { ChevronDownIcon } from '@heroicons/react/24/solid' +import Image from 'next/image' +import { Menu, MenuItem } from '@/types' +import { useHideableNavbar } from '../../hooks/useHideableNavbar' export function classNames(...classes: string[]) { - return classes.filter(Boolean).join(' '); + return classes.filter(Boolean).join(' ') } const useOnHover = () => { - const buttonRef = useRef(null); - const timeoutDuration = 200; - let timeout: NodeJS.Timeout; + const buttonRef = useRef(null) + const timeoutDuration = 200 + let timeout: NodeJS.Timeout - const closePopover = () => { - return buttonRef.current?.dispatchEvent( + const closePopover = () => + buttonRef.current?.dispatchEvent( new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true, - }) - ); - }; + }), + ) const onMouseEnter = (open: boolean) => { - clearTimeout(timeout); - if (open) return; - return buttonRef.current?.click(); - }; + clearTimeout(timeout) + if (open) return + buttonRef.current?.click() + } const onMouseLeave = (open: boolean) => { - if (!open) return; - timeout = setTimeout(() => closePopover(), timeoutDuration); - }; + if (!open) return + timeout = setTimeout(() => closePopover(), timeoutDuration) + } - return { buttonRef, onMouseEnter, onMouseLeave }; -}; + return { buttonRef, onMouseEnter, onMouseLeave } +} -const HoverPopover = ({ +function HoverPopover({ pathname, item: { children, title, url, target }, }: { - item: MenuItem; - pathname?: string | null; + item: MenuItem + pathname?: string | null // subItems: { name: string; href: string; description?: string; scroll?: boolean }[] // title: string // titleHref?: string -}) => { - const { buttonRef, onMouseEnter, onMouseLeave } = useOnHover(); +}) { + const { buttonRef, onMouseEnter, onMouseLeave } = useOnHover() return ( {({ open }) => ( @@ -68,11 +71,9 @@ const HoverPopover = ({ 'group inline-flex items-center text-base font-medium hover:text-gray-900 hover:ring-[rgba(0,0,0,0)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500 focus-visible:ring-offset-2', pathname && url && - (pathname === url && pathname === '/' - ? 'after:!w-full' - : pathname?.startsWith(url)) + (pathname === url && pathname === '/' ? 'after:!w-full' : pathname?.startsWith(url)) ? 'after:!w-full' - : '' + : '', )} onMouseEnter={onMouseEnter.bind(null, open)} onMouseLeave={onMouseLeave.bind(null, open)} @@ -80,9 +81,7 @@ const HoverPopover = ({ {url ? ( {title} @@ -115,19 +114,13 @@ const HoverPopover = ({ {children?.map(({ title, url, target, description }) => ( -

      - {title} -

      -

      - {description} -

      +

      {title}

      +

      {description}

      ))}
      @@ -137,14 +130,14 @@ const HoverPopover = ({ )} - ); -}; + ) +} export function Navigation({ nav }: { nav: Menu }) { - const pathname = usePathname(); + const pathname = usePathname() - const { isNavbarVisible, navbarRef } = useHideableNavbar(); - const [hover, setHover] = useState(false); + const { isNavbarVisible, navbarRef } = useHideableNavbar() + const [hover, setHover] = useState(false) return (
      -
      +
      Open menu @@ -184,18 +177,15 @@ export function Navigation({ nav }: { nav: Menu }) {
      {nav.items?.map((item) => { - if (item.children?.length == 0) { + if (item.children?.length === 0) { const shouldOpenInNewTab = - item.target ?? item.url?.startsWith('http') - ? '_blank' - : undefined; + item.target ?? item.url?.startsWith('http') ? '_blank' : undefined const underlineMaybe = pathname && - ((pathname === item.url && pathname === '/') || - item.url?.startsWith(pathname)) + ((pathname === item.url && pathname === '/') || item.url?.startsWith(pathname)) ? 'after:!w-full' - : ''; + : '' return ( {item.title} - ); + ) } - return ( - - ); + return })}
      @@ -228,7 +216,7 @@ export function Navigation({ nav }: { nav: Menu }) { className="absolute inset-x-0 top-0 origin-top-right transform p-2 transition md:hidden" >
      -
      +
      @@ -296,5 +276,5 @@ export function Navigation({ nav }: { nav: Menu }) { - ); + ) } diff --git a/apps/trialanderror.org/src/app/components/OurMission.tsx b/apps/trialanderror.org/src/app/components/OurMission.tsx index 3a4a7fe1..ed039442 100644 --- a/apps/trialanderror.org/src/app/components/OurMission.tsx +++ b/apps/trialanderror.org/src/app/components/OurMission.tsx @@ -4,8 +4,7 @@ import { motion } from 'framer-motion' import Link from 'next/link' export function OurMission() { - return ( -
      + return
      {/* light blue backdrop */}
      @@ -58,5 +57,4 @@ export function OurMission() {
      - ) } diff --git a/apps/trialanderror.org/src/app/components/SignUp.tsx b/apps/trialanderror.org/src/app/components/SignUp.tsx index 287f7329..91232409 100644 --- a/apps/trialanderror.org/src/app/components/SignUp.tsx +++ b/apps/trialanderror.org/src/app/components/SignUp.tsx @@ -1,14 +1,18 @@ 'use client' + +/* eslint-disable jsx-a11y/label-has-associated-control */ + import { lazy, useId, useState } from 'react' // lazy load the form -const MailForm = lazy(async () => await import('./MailForm')) +const MailForm = lazy(async () => import('./MailForm')) -export const SignUp = ({ mailId }: { mailId?: string }) => { +export function SignUp({ mailId }: { mailId?: string }) { const [open, setOpen] = useState(false) const [email, setEmail] = useState('') const id = useId() + const correctId = mailId ?? id return ( <> @@ -19,25 +23,25 @@ export const SignUp = ({ mailId }: { mailId?: string }) => { }} className="mt-4 sm:flex sm:max-w-md lg:mt-0" > -
      + ) } diff --git a/apps/trialanderror.org/src/app/components/WhatDoWeDo.tsx b/apps/trialanderror.org/src/app/components/WhatDoWeDo.tsx index a5a55c28..52301d1f 100644 --- a/apps/trialanderror.org/src/app/components/WhatDoWeDo.tsx +++ b/apps/trialanderror.org/src/app/components/WhatDoWeDo.tsx @@ -1,11 +1,12 @@ 'use client' + import { Attribute } from '@strapi/strapi' import { motion, useReducedMotion, Variant } from 'framer-motion' import Image from 'next/image' import { useMemo, useState } from 'react' import { useMediaQuery } from '../../hooks/useMediaQuery' -const WhatWeDoSection = ({ +function WhatWeDoSection({ children, hover, image, @@ -19,9 +20,9 @@ const WhatWeDoSection = ({ title: string isSmall?: boolean setHover: (arg: React.SetStateAction<{ tab: number; show: boolean }[]>) => void -}) => { +}) { const handleHover = () => { - setHover((prev) => { + setHover(() => { const newHover = [ { tab: 0, show: false }, { tab: 1, show: false }, @@ -78,6 +79,7 @@ const WhatWeDoSection = ({ flexShrink: 1, }} className={`relative flex flex-col items-center bg-white ${ + // eslint-disable-next-line no-nested-ternary hover.tab === 2 ? '' : isSmall @@ -179,11 +181,11 @@ const WhatWeDoSection = ({ ) } -export const WhatDoWeDo = ({ +export function WhatDoWeDo({ images, }: { images: (Attribute.GetValues<'plugin::upload.file'> | null)[] -}) => { +}) { const [hover, setHover] = useState([ { tab: 0, show: true }, { tab: 1, show: false }, diff --git a/apps/trialanderror.org/src/app/layout.tsx b/apps/trialanderror.org/src/app/layout.tsx index 4ec2569e..24edbff4 100644 --- a/apps/trialanderror.org/src/app/layout.tsx +++ b/apps/trialanderror.org/src/app/layout.tsx @@ -1,11 +1,10 @@ +import { Overpass, Open_Sans } from 'next/font/google' +import Script from 'next/script' import { AnalyticsWrapper } from './components/Analytics' import { Footer } from './components/Footer' import { Nav } from './components/Nav' import { createMetadata } from '../utils/createMetadata' -import { Overpass, Open_Sans } from 'next/font/google' -import Script from 'next/script' - import '../styles/globals.css' const overpass = Overpass({ @@ -14,7 +13,7 @@ const overpass = Overpass({ // display: 'swap', }) -const open_sans = Open_Sans({ +const openSans = Open_Sans({ subsets: ['latin'], variable: '--font-open-sans', // display: 'swap', @@ -26,7 +25,7 @@ export const metadata = createMetadata({ export default function RootLayout({ children }: { children: React.ReactNode }) { return ( - + diff --git a/apps/trialanderror.org/src/app/page.tsx b/apps/trialanderror.org/src/app/page.tsx index 30abe18e..7f902a8d 100644 --- a/apps/trialanderror.org/src/app/page.tsx +++ b/apps/trialanderror.org/src/app/page.tsx @@ -9,7 +9,7 @@ export const revalidate = 3600 // revalidate at least every hour export default async function Page() { const cardsPromise = await getAllCards({ limit: 12 }) // TODO: don't hardcode the images - const filesPromise = Promise.all([573, 571, 572].map(async (file) => await getFile(file))) + const filesPromise = Promise.all([573, 571, 572].map(async (file) => getFile(file))) const [cards, files] = await Promise.all([cardsPromise, filesPromise]) @@ -22,7 +22,7 @@ export default async function Page() {

      - What's New? + What's New?

      {cards.map((card, idx) => ( diff --git a/apps/trialanderror.org/src/app/projects/page.tsx b/apps/trialanderror.org/src/app/projects/page.tsx index 9dbfa99a..9e097a8b 100644 --- a/apps/trialanderror.org/src/app/projects/page.tsx +++ b/apps/trialanderror.org/src/app/projects/page.tsx @@ -5,17 +5,17 @@ export default async function ProjectsPage() {

      Journal of Trial & Error

      -

      +

      Blog of Trial & Error

      -

      +

      Publishers of Trial & Error

      -

      +

      ) diff --git a/apps/trialanderror.org/src/app/team/[slug]/pageX.tsx b/apps/trialanderror.org/src/app/team/[slug]/pageX.tsx index b53f9958..2c7fd4d2 100644 --- a/apps/trialanderror.org/src/app/team/[slug]/pageX.tsx +++ b/apps/trialanderror.org/src/app/team/[slug]/pageX.tsx @@ -30,12 +30,12 @@ export default async function PersonPage({ params }: { params: { slug: string } lastName, position, pronouns, - show_pronouns, + show_pronouns: showPronouns, bio, summary, github, image, - blog_posts, + blog_posts: blogPosts, linkedin, personalWebsite, twitter, @@ -49,7 +49,7 @@ export default async function PersonPage({ params }: { params: { slug: string } {firstName} {lastName} - {show_pronouns && ( + {showPronouns && (

      {pronouns}

      @@ -118,13 +118,13 @@ export default async function PersonPage({ params }: { params: { slug: string }
      - {blog_posts && ( + {blogPosts && (

      Blog Posts by {firstName} {lastName}

      - {blog_posts.map((post) => ( -
      + {blogPosts.map((post) => ( +

      {post.title}

      {post.excerpt}

      diff --git a/apps/trialanderror.org/src/app/team/page.tsx b/apps/trialanderror.org/src/app/team/page.tsx index 316e2715..9bc41bad 100644 --- a/apps/trialanderror.org/src/app/team/page.tsx +++ b/apps/trialanderror.org/src/app/team/page.tsx @@ -1,7 +1,7 @@ -import { strapiClient } from '../../server/api/strapi' import { Attribute } from '@strapi/strapi' import Image from 'next/image' import Link from 'next/link' +import { strapiClient } from '../../server/api/strapi' export const revalidate = 3600 // revalidate every hour @@ -19,115 +19,107 @@ export default async function TeamPage() { const team = await getTeam() return ( - <> -
      -
      -
      -
      -

      Our Team

      -

      - Nulla quam felis, enim faucibus proin velit, ornare id pretium. Augue ultrices sed - arcu condimentum vestibulum suspendisse. Volutpat eu faucibus vivamus eget bibendum - cras. -

      -
      -
      -
      - +
      ) } diff --git a/apps/trialanderror.org/src/hooks/useHideableNavbar.tsx b/apps/trialanderror.org/src/hooks/useHideableNavbar.tsx index 458f5cb8..128b8861 100644 --- a/apps/trialanderror.org/src/hooks/useHideableNavbar.tsx +++ b/apps/trialanderror.org/src/hooks/useHideableNavbar.tsx @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import { useState, useCallback, useRef, useEffect } from 'react' +import { useState, useCallback, useRef } from 'react' // import {useScrollPosition} from '../utils/scrollUtils'; import { useMotionValueEvent, useScroll } from 'framer-motion' diff --git a/apps/trialanderror.org/src/pages/api/auth/[...nextauth].ts b/apps/trialanderror.org/src/pages/api/auth/[...nextauth].ts index 1372ec89..c8adbfc0 100644 --- a/apps/trialanderror.org/src/pages/api/auth/[...nextauth].ts +++ b/apps/trialanderror.org/src/pages/api/auth/[...nextauth].ts @@ -1,12 +1,11 @@ import NextAuth, { type NextAuthOptions } from 'next-auth' -import { env } from '../../../env/server.mjs' - export const authOptions: NextAuthOptions = { // Include user.id on session callbacks: { session({ session, user }) { if (session.user) { + // eslint-disable-next-line no-param-reassign session.user.id = user.id } return session diff --git a/apps/trialanderror.org/src/pages/api/rss.ts b/apps/trialanderror.org/src/pages/api/rss.ts index a5fd5a78..7925b6a0 100644 --- a/apps/trialanderror.org/src/pages/api/rss.ts +++ b/apps/trialanderror.org/src/pages/api/rss.ts @@ -18,10 +18,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) switch (typeAsString) { case 'rss': res.setHeader('Content-Type', 'application/rss+xml') + break case 'atom': res.setHeader('Content-Type', 'application/atom+xml') + break case 'json': res.setHeader('Content-Type', 'application/json') + break + default: + break } res.setHeader('Cache-Control', 'max-age=0, s-maxage=3600') diff --git a/apps/trialanderror.org/src/pages/api/trpc/[trpc].ts b/apps/trialanderror.org/src/pages/api/trpc/[trpc].ts index 8ec828b5..f5694e17 100644 --- a/apps/trialanderror.org/src/pages/api/trpc/[trpc].ts +++ b/apps/trialanderror.org/src/pages/api/trpc/[trpc].ts @@ -1,19 +1,17 @@ -import { createNextApiHandler } from "@trpc/server/adapters/next"; +import { createNextApiHandler } from '@trpc/server/adapters/next' -import { env } from "../../../env/server.mjs"; -import { createTRPCContext } from "../../../server/api/trpc"; -import { appRouter } from "../../../server/api/root"; +import { env } from '../../../env/server.mjs' +import { createTRPCContext } from '../../../server/api/trpc' +import { appRouter } from '../../../server/api/root' // export API handler export default createNextApiHandler({ router: appRouter, createContext: createTRPCContext, onError: - env.NODE_ENV === "development" + env.NODE_ENV === 'development' ? ({ path, error }) => { - console.error( - `❌ tRPC failed on ${path ?? ""}: ${error.message}`, - ); + console.error(`❌ tRPC failed on ${path ?? ''}: ${error.message}`) } : undefined, -}); +}) diff --git a/apps/trialanderror.org/src/server/api/routers/example.ts b/apps/trialanderror.org/src/server/api/routers/example.ts index 30559f27..8ce3117d 100644 --- a/apps/trialanderror.org/src/server/api/routers/example.ts +++ b/apps/trialanderror.org/src/server/api/routers/example.ts @@ -5,13 +5,9 @@ import { createTRPCRouter, publicProcedure, protectedProcedure } from "../trpc"; export const exampleRouter = createTRPCRouter({ hello: publicProcedure .input(z.object({ text: z.string() })) - .query(({ input }) => { - return { + .query(({ input }) => ({ greeting: `Hello ${input.text}`, - }; - }), + })), - getSecretMessage: protectedProcedure.query(() => { - return "you can now see this secret message!"; - }), + getSecretMessage: protectedProcedure.query(() => "you can now see this secret message!"), }); diff --git a/apps/trialanderror.org/src/server/api/routers/frontPageCards.ts b/apps/trialanderror.org/src/server/api/routers/frontPageCards.ts index 3ae87306..b4628978 100644 --- a/apps/trialanderror.org/src/server/api/routers/frontPageCards.ts +++ b/apps/trialanderror.org/src/server/api/routers/frontPageCards.ts @@ -1,7 +1,7 @@ import { z } from 'zod' import { getAllCards } from '../../mixed' -import { createTRPCRouter, publicProcedure, protectedProcedure } from '../trpc' +import { createTRPCRouter, publicProcedure } from '../trpc' export const cardRouter = createTRPCRouter({ infiniteCards: publicProcedure @@ -14,10 +14,10 @@ export const cardRouter = createTRPCRouter({ .query(async ({ input }) => { const cards = await getAllCards({ limit: input.limit + 1, offset: input.cursor }) - let nextCursor: number | undefined = undefined + let nextCursor: number | undefined if (cards.length > input.limit) { - const lastCard = cards.pop() + cards.pop() nextCursor = input.cursor + input.limit } diff --git a/apps/trialanderror.org/src/server/api/strapi.ts b/apps/trialanderror.org/src/server/api/strapi.ts index 3ea988b9..85d8f7c7 100644 --- a/apps/trialanderror.org/src/server/api/strapi.ts +++ b/apps/trialanderror.org/src/server/api/strapi.ts @@ -5,7 +5,7 @@ import { env } from '../../env/server.mjs' declare global { // eslint-disable-next-line vars-on-top, no-var - var strapi: StrapiClient | undefined + var strapiClient: StrapiClient } export const strapiClientOptions: StrapiClientOptions = { @@ -16,8 +16,8 @@ export const strapiClientOptions: StrapiClientOptions = { persistSession: false, } -export const strapiClient = global.strapi || createClient(strapiClientOptions) +export const strapiClient = global.strapiClient || createClient(strapiClientOptions) if (env.NODE_ENV !== 'production') { - global.strapi = strapiClient + global.strapiClient = strapiClient } diff --git a/apps/trialanderror.org/src/server/api/trpc.ts b/apps/trialanderror.org/src/server/api/trpc.ts index a8c5a482..8ead3e36 100644 --- a/apps/trialanderror.org/src/server/api/trpc.ts +++ b/apps/trialanderror.org/src/server/api/trpc.ts @@ -19,6 +19,15 @@ import { type CreateNextContextOptions } from "@trpc/server/adapters/next"; import { type Session } from "next-auth"; + +/** + * 2. INITIALIZATION + * + * This is where the trpc api is initialized, connecting the context and + * transformer + */ +import { initTRPC, TRPCError } from "@trpc/server"; +import superjson from "superjson"; import { getServerAuthSession } from "../auth"; type CreateContextOptions = { @@ -34,11 +43,9 @@ type CreateContextOptions = { * - trpc's `createSSGHelpers` where we don't have req/res * @see https://create.t3.gg/en/usage/trpc#-servertrpccontextts */ -const createInnerTRPCContext = (opts: CreateContextOptions) => { - return { +const createInnerTRPCContext = (opts: CreateContextOptions) => ({ session: opts.session, - }; -}; + }); /** * This is the actual context you'll use in your router. It will be used to @@ -56,15 +63,6 @@ export const createTRPCContext = async (opts: CreateNextContextOptions) => { }); }; -/** - * 2. INITIALIZATION - * - * This is where the trpc api is initialized, connecting the context and - * transformer - */ -import { initTRPC, TRPCError } from "@trpc/server"; -import superjson from "superjson"; - const t = initTRPC.context().create({ transformer: superjson, errorFormatter({ shape }) { diff --git a/apps/trialanderror.org/src/server/auth.ts b/apps/trialanderror.org/src/server/auth.ts index 4b93fc13..8888f641 100644 --- a/apps/trialanderror.org/src/server/auth.ts +++ b/apps/trialanderror.org/src/server/auth.ts @@ -16,6 +16,4 @@ import { authOptions } from '../pages/api/auth/[...nextauth]' export const getServerAuthSession = async (ctx: { req: GetServerSidePropsContext['req'] res: GetServerSidePropsContext['res'] -}) => { - return await getServerSession(ctx.req, ctx.res, authOptions) -} +}) => getServerSession(ctx.req, ctx.res, authOptions) diff --git a/apps/trialanderror.org/src/server/files.ts b/apps/trialanderror.org/src/server/files.ts index fc762999..532b1fa5 100644 --- a/apps/trialanderror.org/src/server/files.ts +++ b/apps/trialanderror.org/src/server/files.ts @@ -1,17 +1,15 @@ -import { cache } from 'react' -import { strapiClient } from './api/strapi' import { Attribute } from '@strapi/strapi' import { env } from '../env/server.mjs' export const getFile = async (id: number) => { try { - return ( + return await (( await fetch(`${env.STRAPI_ENDPOINT}/upload/files/${id}`, { headers: { Authorization: `Bearer ${env.STRAPI_API_TOKEN}`, }, }) - ).json() as Promise> + ).json() as Promise>) } catch (err) { console.log(err) return null diff --git a/apps/trialanderror.org/src/server/mixed.ts b/apps/trialanderror.org/src/server/mixed.ts index eb9ba751..f6c0757e 100644 --- a/apps/trialanderror.org/src/server/mixed.ts +++ b/apps/trialanderror.org/src/server/mixed.ts @@ -1,4 +1,3 @@ -import { cache } from 'react' import { env } from '../env/server.mjs' export interface Card { @@ -40,14 +39,14 @@ interface Img { export const getAllCards = async ({ limit = 100, offset = 0 } = {}) => { try { - return ( + return await (( await fetch(`${env.STRAPI_ENDPOINT}/front-page-cards?limit=${limit}&offset=${offset}`, { headers: { Authorization: `Bearer ${env.STRAPI_API_TOKEN}`, }, next: { revalidate: 3600 }, }) - ).json() as Promise + ).json() as Promise) } catch (err) { console.log(err) return [] diff --git a/apps/trialanderror.org/src/server/nav.ts b/apps/trialanderror.org/src/server/nav.ts index 87075780..c8c73e45 100644 --- a/apps/trialanderror.org/src/server/nav.ts +++ b/apps/trialanderror.org/src/server/nav.ts @@ -4,8 +4,7 @@ import { strapiClient } from './api/strapi' // otherwise the strapiClient will be type undefined import { Menu } from '@/types' -export const getNavigation = cache(async (slug: string) => { - return ( +export const getNavigation = cache(async (slug: string) => ( ( await strapiClient .from('menus?nested=true') @@ -14,5 +13,4 @@ export const getNavigation = cache(async (slug: string) => { .populate() .get() )?.data?.[0] ?? ({} as Menu) - ) -}) + )) diff --git a/apps/trialanderror.org/src/server/page.ts b/apps/trialanderror.org/src/server/page.ts index 6a522d73..abc87558 100644 --- a/apps/trialanderror.org/src/server/page.ts +++ b/apps/trialanderror.org/src/server/page.ts @@ -4,9 +4,7 @@ import { strapiClient } from './api/strapi' // otherwise the strapiClient will be type undefined import type { Page } from '@/types' -export const getPage = cache(async (slug: string) => { - return ( +export const getPage = cache(async (slug: string) => ( (await strapiClient.from('pages').select().equalTo('slug', slug).populate().get()) ?.data?.[0] ?? ({} as Page) - ) -}) + )) diff --git a/apps/trialanderror.org/src/types.d.ts b/apps/trialanderror.org/src/types.d.ts index 43845f8f..146b3d55 100644 --- a/apps/trialanderror.org/src/types.d.ts +++ b/apps/trialanderror.org/src/types.d.ts @@ -1,4 +1,5 @@ import { ReactNode } from 'react' + declare global { namespace JSX { type ElementType = diff --git a/apps/trialanderror.org/src/utils/api.ts b/apps/trialanderror.org/src/utils/api.ts index fed35a17..3d968feb 100644 --- a/apps/trialanderror.org/src/utils/api.ts +++ b/apps/trialanderror.org/src/utils/api.ts @@ -26,7 +26,7 @@ export const api = createTRPCNext({ /** * Transformer used for data de-serialization from the server * @see https://trpc.io/docs/data-transformers - **/ + * */ transformer: superjson, /** @@ -55,10 +55,10 @@ export const api = createTRPCNext({ /** * Inference helper for inputs * @example type HelloInput = RouterInputs['example']['hello'] - **/ + * */ export type RouterInputs = inferRouterInputs /** * Inference helper for outputs * @example type HelloOutput = RouterOutputs['example']['hello'] - **/ + * */ export type RouterOutputs = inferRouterOutputs diff --git a/apps/trialanderror.org/src/utils/createMetadata.ts b/apps/trialanderror.org/src/utils/createMetadata.ts index f633949b..9b79283f 100644 --- a/apps/trialanderror.org/src/utils/createMetadata.ts +++ b/apps/trialanderror.org/src/utils/createMetadata.ts @@ -38,7 +38,7 @@ export const createMetadata = ( url: `https://trialanderror.org/${canonical}`, title: ogTitle ?? (title ? `${title} | Center of Trial and Error` : 'Center of Trial and Error'), - description: description, + description, images: [ { url: diff --git a/apps/trialanderror.org/src/utils/generateRSSFeed.ts b/apps/trialanderror.org/src/utils/generateRSSFeed.ts index 29b75d3f..0b780a82 100644 --- a/apps/trialanderror.org/src/utils/generateRSSFeed.ts +++ b/apps/trialanderror.org/src/utils/generateRSSFeed.ts @@ -1,10 +1,9 @@ import { Feed, FeedOptions } from 'feed' import { getAllCards } from '../server/mixed' -import { env } from '../env/server.mjs' export async function generateRssFeed(type: 'rss' | 'atom' | 'json' = 'rss') { const allPosts = await getAllCards({ limit: 1000 }) - const site_url = process.env.VERCEL ? 'https://trialanderror.org' : 'http://localhost:4200' + const siteUrl = process.env.VERCEL ? 'https://trialanderror.org' : 'http://localhost:4200' const feedOptions: FeedOptions = { updated: new Date(), @@ -17,10 +16,10 @@ export async function generateRssFeed(type: 'rss' | 'atom' | 'json' = 'rss') { ttl: 60 * 60, title: 'Center of Trial & Error | RSS Feed', description: 'Updates from the Blog, Journal, and Center of Trial & Error!', - id: site_url, - link: site_url, - image: `${site_url}/android-chrome-384x384.png`, - favicon: `${site_url}/favicon.ico`, + id: siteUrl, + link: siteUrl, + image: `${siteUrl}/android-chrome-384x384.png`, + favicon: `${siteUrl}/favicon.ico`, copyright: `CC-BY 4.0 ${new Date().getFullYear()}, Center of Trial & Error`, generator: 'Feed for Node.js', feedLinks: { @@ -90,15 +89,12 @@ export async function generateRssFeed(type: 'rss' | 'atom' | 'json' = 'rss') { }) }) - if (type === 'rss') { - return feed.rss2() - } - - if (type === 'atom') { - return feed.atom1() - } - - if (type === 'json') { - return feed.json1() + switch (type) { + case 'json': + return feed.json1() + case 'atom': + return feed.atom1() + default: + return feed.rss2() } } diff --git a/apps/trialanderror.org/src/utils/trpcClient.tsx b/apps/trialanderror.org/src/utils/trpcClient.tsx index e44396cf..31a893ee 100644 --- a/apps/trialanderror.org/src/utils/trpcClient.tsx +++ b/apps/trialanderror.org/src/utils/trpcClient.tsx @@ -1,4 +1,5 @@ 'use client' + import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { httpBatchLink, loggerLink } from '@trpc/client' import { createTRPCReact } from '@trpc/react-query' @@ -31,7 +32,7 @@ function getBaseUrl() { return `http://localhost:${process.env.PORT ?? 3000}` } -export function ClientProvider(props: { children: React.ReactNode }) { +export function ClientProvider({ children }: { children: React.ReactNode }) { const [queryClient] = useState(() => new QueryClient()) const [trpcClient] = useState(() => trpc.createClient({ @@ -48,7 +49,7 @@ export function ClientProvider(props: { children: React.ReactNode }) { ) return ( - {props.children} + {children} ) }