From 88c1fa5b9e165ed2267779183adcc01a30bdda5a Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 25 Sep 2022 12:58:22 +0300 Subject: [PATCH] Refactor BuildCard to take attributes in one obj --- app/components/BuildCard.tsx | 58 ++++++++++++----------- app/routes/builds/$slug.tsx | 15 +----- app/routes/u.$identifier/builds/index.tsx | 15 +----- 3 files changed, 32 insertions(+), 56 deletions(-) diff --git a/app/components/BuildCard.tsx b/app/components/BuildCard.tsx index 55a2dadc9..ce769e244 100644 --- a/app/components/BuildCard.tsx +++ b/app/components/BuildCard.tsx @@ -16,41 +16,43 @@ import { FormWithConfirm } from "./FormWithConfirm"; import { Image } from "./Image"; import { Popover } from "./Popover"; -type BuildProps = Pick< - Build, - | "id" - | "title" - | "description" - | "clothesGearSplId" - | "headGearSplId" - | "shoesGearSplId" - | "updatedAt" - | "modes" -> & { - abilities: BuildAbilitiesTuple; - modes: ModeShort[] | null; - weapons: Array; +interface BuildProps { + build: Pick< + Build, + | "id" + | "title" + | "description" + | "clothesGearSplId" + | "headGearSplId" + | "shoesGearSplId" + | "updatedAt" + > & { + abilities: BuildAbilitiesTuple; + modes: ModeShort[] | null; + weapons: Array; + }; canEdit?: boolean; -}; +} -export function BuildCard({ - id, - title, - description, - weapons, - updatedAt, - headGearSplId, - clothesGearSplId, - shoesGearSplId, - abilities, - modes, - canEdit = false, -}: BuildProps) { +export function BuildCard({ build, canEdit = false }: BuildProps) { const user = useUser(); const { t } = useTranslation(["weapons", "builds", "common"]); const { i18n } = useTranslation(); const isMounted = useIsMounted(); + const { + id, + title, + description, + clothesGearSplId, + headGearSplId, + shoesGearSplId, + updatedAt, + abilities, + modes, + weapons, + } = build; + const bottomRowItems = [ description && ( {data.builds.map((build) => ( - + ))} ); diff --git a/app/routes/u.$identifier/builds/index.tsx b/app/routes/u.$identifier/builds/index.tsx index 2f95112d9..a6f4c131b 100644 --- a/app/routes/u.$identifier/builds/index.tsx +++ b/app/routes/u.$identifier/builds/index.tsx @@ -76,20 +76,7 @@ export default function UserBuildsPage() { {data.builds.length > 0 ? (
{data.builds.map((build) => ( - + ))}
) : (