Skip to content

Commit

Permalink
add a story for Edit emptyWhileLoading
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanMarmelab committed Sep 21, 2024
1 parent 60cbc3b commit 4514f75
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/ra-ui-materialui/src/detail/Edit.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,45 @@ export const Default = () => (
</Admin>
</TestMemoryRouter>
);

export const emptyWhileLoading = () => {
// getOne: () => new Promise(() => setTimeout(dataProvider.getOne, 1000)),
const customDataProvider = {
getOne: () =>
new Promise(resolve =>
setTimeout(
() =>
resolve({
data: {
id: 1,
title: 'War and Peace',
author: 'Leo Tolstoy',
summary:
"War and Peace broadly focuses on Napoleon's invasion of Russia, and the impact it had on Tsarist society. The book explores themes such as revolution, revolution and empire, the growth and decline of various states and the impact it had on their economies, culture, and society.",
year: 1869,
},
}),
2000
)
),
} as any;
return (
<TestMemoryRouter initialEntries={['/books/1/Edit']}>
<Admin dataProvider={customDataProvider}>
<Resource
name="books"
edit={() => (
<Edit emptyWhileLoading>
<SimpleForm>
<TextInput source="title" />
<TextInput source="author" />
<TextInput source="summary" />
<TextInput source="year" />
</SimpleForm>
</Edit>
)}
/>
</Admin>
</TestMemoryRouter>
);
};

0 comments on commit 4514f75

Please sign in to comment.