Skip to content

Commit

Permalink
skip:build add demo
Browse files Browse the repository at this point in the history
for issue we are having
  • Loading branch information
oze4 committed Jul 13, 2021
1 parent 6ec1a47 commit 0f2a7e3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
57 changes: 57 additions & 0 deletions __tests__/demo/demo-components/EditableRowDateColumnIssue/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';
import MaterialTable from '../../../../src';

export default function EditableTable() {
const { useState } = React;

const [columns, setColumns] = useState([
{
title: 'Date',
field: 'date',
type: 'date',
dateSetting: { locale: 'en-US', format: 'MM/dd/yyyy' }
}
]);

const [data, setData] = useState([{ date: new Date() }]);

return (
<MaterialTable
title="Editable Preview"
columns={columns}
data={data}
editable={{
onRowAdd: (newData) =>
new Promise((resolve, reject) => {
setTimeout(() => {
setData([...data, newData]);

resolve();
}, 1000);
}),
onRowUpdate: (newData, oldData) =>
new Promise((resolve, reject) => {
setTimeout(() => {
const dataUpdate = [...data];
const index = oldData.tableData.id;
dataUpdate[index] = newData;
setData([...dataUpdate]);

resolve();
}, 1000);
}),
onRowDelete: (oldData) =>
new Promise((resolve, reject) => {
setTimeout(() => {
const dataDelete = [...data];
const index = oldData.tableData.id;
dataDelete.splice(index, 1);
setData([...dataDelete]);

resolve();
}, 1000);
})
}}
/>
);
}
2 changes: 2 additions & 0 deletions __tests__/demo/demo-components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { useState, useRef } from 'react';
import MaterialTable, { MTableBodyRow, MTableEditRow } from '../../../src'; // root of this project
// import { ExportCsv, ExportPdf } from '../../../exporters'; // root of this project

export { default as EditableRowDateColumnIssue } from './EditableRowDateColumnIssue';

const global_data = [
{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 }
Expand Down
6 changes: 5 additions & 1 deletion __tests__/demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ import {
EditableCells,
FrankensteinDemo,
HidingColumns,
Resizable
Resizable,
EditableRowDateColumnIssue
} from './demo-components';
import { I1353, I1941, I122 } from './demo-components/RemoteData';

module.hot.accept();

render(
<div>
<h1>EditableRowDateColumnIssue</h1>
<EditableRowDateColumnIssue />

<h1>Basic</h1>
<Basic />

Expand Down

0 comments on commit 0f2a7e3

Please sign in to comment.