diff --git a/package-lock.json b/package-lock.json index aa99337d8d6..a0fee9a566c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -115,6 +115,7 @@ "apps/care_livekit_fe": { "name": "care-livekit", "version": "0.0.1", + "extraneous": true, "license": "ISC", "dependencies": { "@livekit/components-react": "^2.6.2", @@ -1779,11 +1780,6 @@ "node": ">=6.9.0" } }, - "node_modules/@bufbuild/protobuf": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.10.0.tgz", - "integrity": "sha512-QDdVFLoN93Zjg36NoQPZfsVH9tZew7wKDKyV5qRdj8ntT4wQCOradQjRaTdwMhWUYsgKsvCINKKm87FdEk96Ag==" - }, "node_modules/@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -2647,64 +2643,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@livekit/components-core": { - "version": "0.11.9", - "resolved": "https://registry.npmjs.org/@livekit/components-core/-/components-core-0.11.9.tgz", - "integrity": "sha512-LPE1BZ+YTaqsVqGy/GAlpiO5rEI8XpEaf1TQcGdZN1BCBas9hTHt7/aHMbHQJ0K5xuAFQx8is6dFe451T4qXIQ==", - "dependencies": { - "@floating-ui/dom": "1.6.11", - "loglevel": "1.9.1", - "rxjs": "7.8.1" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "livekit-client": "^2.5.7", - "tslib": "^2.6.2" - } - }, - "node_modules/@livekit/components-react": { - "version": "2.6.5", - "resolved": "https://registry.npmjs.org/@livekit/components-react/-/components-react-2.6.5.tgz", - "integrity": "sha512-G3BpBlKy+lWTV9MH3/oBTBC17Z8CWqZ9GnjcG/xmYI0IvqmY89tVWph7cj2Bq0taniA+mD3U9EMPr68fOb1m1g==", - "dependencies": { - "@livekit/components-core": "0.11.9", - "clsx": "2.1.1", - "usehooks-ts": "3.1.0" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "@livekit/krisp-noise-filter": "^0.2.12", - "livekit-client": "^2.5.7", - "react": ">=18", - "react-dom": ">=18", - "tslib": "^2.6.2" - }, - "peerDependenciesMeta": { - "@livekit/krisp-noise-filter": { - "optional": true - } - } - }, - "node_modules/@livekit/components-styles": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@livekit/components-styles/-/components-styles-1.1.4.tgz", - "integrity": "sha512-QCupn7tQ/dy/WZclrfsgtDe8peiGYS6Ied1IGkKOysaXo04l90t62SIUTKyxgd0dNDhUDC0p34qCggGZs/44lQ==", - "engines": { - "node": ">=18" - } - }, - "node_modules/@livekit/protocol": { - "version": "1.24.0", - "resolved": "https://registry.npmjs.org/@livekit/protocol/-/protocol-1.24.0.tgz", - "integrity": "sha512-9dCsqnkMn7lvbI4NGh18zhLDsrXyUcpS++TEFgEk5Xv1WM3R2kT3EzqgL1P/mr3jaabM6rJ8wZA/KJLuQNpF5w==", - "dependencies": { - "@bufbuild/protobuf": "^1.10.0" - } - }, "node_modules/@mapbox/node-pre-gyp": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz", @@ -6195,10 +6133,6 @@ "node": ">=6" } }, - "node_modules/care-livekit": { - "resolved": "apps/care_livekit_fe", - "link": true - }, "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -10932,26 +10866,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/livekit-client": { - "version": "2.5.9", - "resolved": "https://registry.npmjs.org/livekit-client/-/livekit-client-2.5.9.tgz", - "integrity": "sha512-oDpK6SKYB1F+mNO+25DA0bF0cD2XoOJeD8ji4YQpzDBQv2IxeyKrQhoqXAqrYgIKuiMNkImSf+yg2v7EHSl4Og==", - "dependencies": { - "@livekit/protocol": "1.24.0", - "events": "^3.3.0", - "loglevel": "^1.8.0", - "sdp-transform": "^2.14.1", - "ts-debounce": "^4.0.0", - "tslib": "2.7.0", - "typed-emitter": "^2.1.0", - "webrtc-adapter": "^9.0.0" - } - }, - "node_modules/livekit-client/node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" - }, "node_modules/load-plugin": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/load-plugin/-/load-plugin-6.0.3.tgz", @@ -11052,7 +10966,8 @@ "node_modules/lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==" + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true }, "node_modules/lodash.isplainobject": { "version": "4.0.6", @@ -11138,18 +11053,6 @@ "node": ">=8" } }, - "node_modules/loglevel": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.1.tgz", - "integrity": "sha512-hP3I3kCrDIMuRwAwHltphhDM1r8i55H33GgqjXbrisuJhF4kRhW1dNuxsRklp4bXl8DSdLaNLuiL4A/LWRfxvg==", - "engines": { - "node": ">= 0.6.0" - }, - "funding": { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/loglevel" - } - }, "node_modules/long": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz", @@ -16101,14 +16004,6 @@ "resolved": "https://registry.npmjs.org/sdp/-/sdp-3.2.0.tgz", "integrity": "sha512-d7wDPgDV3DDiqulJjKiV2865wKsJ34YI+NDREbm+FySq6WuKOikwyNQcm+doLAZ1O6ltdO0SeKle2xMpN3Brgw==" }, - "node_modules/sdp-transform": { - "version": "2.14.2", - "resolved": "https://registry.npmjs.org/sdp-transform/-/sdp-transform-2.14.2.tgz", - "integrity": "sha512-icY6jVao7MfKCieyo1AyxFYm1baiM+fA00qW/KrNNVlkxHAd34riEKuEkUe4bBb3gJwLJZM+xT60Yj1QL8rHiA==", - "bin": { - "sdp-verify": "checker.js" - } - }, "node_modules/semver": { "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", @@ -17329,11 +17224,6 @@ "typescript": ">=4.2.0" } }, - "node_modules/ts-debounce": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/ts-debounce/-/ts-debounce-4.0.0.tgz", - "integrity": "sha512-+1iDGY6NmOGidq7i7xZGA4cm8DAa6fqdYcvO5Z6yBevH++Bdo9Qt/mN0TzHUgcCcKv1gmh9+W5dHqz8pMWbCbg==" - }, "node_modules/ts-interface-checker": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", @@ -17501,14 +17391,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/typed-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/typed-emitter/-/typed-emitter-2.1.0.tgz", - "integrity": "sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA==", - "optionalDependencies": { - "rxjs": "*" - } - }, "node_modules/typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -18043,20 +17925,6 @@ "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/usehooks-ts": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/usehooks-ts/-/usehooks-ts-3.1.0.tgz", - "integrity": "sha512-bBIa7yUyPhE1BCc0GmR96VU/15l/9gP1Ch5mYdLcFBaFGQsdmXkvjV0TtOqW1yUd6VjIwDunm+flSciCQXujiw==", - "dependencies": { - "lodash.debounce": "^4.0.8" - }, - "engines": { - "node": ">=16.15.0" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17 || ^18" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/src/Components/Users/UserProfile.tsx b/src/Components/Users/UserProfile.tsx index 22f2a0e2607..5ca5c0221b4 100644 --- a/src/Components/Users/UserProfile.tsx +++ b/src/Components/Users/UserProfile.tsx @@ -1,4 +1,4 @@ -import { useState, useReducer, FormEvent } from "react"; +import { useState, useReducer, FormEvent, useMemo } from "react"; import { GENDER_TYPES } from "../../Common/constants"; import { validateEmailAddress } from "../../Common/validation"; import * as Notification from "../../Utils/Notifications.js"; @@ -182,6 +182,51 @@ export default function UserProfile() { }, ); + const hasChanges = useMemo(() => { + if (!userData) return false; + + const fieldsToCheck: (keyof EditForm)[] = [ + "altPhoneNumber", + "date_of_birth", + "doctor_experience_commenced_on", + "doctor_medical_council_registration", + "email", + "firstName", + "gender", + "lastName", + "phoneNumber", + "qualification", + "video_connect_link", + "weekly_working_hours", + ]; + + return fieldsToCheck.some((field) => { + if (field === "date_of_birth") { + return ( + dayjs(states.form[field]).format("YYYY-MM-DD") !== + dayjs(userData[field]).format("YYYY-MM-DD") + ); + } + if (field === "doctor_experience_commenced_on") { + const userDataYears = dayjs().diff(dayjs(userData[field]), "years"); + return Number(states.form[field]) !== Number(userDataYears); + } + if (field === "weekly_working_hours") + return Number(states.form[field]) !== Number(userData[field]); + if (field === "firstName") + return states.form[field] !== userData.first_name; + if (field === "lastName") + return states.form[field] !== userData.last_name; + if (field === "phoneNumber") + return states.form[field] !== userData.phone_number; + if (field === "altPhoneNumber") + return states.form[field] !== userData.alt_phone_number; + if (field === "video_connect_link") + return states.form[field] !== userData[field] && !!states.form[field]; + return states.form[field] !== userData[field]; + }); + }, [states.form, userData]); + const validateNewPassword = (password: string) => { if ( password.length < 8 || @@ -788,7 +833,11 @@ export default function UserProfile() {