From 02538836a9f2a4d95aa58079f0c205d10381bb9a Mon Sep 17 00:00:00 2001 From: Amruth Pillai Date: Sat, 4 Jul 2026 21:47:22 +0200 Subject: [PATCH] =?UTF-8?q?refactor(web):=20finding=205=20=E2=80=94=20repl?= =?UTF-8?q?ace=20match(boolean)=20with=20ternary=20+=20ActionButton=20wrap?= =?UTF-8?q?per?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three auth-settings components (password, two-factor, social-provider) each duplicated an identical m.div hover/tap wrapper for both branches of match(boolean). Extracted one ActionButton wrapper and replaced match with a plain ternary; removed ts-pattern imports. Claude-Session: https://claude.ai/code/session_012Bnvt1MghwHj4qQRxuQUGa --- .../authentication/components/password.tsx | 66 +++++++++---------- .../components/social-provider.tsx | 60 ++++++++--------- .../authentication/components/two-factor.tsx | 50 +++++++------- 3 files changed, 86 insertions(+), 90 deletions(-) diff --git a/apps/web/src/features/settings/authentication/components/password.tsx b/apps/web/src/features/settings/authentication/components/password.tsx index 73f90406c..fc6628011 100644 --- a/apps/web/src/features/settings/authentication/components/password.tsx +++ b/apps/web/src/features/settings/authentication/components/password.tsx @@ -3,11 +3,24 @@ import { PasswordIcon, PencilSimpleLineIcon } from "@phosphor-icons/react"; import { Link, useNavigate } from "@tanstack/react-router"; import { m } from "motion/react"; import { useCallback } from "react"; -import { match } from "ts-pattern"; import { Button } from "@reactive-resume/ui/components/button"; import { useDialogStore } from "@/dialogs/store"; import { useAuthAccounts } from "./hooks"; +// ponytail: m.div wrapper is identical for both branches — extracted, match(boolean) removed +function ActionButton({ children }: { children: React.ReactNode }) { + return ( + + {children} + + ); +} + export function PasswordSection() { const navigate = useNavigate(); const { openDialog } = useDialogStore(); @@ -35,39 +48,24 @@ export function PasswordSection() { Password - {match(hasPassword) - .with(true, () => ( - - - - )) - .with(false, () => ( - - + ) : ( + - - )) - .with(false, () => ( - - - - )) - .exhaustive()} + + {isConnected ? ( + + ) : ( + + )} + ); diff --git a/apps/web/src/features/settings/authentication/components/two-factor.tsx b/apps/web/src/features/settings/authentication/components/two-factor.tsx index c534783e2..a977586a6 100644 --- a/apps/web/src/features/settings/authentication/components/two-factor.tsx +++ b/apps/web/src/features/settings/authentication/components/two-factor.tsx @@ -2,13 +2,26 @@ import { Trans } from "@lingui/react/macro"; import { KeyIcon, LockOpenIcon, ToggleLeftIcon, ToggleRightIcon } from "@phosphor-icons/react"; import { m } from "motion/react"; import { useCallback } from "react"; -import { match } from "ts-pattern"; import { Button } from "@reactive-resume/ui/components/button"; import { Separator } from "@reactive-resume/ui/components/separator"; import { useDialogStore } from "@/dialogs/store"; import { authClient } from "@/libs/auth/client"; import { useAuthAccounts } from "./hooks"; +// ponytail: shared hover/tap wrapper — identical in both branches, match(boolean) removed +function ActionButton({ children }: { children: React.ReactNode }) { + return ( + + {children} + + ); +} + export function TwoFactorSection() { const { openDialog } = useDialogStore(); const { hasAccount } = useAuthAccounts(); @@ -42,34 +55,21 @@ export function TwoFactorSection() { Two-Factor Authentication - {match(hasTwoFactor) - .with(true, () => ( - - - - )) - .with(false, () => ( - - - - )) - .exhaustive()} + + )} + + );