Skip to content

Commit 87348b8

Browse files
committed
feat: 👽️ remove doctor id
doctor.csv will no longer have "id" field BREAKING CHANGE: #115
1 parent 7032e16 commit 87348b8

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

src/components/DoctorCard/index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { memo } from 'react';
2+
import slugify from 'slugify';
23
import CardContent from '@mui/material/CardContent';
34
import CardMedia from '@mui/material/CardMedia';
45

@@ -17,9 +18,11 @@ const DoctorCard = function DoctorCard({ doctor, isPage = false, isReportError }
1718
map.flyTo([lat, lon], 13);
1819
};
1920

21+
const id = `${doctor.type}-${slugify(doctor.name).toLowerCase()}`;
22+
2023
if (isPage) {
2124
return (
22-
<Styled.PageInfoCard id={doctor.id} accepts={accepts.toString()}>
25+
<Styled.PageInfoCard id={id} accepts={accepts.toString()}>
2326
<Styled.PageInfoBox id="doctor-box">
2427
<PageInfo doctor={doctor} handleZoom={handleZoom} isReportError={isReportError} />
2528
<CardContent>
@@ -33,11 +36,11 @@ const DoctorCard = function DoctorCard({ doctor, isPage = false, isReportError }
3336
}
3437

3538
return (
36-
<Styled.InfoCard id={doctor.id} accepts={accepts.toString()}>
39+
<Styled.InfoCard id={id} accepts={accepts.toString()}>
3740
<Info doctor={doctor} handleZoom={handleZoom} />
3841
</Styled.InfoCard>
3942
);
4043
};
4144

42-
const propsAreEqual = (prevProps, nextProps) => prevProps.doctor.id === nextProps.doctor.id;
45+
const propsAreEqual = (prevProps, nextProps) => prevProps.doctor.key === nextProps.doctor.key;
4346
export default memo(DoctorCard, propsAreEqual);

src/components/Doctors/Map.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function withLeaflet(Component) {
1818
userLocation = false,
1919
...other
2020
}) {
21-
const markers = doctors?.map(doctor => <Markers.Doctor key={doctor.id} doctor={doctor} />);
21+
const markers = doctors?.map(doctor => <Markers.Doctor key={doctor.key} doctor={doctor} />);
2222
const injectedProps = {
2323
center,
2424
zoom,

src/components/Doctors/Markers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const PopUpData = function PopUpData({ doctor }) {
4040
);
4141
};
4242

43-
const areEqual = (prevProps, nextProps) => prevProps.doctor.id === nextProps.doctor.id;
43+
const areEqual = (prevProps, nextProps) => prevProps.doctor.key === nextProps.doctor.key;
4444
export const Doctor = memo(({ doctor }) => {
4545
const ref = createRef(null);
4646
const theme = useTheme();

src/services/doctors.js

-6
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ export function createDoctor(doctor, type, institution) {
4444
get key() {
4545
return uuid;
4646
},
47-
get id() {
48-
return doctor.id;
49-
},
5047
get type() {
5148
return doctor.type;
5249
},
@@ -99,8 +96,6 @@ export default function createDoctors(doctorsDict, institutionsDict, typesDict)
9996
return acc;
10097
}, {});
10198

102-
const getById = id => doctors[`${id}`];
103-
10499
const doctorValues = Object.values(doctors);
105100
const doctorsValues = Intl.Collator
106101
? doctorValues.sort((a, b) => new Intl.Collator('sl').compare(a.name, b.name))
@@ -125,7 +120,6 @@ export default function createDoctors(doctorsDict, institutionsDict, typesDict)
125120

126121
return Object.freeze({
127122
all: doctorsValues,
128-
getById,
129123
types,
130124
filterByType,
131125
typesDict,

0 commit comments

Comments
 (0)