Enhancement: Expose getFeature() method for useLicenseLimits hooks

This commit is contained in:
Gustav Hansen 2023-07-05 12:31:02 +02:00
parent 85f4c892e0
commit f4720e22db

View File

@ -1,3 +1,5 @@
import * as React from 'react';
import { useFetchClient, useRBAC } from '@strapi/helper-plugin';
import { useQuery } from 'react-query';
import { useSelector } from 'react-redux';
@ -27,5 +29,16 @@ export function useLicenseLimits() {
}
);
return { license: data ?? {}, isError, isLoading };
const license = data ?? {};
const getFeature = React.useCallback(
(name) => {
const feature = (license?.features ?? []).find((feature) => feature.name === name);
return feature?.options ?? {};
},
[license?.features]
);
return { license, getFeature, isError, isLoading };
}