autumn-js
Version:
Autumn JS Library
23 lines (20 loc) • 691 B
JavaScript
"use client";
// src/react/hooks/internal/check/customerToFeatures.ts
var customerToFeatures = ({
customer
}) => {
const balances = Object.values(customer.balances);
const flags = Object.values(customer.flags);
const customerStates = [...balances, ...flags];
if (customerStates.length === 0) return [];
const firstCustomerState = customerStates[0];
if (!firstCustomerState.feature) {
throw new Error(
"[customerToFeatures] please expand `balances.feature` or `flags.feature` to get features for the customer"
);
}
return customerStates.map((customerState) => customerState.feature).filter((feature) => Boolean(feature));
};
export {
customerToFeatures
};