Skip to content

Commit 882ce06

Browse files
committed
Updated react scheduler sample to latest version with typescript.
1 parent 6cf45d5 commit 882ce06

9 files changed

+119
-3
lines changed

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
{
2-
"name": "scheduling-dashboard",
2+
"name": "schedule-react",
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
66
"@syncfusion/ej2-react-schedule": "^27.1.53",
77
"@testing-library/jest-dom": "^5.17.0",
88
"@testing-library/react": "^13.4.0",
99
"@testing-library/user-event": "^13.5.0",
10+
"@types/jest": "^27.5.2",
11+
"@types/node": "^16.18.114",
12+
"@types/react": "^18.3.11",
13+
"@types/react-dom": "^18.3.1",
1014
"react": "^18.3.1",
1115
"react-dom": "^18.3.1",
1216
"react-scripts": "5.0.1",
17+
"typescript": "^4.9.5",
1318
"web-vitals": "^2.1.4"
1419
},
1520
"scripts": {

src/App.css

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
@import "../node_modules/@syncfusion/ej2-navigations/styles/bootstrap5.css";
88
@import "../node_modules/@syncfusion/ej2-popups/styles/bootstrap5.css";
99
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/bootstrap5.css";
10-
@import "../node_modules/@syncfusion/ej2-react-schedule/styles/bootstrap5.css";
11-
10+
@import "../node_modules/@syncfusion/ej2-react-schedule/styles/bootstrap5.css";

src/App.test.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import App from './App';
4+
5+
test('renders learn react link', () => {
6+
render(<App />);
7+
const linkElement = screen.getByText(/learn react/i);
8+
expect(linkElement).toBeInTheDocument();
9+
});

src/App.tsx

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import './App.css';
3+
import { ScheduleComponent, Day, Week, WorkWeek, Month, Agenda, Inject } from '@syncfusion/ej2-react-schedule';
4+
5+
function App() {
6+
const data = [
7+
{
8+
Id: 1,
9+
Subject: 'Paris',
10+
StartTime: new Date(2023, 1, 15, 10, 0),
11+
EndTime: new Date(2023, 1, 15, 12, 30),
12+
},
13+
{
14+
Id: 2,
15+
Subject: 'Germany',
16+
StartTime: new Date(2023, 1, 17, 12, 0),
17+
EndTime: new Date(2023, 1, 17, 13, 30),
18+
},
19+
{
20+
Id: 3,
21+
Subject: 'England',
22+
StartTime: new Date(2023, 1, 13, 9, 0),
23+
EndTime: new Date(2023, 1, 13, 11, 0),
24+
},
25+
];
26+
27+
const eventSettings = { dataSource: data }
28+
return (
29+
<div className="App">
30+
<ScheduleComponent height='550px' selectedDate={new Date(2023, 1, 15)} eventSettings={eventSettings}>
31+
<Inject services={[Day, Week, WorkWeek, Month, Agenda]} />
32+
</ScheduleComponent>
33+
</div>
34+
);
35+
}
36+
37+
export default App;

src/index.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom/client';
3+
import './index.css';
4+
import App from './App';
5+
import reportWebVitals from './reportWebVitals';
6+
7+
const root = ReactDOM.createRoot(
8+
document.getElementById('root') as HTMLElement
9+
);
10+
root.render(
11+
<React.StrictMode>
12+
<App />
13+
</React.StrictMode>
14+
);
15+
16+
// If you want to start measuring performance in your app, pass a function
17+
// to log results (for example: reportWebVitals(console.log))
18+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
19+
reportWebVitals();

src/react-app-env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="react-scripts" />

src/reportWebVitals.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ReportHandler } from 'web-vitals';
2+
3+
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
4+
if (onPerfEntry && onPerfEntry instanceof Function) {
5+
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
6+
getCLS(onPerfEntry);
7+
getFID(onPerfEntry);
8+
getFCP(onPerfEntry);
9+
getLCP(onPerfEntry);
10+
getTTFB(onPerfEntry);
11+
});
12+
}
13+
};
14+
15+
export default reportWebVitals;

src/setupTests.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// jest-dom adds custom jest matchers for asserting on DOM nodes.
2+
// allows you to do things like:
3+
// expect(element).toHaveTextContent(/react/i)
4+
// learn more: https://github.com/testing-library/jest-dom
5+
import '@testing-library/jest-dom';

tsconfig.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": [
5+
"dom",
6+
"dom.iterable",
7+
"esnext"
8+
],
9+
"allowJs": true,
10+
"skipLibCheck": true,
11+
"esModuleInterop": true,
12+
"allowSyntheticDefaultImports": true,
13+
"strict": true,
14+
"forceConsistentCasingInFileNames": true,
15+
"noFallthroughCasesInSwitch": true,
16+
"module": "esnext",
17+
"moduleResolution": "node",
18+
"resolveJsonModule": true,
19+
"isolatedModules": true,
20+
"noEmit": true,
21+
"jsx": "react-jsx"
22+
},
23+
"include": [
24+
"src"
25+
]
26+
}

0 commit comments

Comments
 (0)