{"version":3,"file":"use-account-CtG0WxiP.mjs","names":[],"sources":["../src/account/query-keys.ts","../src/hooks/use-account.ts"],"sourcesContent":["export const accountKeys = {\n  all: [\"portalTenant\", \"account\"] as const,\n  detail: (userId?: number) => [...accountKeys.all, userId] as const,\n} as const;\n\nexport const storeKeys = {\n  countries: (languageIso?: string) =>\n    languageIso\n      ? ([\"bff-store-countries\", languageIso] as const)\n      : ([\"bff-store-countries\"] as const),\n  languages: () => [\"bff-store-languages\"] as const,\n} as const;\n\nexport const payKeys = {\n  addresses: {\n    all: [\"portalTenant\", \"addresses\"] as const,\n    list: (userId?: number) => [...payKeys.addresses.all, userId] as const,\n  },\n  paymentMethods: {\n    all: [\"portalTenant\", \"paymentMethods\"] as const,\n    list: (userId?: number) => [...payKeys.paymentMethods.all, userId] as const,\n  },\n  pointsLedgers: {\n    all: [\"portalTenant\", \"pointsLedgers\"] as const,\n    list: (userId?: number) => [...payKeys.pointsLedgers.all, userId] as const,\n  },\n} as const;\n","import {\n  useQuery,\n  type QueryClient,\n  type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport { useAccountApi } from \"@fluid-app/portal-core/account-api-context\";\nimport type { AccountRep } from \"@fluid-app/portal-core/account-types\";\nimport { accountKeys } from \"../account/query-keys\";\n\n/**\n * Fetches the current user's account from GET /api/account.\n * Replaces the old useCurrentUser (which called non-existent /api/me).\n */\nexport function useAccount(): UseQueryResult<AccountRep> {\n  const api = useAccountApi();\n\n  return useQuery({\n    queryKey: accountKeys.detail(),\n    queryFn: async () => {\n      const response = await api.fetchAccount();\n      return response.account;\n    },\n    staleTime: 5 * 60 * 1000,\n  });\n}\n\n/**\n * Refresh the cached account. A member's public MySite URL is served on this\n * payload, so anything that renames their slug has to refresh it here as well\n * as on the MySite profile entry, or readers keep the old URL for the five\n * minutes this query stays fresh.\n */\nexport function refreshAccount(queryClient: QueryClient): Promise<void> {\n  return queryClient.invalidateQueries({ queryKey: accountKeys.all });\n}\n"],"mappings":";;;AAAA,MAAa,cAAc;CACzB,KAAK,CAAC,gBAAgB,UAAU;CAChC,SAAS,WAAoB,CAAC,GAAG,YAAY,KAAK,OAAO;CAC1D;AAED,MAAa,YAAY;CACvB,YAAY,gBACV,cACK,CAAC,uBAAuB,YAAY,GACpC,CAAC,sBAAsB;CAC9B,iBAAiB,CAAC,sBAAsB;CACzC;AAED,MAAa,UAAU;CACrB,WAAW;EACT,KAAK,CAAC,gBAAgB,YAAY;EAClC,OAAO,WAAoB,CAAC,GAAG,QAAQ,UAAU,KAAK,OAAO;EAC9D;CACD,gBAAgB;EACd,KAAK,CAAC,gBAAgB,iBAAiB;EACvC,OAAO,WAAoB,CAAC,GAAG,QAAQ,eAAe,KAAK,OAAO;EACnE;CACD,eAAe;EACb,KAAK,CAAC,gBAAgB,gBAAgB;EACtC,OAAO,WAAoB,CAAC,GAAG,QAAQ,cAAc,KAAK,OAAO;EAClE;CACF;;;;;;;ACbD,SAAgB,aAAyC;CACvD,MAAM,MAAM,eAAe;AAE3B,QAAO,SAAS;EACd,UAAU,YAAY,QAAQ;EAC9B,SAAS,YAAY;AAEnB,WADiB,MAAM,IAAI,cAAc,EACzB;;EAElB,WAAW,MAAS;EACrB,CAAC;;;;;;;;AASJ,SAAgB,eAAe,aAAyC;AACtE,QAAO,YAAY,kBAAkB,EAAE,UAAU,YAAY,KAAK,CAAC"}