Skip to content

Commit 42142ba

Browse files
committed
972599: To resolve Git Dependabot alerts
1 parent a544146 commit 42142ba

File tree

2 files changed

+45
-36
lines changed

2 files changed

+45
-36
lines changed

package.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"version": "0.0.0",
44
"private": true,
55
"dependencies": {
6-
"@syncfusion/ej2-base": "*",
7-
"@syncfusion/ej2-react-schedule": "*",
8-
"axios": "^0.21.1",
9-
"react": "17.0.0",
10-
"react-dom": "17.0.0"
6+
"@syncfusion/ej2-base": "^28.1.48",
7+
"@syncfusion/ej2-react-schedule": "^28.1.48",
8+
"axios": "^1.7.9",
9+
"react": "^17.0.2",
10+
"react-dom": "^17.0.2"
1111
},
1212
"scripts": {
1313
"start": "react-scripts start",
@@ -16,6 +16,18 @@
1616
"eject": "react-scripts eject"
1717
},
1818
"devDependencies": {
19-
"react-scripts": "latest"
19+
"react-scripts": "^5.0.1"
20+
},
21+
"browserslist": {
22+
"production": [
23+
">0.2%",
24+
"not dead",
25+
"not op_mini all"
26+
],
27+
"development": [
28+
"last 1 chrome version",
29+
"last 1 firefox version",
30+
"last 1 safari version"
31+
]
2032
}
2133
}

src/index.js

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,43 @@ import {
1717
} from '@syncfusion/ej2-react-schedule';
1818
import { SampleBase } from './sample-base';
1919
import axios from 'axios';
20+
import dataSource from './datasource.json';
2021
/**
2122
* Schedule Default sample
2223
*/
23-
export class Default extends SampleBase {
24-
constructor() {
25-
super(...arguments);
26-
this.flag = true;
27-
}
24+
export class Default extends SampleBase {
25+
constructor() {
26+
super(...arguments);
27+
this.data = dataSource.scheduleData;
28+
}
2829

2930
onBound(args) {
30-
if (this.flag) {
31-
axios.get('http://localhost:54738/Home/GetData').then(response => {
32-
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
33-
schObj.eventSettings.dataSource = response.data;
34-
});
35-
this.flag = false;
36-
}
31+
// Data is already loaded from local datasource.json
3732
}
3833

3934
onBegin(args) {
4035
if (args.requestType === 'eventCreate') {
41-
axios
42-
.post('http://localhost:54738/Home/Insert', args.data[0])
43-
.then(response => {
44-
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
45-
schObj.eventSettings.dataSource = response.data;
46-
});
36+
// Handle local data creation
37+
const newEvent = args.data[0];
38+
newEvent.Id = this.data.length + 1;
39+
this.data.push(newEvent);
40+
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
41+
schObj.eventSettings.dataSource = [...this.data];
4742
} else if (args.requestType === 'eventChange') {
48-
axios
49-
.post('http://localhost:54738/Home/Update', args.data)
50-
.then(response => {
51-
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
52-
schObj.eventSettings.dataSource = response.data;
53-
});
43+
// Handle local data update
44+
const updatedEvent = args.data;
45+
const index = this.data.findIndex(event => event.Id === updatedEvent.Id);
46+
if (index !== -1) {
47+
this.data[index] = updatedEvent;
48+
}
49+
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
50+
schObj.eventSettings.dataSource = [...this.data];
5451
} else if (args.requestType === 'eventRemove') {
55-
axios
56-
.post('http://localhost:54738/Home/Delete', args.data[0])
57-
.then(response => {
58-
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
59-
schObj.eventSettings.dataSource = response.data;
60-
});
52+
// Handle local data deletion
53+
const deletedEvent = args.data[0];
54+
this.data = this.data.filter(event => event.Id !== deletedEvent.Id);
55+
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
56+
schObj.eventSettings.dataSource = [...this.data];
6157
}
6258
}
6359
render() {
@@ -70,6 +66,7 @@ export class Default extends SampleBase {
7066
ref={schedule => (this.scheduleObj = schedule)}
7167
currentView="Month"
7268
selectedDate={new Date(2020, 5, 10)}
69+
eventSettings={{ dataSource: this.data }}
7370
dataBound={this.onBound.bind(this)}
7471
actionBegin={this.onBegin.bind(this)}
7572
>

0 commit comments

Comments
 (0)