mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Add endpoint to read firmware capabilities #1218
This commit is contained in:
@@ -5,28 +5,19 @@ import type { FC } from 'react';
|
||||
|
||||
import type { RequiredChildrenProps } from 'utils';
|
||||
import * as FeaturesApi from 'api/features';
|
||||
import { ApplicationError, LoadingSpinner } from 'components';
|
||||
|
||||
const FeaturesLoader: FC<RequiredChildrenProps> = (props) => {
|
||||
const { data: features, error } = useRequest(FeaturesApi.readFeatures);
|
||||
const { data: features } = useRequest(FeaturesApi.readFeatures);
|
||||
|
||||
if (features) {
|
||||
return (
|
||||
<FeaturesContext.Provider
|
||||
value={{
|
||||
features
|
||||
}}
|
||||
>
|
||||
{props.children}
|
||||
</FeaturesContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return <ApplicationError message={error?.message} />;
|
||||
}
|
||||
|
||||
return <LoadingSpinner height="100vh" />;
|
||||
return (
|
||||
<FeaturesContext.Provider
|
||||
value={{
|
||||
features
|
||||
}}
|
||||
>
|
||||
{props.children}
|
||||
</FeaturesContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export default FeaturesLoader;
|
||||
|
||||
Reference in New Issue
Block a user