Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21,334 changes: 21,310 additions & 24 deletions client/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"socket.io-client": "^4.0.1",
"web-vitals": "^1.1.1",
"worker-loader": "^3.0.8",
"yup": "^0.32.9"
Expand Down
3 changes: 3 additions & 0 deletions client/src/App/socket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import socketIOClient from 'socket.io-client';

export default socketIOClient('/');
5 changes: 5 additions & 0 deletions client/src/components/BookingForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import moment from 'moment';
import Image from '../common/Image';
import './style.css';
import bookingFormImage from '../../assets/images/undraw_Booking_re_gw4j.svg';
import socket from '../../App/socket';

const { Title } = Typography;

Expand Down Expand Up @@ -49,6 +50,10 @@ const BookingForm = () => {
appointmentTime: moment(appointmentTime).format('HH:mm:ss'),
complaints,
});
socket.emit(
'add appointment',
moment(appointmentDate).format('YYYY-MM-DD')
);
setSuccess(true);
setError(false);
setLoading(false);
Expand Down
10 changes: 10 additions & 0 deletions client/src/components/PatientSearchDateTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import moment from 'moment';
import { useLocation } from 'react-router-dom';
import { bool } from 'prop-types';
import { message } from 'antd';
import socketIOClient from 'socket.io-client';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repeated code
isn't it better to create a folder IO and export the functions from it

import CalendarSearch from '../CalendarSearch';
import PatientSearchTable from '../PatientSearchTable';

Expand Down Expand Up @@ -40,6 +41,15 @@ const PatientSearchDateTable = ({ showSearchBar }) => {
content: `Failed! ${errorMessage ? `${errorMessage}` : errorMessage}`,
});
};

useEffect(() => {
const socket = socketIOClient('/');
socket.on('updateAppointments', () => {
setUpdate((x) => !x);
});
return () => socket.disconnect();
}, []);

useEffect(() => {
const hideLoadingMessage = message.loading('Action in progress..', 0.5);
let unmounted = false;
Expand Down
Loading