Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import simpleRestProvider from 'ra-data-simple-rest';
const restProvider = simpleRestProvider('http://localhost:4000');
const delayedDataProvider = new Proxy(restProvider, {
get: (target, name, self) =>
name === 'then' // as we await for the dataProvider, JS calls then on it. We must trap that call or else the dataProvider will be called with the then method
? self
: (resource, params) =>
new Promise(resolve =>
setTimeout(
() => resolve(restProvider[name](resource, params)),
500
)
),
});
export default delayedDataProvider;
import simpleRestProvider from 'ra-data-simple-rest';
const restProvider = simpleRestProvider('http://localhost:4000');
export default (type, resource, params) =>
new Promise(resolve =>
setTimeout(() => resolve(restProvider(type, resource, params)), 500)
);
import { englishMessages } from "./i18n/en";
import { chineseMessages } from "./i18n/cn";
import { fakeServer } from "./fakeServer";
import { CustomerList, CustomerEdit, CustomerCreate, CustomerIcon } from "./customers";
import { CommandList, CommandIcon, CommandEdit } from "./commands";
import { ProductList, ProductCreate, ProductEdit, ProductIcon } from "./products";
import { Segments, SegmentsIcon } from "./segments";
import { CategoryList, CategoryIcon, CategoryEdit } from "./categories";
import { ReviewIcon, ReviewList, ReviewEdit } from "./reviews";
import { Menu } from "./Menu";
import { customRoutes } from "./routes";
import { sagas } from "./sagas";
import { themeReducer } from "./themeReducer";
import { AppLayout } from "./Layout";
const dataProvider = simpleRestProvider("http://api.fakeserver.com");
const messages = {
cn: chineseMessages,
en: englishMessages,
};
const i18nProvider = (locale: string) => messages[locale];
export class App extends React.Component {
public componentWillMount() {
fakeServer();
}
public render() {
return (