Chunk out the different routers and clean up feature logic
This commit is contained in:
parent
04e97cc67e
commit
7197d28815
5 changed files with 54 additions and 32 deletions
19
resources/scripts/components/server/features/Features.tsx
Normal file
19
resources/scripts/components/server/features/Features.tsx
Normal file
|
@ -0,0 +1,19 @@
|
|||
import React, { useMemo } from 'react';
|
||||
import features from './index';
|
||||
import { getObjectKeys } from '@/helpers';
|
||||
|
||||
type ListItems = [ string, React.ComponentType ][];
|
||||
|
||||
export default ({ enabled }: { enabled: string[] }) => {
|
||||
const mapped: ListItems = useMemo(() => {
|
||||
return getObjectKeys(features)
|
||||
.filter(key => enabled.map((v) => v.toLowerCase()).includes(key.toLowerCase()))
|
||||
.reduce((arr, key) => [ ...arr, [ key, features[key] ] ], [] as ListItems);
|
||||
}, [ enabled ]);
|
||||
|
||||
return (
|
||||
<React.Suspense fallback={null}>
|
||||
{mapped.map(([ key, Component ]) => <Component key={key}/>)}
|
||||
</React.Suspense>
|
||||
);
|
||||
};
|
Reference in a new issue