From b2008f693fc4e1d7da4eb7dd84d2cf4c42617436 Mon Sep 17 00:00:00 2001 From: Mahen Date: Tue, 17 Feb 2026 15:33:41 +0700 Subject: [PATCH] refactor: separate profile set state --- src/components/dashboards/ProfileCard.tsx | 19 +++++++++++------- src/hooks/useProfileClient.ts | 24 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 src/hooks/useProfileClient.ts diff --git a/src/components/dashboards/ProfileCard.tsx b/src/components/dashboards/ProfileCard.tsx index bedb244..178bb3c 100644 --- a/src/components/dashboards/ProfileCard.tsx +++ b/src/components/dashboards/ProfileCard.tsx @@ -15,11 +15,9 @@ import { Save, } from "lucide-react"; import { ProfileClientProps } from "@/src/types"; -import { useSession } from "next-auth/react"; import { Button } from "../ui/button"; import { Separator } from "../ui/separator"; import { brandFormat, formatRupiah } from "@/src/utils/datas"; -import { useState } from "react"; import { Select, SelectContent, @@ -30,6 +28,7 @@ import { import { brandItems, OSItems, professionItems } from "@/src/utils/const"; import { Input } from "../ui/input"; import { Label } from "../ui/label"; +import { useProfileClient } from "@/src/hooks/useProfileClient"; export default function ProfileCard({ bio, @@ -38,12 +37,18 @@ export default function ProfileCard({ budgetMax, budgetMin, }: ProfileClientProps) { - const session = useSession(); const { brands } = brandFormat({ preferenceBrand }); - const [showModal, setShowModal] = useState(false); - const [profession, setProfession] = useState(""); - const [brand, setBrand] = useState(""); - const [OS, setOS] = useState(""); + const { + session, + showModal, + profession, + brand, + OS, + setShowModal, + setProfession, + setBrand, + setOS, + } = useProfileClient(); return ( { + const session = useSession(); + const [showModal, setShowModal] = useState(false); + const [profession, setProfession] = useState(""); + const [brand, setBrand] = useState(""); + const [OS, setOS] = useState(""); + + return { + session, + showModal, + profession, + brand, + OS, + setShowModal, + setProfession, + setBrand, + setOS, + }; +};