From 95bbb198b5ee66e4b958d4a47850a0a6c654c842 Mon Sep 17 00:00:00 2001 From: kibin Date: Wed, 1 Apr 2026 07:54:27 +0000 Subject: [PATCH] feat(251): filter plan dropdown by billing type, hide archived plans --- app/(app)/clients/page.tsx | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/app/(app)/clients/page.tsx b/app/(app)/clients/page.tsx index 06e3494..2d26890 100644 --- a/app/(app)/clients/page.tsx +++ b/app/(app)/clients/page.tsx @@ -53,11 +53,21 @@ export default function ClientsPage() { queryFn: async () => { const r = await api.get("/api/v1/areas"); return r.data; }, }); - const { data: plans = [] } = useQuery({ - queryKey: ["plans"], - queryFn: async () => { const r = await api.get("/api/v1/plans"); return Array.isArray(r.data) ? r.data : (r.data as any).data ?? []; }, + // Fetch only active plans, filter client-side by billing type + const { data: allActivePlans = [] } = useQuery<(Plan & { type: string; isActive: boolean })[]>({ + queryKey: ["plans", "active"], + queryFn: async () => { + const r = await api.get("/api/v1/plans?isActive=true"); + const raw = Array.isArray(r.data) ? r.data : (r.data as any).data ?? []; + return raw; + }, }); + // Filter plans by selected billing type + const filteredPlans = allActivePlans.filter(p => + !form.billingType || p.type === form.billingType + ); + const createClient = useMutation({ mutationFn: async () => { const res = await api.post("/api/v1/clients", { @@ -186,10 +196,11 @@ export default function ClientsPage() {
+

Plan list filters to match this type

@@ -197,8 +208,11 @@ export default function ClientsPage() { + {filteredPlans.length === 0 && form.billingType && ( +

No active {form.billingType.toLowerCase()} plans available.

+ )}