Skip to content

Commit 29a51e4

Browse files
committed
generate reactjs demos
1 parent 2061f33 commit 29a51e4

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

apps/demos/Demos/Scheduler/CellTemplates/ReactJs/TimeCell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const TimeCell = (props) => {
66
const isDinner = Utils.isDinner(date);
77
const hasCoffeeCupIcon = Utils.hasCoffeeCupIcon(date);
88
return (
9-
<div className={isDinner ? 'dinner' : null}>
9+
<div className={isDinner ? 'dinner' : undefined}>
1010
{text}
1111
{hasCoffeeCupIcon && <div className="cafe" />}
1212
</div>

apps/demos/Demos/Scheduler/CellTemplates/ReactJs/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export default class Utils {
2727
}
2828

2929
static isValidAppointment(component, appointmentData) {
30-
const startDate = new Date(appointmentData.startDate);
31-
const endDate = new Date(appointmentData.endDate);
32-
const cellDuration = component.option('cellDuration');
30+
const startDate = appointmentData.startDate ? new Date(appointmentData.startDate) : new Date();
31+
const endDate = appointmentData.endDate ? new Date(appointmentData.endDate) : new Date();
32+
const cellDuration = Number(component.option('cellDuration'));
3333
return Utils.isValidAppointmentInterval(startDate, endDate, cellDuration);
3434
}
3535

apps/demos/Demos/Scheduler/ContextMenu/ReactJs/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const views = ['day', 'month'];
88
const appointmentClassName = '.dx-scheduler-appointment';
99
const cellClassName = '.dx-scheduler-date-table-cell';
1010
const onContextMenuItemClick = (e) => {
11-
e.itemData.onItemClick?.(e);
11+
e.itemData?.onItemClick?.(e);
1212
};
1313
const App = () => {
1414
const schedulerRef = useRef(null);
@@ -26,7 +26,7 @@ const App = () => {
2626
onItemClick: (e) =>
2727
scheduler?.updateAppointment(appointmentData, {
2828
...appointmentData,
29-
...{ roomId: [e.itemData.id] },
29+
...{ roomId: [e.itemData?.id] },
3030
}),
3131
}));
3232
setTarget(appointmentClassName);

apps/demos/Demos/Scheduler/Editing/ReactJs/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ const showToast = (event, value, type) => {
1010
notify(`${event} "${value}" task`, type, 800);
1111
};
1212
const showAddedToast = (e) => {
13-
showToast('Added', e.appointmentData.text, 'success');
13+
showToast('Added', e.appointmentData.text ?? '', 'success');
1414
};
1515
const showUpdatedToast = (e) => {
16-
showToast('Updated', e.appointmentData.text, 'info');
16+
showToast('Updated', e.appointmentData.text ?? '', 'info');
1717
};
1818
const showDeletedToast = (e) => {
19-
showToast('Deleted', e.appointmentData.text, 'warning');
19+
showToast('Deleted', e.appointmentData.text ?? '', 'warning');
2020
};
2121
const App = () => {
2222
const [allowAdding, setAllowAdding] = useState(true);

apps/demos/Demos/Scheduler/Templates/ReactJs/App.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ const App = () => {
4343
);
4444
const updateEndDate = useCallback((movie) => {
4545
const form = formInstanceRef.current;
46-
const formData = form.option('formData');
46+
const formData = form?.option('formData');
4747
const { startDate } = formData;
4848
if (startDate) {
4949
const newEndDate = new Date(startDate.getTime() + 60 * 1000 * movie.duration);
50-
form.updateData('endDate', newEndDate);
50+
form?.updateData('endDate', newEndDate);
5151
}
5252
}, []);
5353
const onFormInitialized = useCallback(
5454
(e) => {
5555
const form = e.component;
56-
formInstanceRef.current = form;
57-
form.on('fieldDataChanged', (fieldEvent) => {
56+
form && (formInstanceRef.current = form);
57+
form?.on('fieldDataChanged', (fieldEvent) => {
5858
if (fieldEvent.dataField === 'startDate') {
59-
const currentFormData = form.option('formData');
59+
const currentFormData = form?.option('formData');
6060
const movie = getMovieById(currentFormData.movieId);
6161
if (movie) {
6262
updateEndDate(movie);
@@ -71,7 +71,7 @@ const App = () => {
7171
const form = formInstanceRef.current;
7272
const movie = getMovieById(e.value);
7373
if (movie) {
74-
form.updateData('director', movie.director);
74+
form?.updateData('director', movie.director);
7575
updateEndDate(movie);
7676
}
7777
},

apps/demos/Demos/Scheduler/Templates/ReactJs/MovieInfoContainer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const MovieInfoContainer = ({ formInstanceRef }) => {
88
const [movie, setMovie] = useState(null);
99
useEffect(() => {
1010
const form = formInstanceRef.current;
11-
const formData = form.option('formData');
11+
const formData = form?.option('formData');
1212
const currentMovie = getMovieById(formData.movieId);
1313
setMovie(currentMovie);
1414
const handleFieldDataChanged = (e) => {
@@ -17,9 +17,9 @@ const MovieInfoContainer = ({ formInstanceRef }) => {
1717
setMovie(updatedMovie);
1818
}
1919
};
20-
form.on('fieldDataChanged', handleFieldDataChanged);
20+
form?.on('fieldDataChanged', handleFieldDataChanged);
2121
return () => {
22-
form.off('fieldDataChanged', handleFieldDataChanged);
22+
form?.off('fieldDataChanged', handleFieldDataChanged);
2323
};
2424
}, [formInstanceRef]);
2525
return (

apps/demos/Demos/Scheduler/Toolbar/ReactJs/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const App = () => {
4646
return;
4747
}
4848
const currentDate = scheduler.option('currentDate');
49-
const cellDuration = scheduler.option('cellDuration');
49+
const cellDuration = Number(scheduler.option('cellDuration'));
5050
const cellDurationMs = cellDuration * MS_IN_HOUR;
5151
const currentTime = new Date(currentDate).getTime();
5252
const roundTime = Math.round(currentTime / cellDurationMs) * cellDurationMs;

0 commit comments

Comments
 (0)