@greatapps/common 1.1.569 → 1.1.570
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/plans/hooks/use-plan-by-id.hook.ts"],"sourcesContent":["\"use client\";\n\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { withAction } from \"../../../utils/withAction\";\nimport { findPlanByIdAction } from \"../actions/find-plan-by-id.action\";\nimport type { Plan } from \"../types/plan.type\";\nimport { PLANS_QUERY_KEY } from \"./list-plans.hook\";\nimport { useWlQueryKey } from \"../../../hooks/useAuthQueryKey\";\n\nexport function usePlanById(idPlan
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/hooks/use-plan-by-id.hook.ts"],"sourcesContent":["\"use client\";\n\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { withAction } from \"../../../utils/withAction\";\nimport { findPlanByIdAction } from \"../actions/find-plan-by-id.action\";\nimport type { Plan } from \"../types/plan.type\";\nimport { PLANS_QUERY_KEY } from \"./list-plans.hook\";\nimport { useWlQueryKey } from \"../../../hooks/useAuthQueryKey\";\n\nexport function usePlanById(idPlan?: number | string | null) {\n const queryClient = useQueryClient();\n const plansKey = useWlQueryKey([...PLANS_QUERY_KEY]);\n\n return useQuery({\n queryKey: [...plansKey, idPlan],\n queryFn: withAction(() => findPlanByIdAction(idPlan!)),\n initialData: () => {\n const queries = queryClient.getQueriesData<Plan[]>({\n queryKey: plansKey,\n });\n\n for (const [, data] of queries) {\n if (!data || !Array.isArray(data)) continue;\n const numericId = Number(idPlan);\n const plan = data.find(\n (p) => p.id === numericId || p.id_plan === numericId\n );\n if (plan) {\n return { success: true as const, data: plan };\n }\n }\n\n return undefined;\n },\n initialDataUpdatedAt: 0,\n enabled: !!idPlan,\n });\n}\n"],"mappings":";AAEA,SAAS,UAAU,sBAAsB;AACzC,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AAEnC,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAEvB,SAAS,YAAY,QAAiC;AAC3D,QAAM,cAAc,eAAe;AACnC,QAAM,WAAW,cAAc,CAAC,GAAG,eAAe,CAAC;AAEnD,SAAO,SAAS;AAAA,IACd,UAAU,CAAC,GAAG,UAAU,MAAM;AAAA,IAC9B,SAAS,WAAW,MAAM,mBAAmB,MAAO,CAAC;AAAA,IACrD,aAAa,MAAM;AACjB,YAAM,UAAU,YAAY,eAAuB;AAAA,QACjD,UAAU;AAAA,MACZ,CAAC;AAED,iBAAW,CAAC,EAAE,IAAI,KAAK,SAAS;AAC9B,YAAI,CAAC,QAAQ,CAAC,MAAM,QAAQ,IAAI,EAAG;AACnC,cAAM,YAAY,OAAO,MAAM;AAC/B,cAAM,OAAO,KAAK;AAAA,UAChB,CAAC,MAAM,EAAE,OAAO,aAAa,EAAE,YAAY;AAAA,QAC7C;AACA,YAAI,MAAM;AACR,iBAAO,EAAE,SAAS,MAAe,MAAM,KAAK;AAAA,QAC9C;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,IACA,sBAAsB;AAAA,IACtB,SAAS,CAAC,CAAC;AAAA,EACb,CAAC;AACH;","names":[]}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import type { Plan } from "../types/plan.type";
|
|
|
7
7
|
import { PLANS_QUERY_KEY } from "./list-plans.hook";
|
|
8
8
|
import { useWlQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
9
9
|
|
|
10
|
-
export function usePlanById(idPlan
|
|
10
|
+
export function usePlanById(idPlan?: number | string | null) {
|
|
11
11
|
const queryClient = useQueryClient();
|
|
12
12
|
const plansKey = useWlQueryKey([...PLANS_QUERY_KEY]);
|
|
13
13
|
|