import * as React from 'react'; import { isValidElement } from 'react'; import { Route, Routes } from 'react-router-dom'; import { ResourceProps } from '../types'; import { ResourceContextProvider } from './ResourceContextProvider'; export const Resource = (props: ResourceProps) => { const { create: Create, edit: Edit, list: List, name, show: Show } = props; return ( {Create && ( } /> )} {Show && ( } /> )} {Edit && ( } /> )} {List && ( } /> )} {props.children} ); }; Resource.raName = 'Resource'; Resource.registerResource = ({ create, edit, icon, list, name, options, show, recordRepresentation, hasCreate, hasEdit, hasShow, }: ResourceProps) => ({ name, options, hasList: !!list, hasCreate: !!create || !!hasCreate, hasEdit: !!edit || !!hasEdit, hasShow: !!show || !!hasShow, icon, recordRepresentation, });