refactor(react-hooks): enable stricter effect rules
Turn on react-hooks/set-state-in-effect and react-hooks/incompatible-library, then remove effect-driven local state sync patterns across affected pages. Keep behavior stable by deriving values from source state, remounting tab state by role key, and replacing useForm watch with useWatch.
This commit is contained in:
@@ -8,7 +8,7 @@ import { Button } from "@/components/ui/button"
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
|
||||
import { statusLabels } from "@/lib/constants"
|
||||
import type { OrderStatus } from "@/lib/types"
|
||||
import type { OrderStatus, UserRole } from "@/lib/types"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
import { useChatStore } from "@/store/chat"
|
||||
@@ -50,19 +50,19 @@ const ownerTabs = [
|
||||
]
|
||||
|
||||
export default function OrderListPage() {
|
||||
const [tab, setTab] = useState<TabFilter | "pending">("all")
|
||||
const { currentRole, user } = useAuthStore()
|
||||
const userId = user?.id ?? "u1"
|
||||
|
||||
return <OrderListContent key={currentRole} currentRole={currentRole} userId={userId} />
|
||||
}
|
||||
|
||||
function OrderListContent({ currentRole, userId }: { currentRole: UserRole; userId: string }) {
|
||||
const [tab, setTab] = useState<TabFilter | "pending">("all")
|
||||
const orders = useOrderStore((state) => state.orders)
|
||||
const sessions = useChatStore((state) => state.sessions)
|
||||
const ensureOrderSession = useChatStore((state) => state.ensureOrderSession)
|
||||
const userId = user?.id ?? "u1"
|
||||
const ownerShopId = "shop1"
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentRole) return
|
||||
setTab("all")
|
||||
}, [currentRole])
|
||||
|
||||
const tabs =
|
||||
currentRole === "consumer" ? consumerTabs : currentRole === "player" ? playerTabs : ownerTabs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user