autumn-js
Version:
Autumn JS Library
37 lines (34 loc) • 803 B
JavaScript
"use client";
import {
useCustomerActions
} from "./chunk-JH5BXBEU.mjs";
import {
useQuery
} from "./chunk-FU6VEECB.mjs";
import {
useAutumnClient
} from "./chunk-SOA7GEAN.mjs";
// src/react/hooks/useCustomer.ts
var useCustomer = (params = {}) => {
const client = useAutumnClient({ caller: "useCustomer" });
const { errorOnNotFound, queryOptions, ...sdkParams } = params;
const queryResult = useQuery({
queryKey: ["autumn", "customer", sdkParams],
queryFn: () => client.getOrCreateCustomer({
...sdkParams,
...errorOnNotFound !== void 0 && { errorOnNotFound }
}),
...queryOptions
});
const actions = useCustomerActions({
client,
customer: queryResult.data ?? null
});
return {
...queryResult,
...actions
};
};
export {
useCustomer
};