import React, { cloneElement } from 'react';
import { useListController } from 'prophet-core';
import { Spin, Drawer } from 'antd';
import { Route } from 'react-router';
import ListActions from './ListActions';
export const ListView = props => {
const {
children,
isLoading,
actions,
basePath,
create,
edit,
show,
destroyOnClose,
...other
} = props;
const handleClose = () => {
const { history, basePath } = props;
history.push(basePath);
};
const resource = {
hasEdit: !!edit,
hasCreate: !!create,
hasShow: !!show,
};
return (
{actions &&
cloneElement(actions, {
basePath,
...other,
...resource,
})}
{children &&
cloneElement(children, { basePath, ...other, ...resource })}
{({ match }) => {
const isMatch =
match && match.params && match.params.id !== 'create';
return edit ? (
{isMatch
? cloneElement(edit, {
id: match.params.id,
onCancel: handleClose,
onOk: handleClose,
...props,
})
: null}
) : null;
}}
{({ match }) => {
const isMatch =
match && match.params && match.params.id !== 'create';
return show ? (
{isMatch
? cloneElement(show, {
id: match.params.id,
onCancel: handleClose,
onOk: handleClose,
...props,
})
: null}
) : null;
}}
{({ match }) => {
return create ? (
{cloneElement(create, {
onCancel: handleClose,
onOk: handleClose,
...props,
})}
) : null;
}}
);
};
ListView.defaultProps = {
actions: ,
destroyOnClose: true,
};
export const ListDrawer = props => (
);
export default ListDrawer;