refactor: separate profile set state

This commit is contained in:
Mahen 2026-02-17 15:33:41 +07:00
parent 06fae9ca91
commit b2008f693f
2 changed files with 36 additions and 7 deletions

View File

@ -15,11 +15,9 @@ import {
Save, Save,
} from "lucide-react"; } from "lucide-react";
import { ProfileClientProps } from "@/src/types"; import { ProfileClientProps } from "@/src/types";
import { useSession } from "next-auth/react";
import { Button } from "../ui/button"; import { Button } from "../ui/button";
import { Separator } from "../ui/separator"; import { Separator } from "../ui/separator";
import { brandFormat, formatRupiah } from "@/src/utils/datas"; import { brandFormat, formatRupiah } from "@/src/utils/datas";
import { useState } from "react";
import { import {
Select, Select,
SelectContent, SelectContent,
@ -30,6 +28,7 @@ import {
import { brandItems, OSItems, professionItems } from "@/src/utils/const"; import { brandItems, OSItems, professionItems } from "@/src/utils/const";
import { Input } from "../ui/input"; import { Input } from "../ui/input";
import { Label } from "../ui/label"; import { Label } from "../ui/label";
import { useProfileClient } from "@/src/hooks/useProfileClient";
export default function ProfileCard({ export default function ProfileCard({
bio, bio,
@ -38,12 +37,18 @@ export default function ProfileCard({
budgetMax, budgetMax,
budgetMin, budgetMin,
}: ProfileClientProps) { }: ProfileClientProps) {
const session = useSession();
const { brands } = brandFormat({ preferenceBrand }); const { brands } = brandFormat({ preferenceBrand });
const [showModal, setShowModal] = useState(false); const {
const [profession, setProfession] = useState(""); session,
const [brand, setBrand] = useState(""); showModal,
const [OS, setOS] = useState(""); profession,
brand,
OS,
setShowModal,
setProfession,
setBrand,
setOS,
} = useProfileClient();
return ( return (
<motion.div <motion.div

View File

@ -0,0 +1,24 @@
"use client";
import { useSession } from "next-auth/react";
import { useState } from "react";
export const useProfileClient = () => {
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,
};
};