Skip to content

Commit

Permalink
refactor(mobile): update PointOfInterest model to factory function
Browse files Browse the repository at this point in the history
  • Loading branch information
weronikaolejniczak committed May 26, 2024
1 parent fbe2c6b commit 7ac92b2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
18 changes: 9 additions & 9 deletions apps/mobile/src/domains/map/containers/MapContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { View } from 'react-native';
import { useDispatch, useSelector } from 'react-redux';

import { patchMapRequest } from 'actions/mapActions';
import PointOfInterest from 'models/PointOfInterest';
import PointOfInterestModel from 'models/PointOfInterest';
import fetchMapSearch from 'services/fetchMapSearch';
import { Toolbar } from '../components';
import { styles } from './MapContainerStyle';
Expand Down Expand Up @@ -151,22 +151,22 @@ const MapContainer = ({ route, navigation }) => {
markers
? [
...markers,
new PointOfInterest(
new Date().getTime().toString(),
new Date().toString(),
PointOfInterestModel({
id: new Date().getTime().toString(),
key: new Date().toString(),
latitude,
longitude,
title,
),
}),
]
: [
new PointOfInterest(
new Date().getTime().toString(),
new Date().toString(),
PointOfInterestModel({
id: new Date().getTime().toString(),
key: new Date().toString(),
latitude,
longitude,
title,
),
}),
],
);
};
Expand Down
30 changes: 21 additions & 9 deletions apps/mobile/src/models/PointOfInterest.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
class PointOfInterest {
constructor(key, id, lat, lon, title) {
this.key = key;
this.id = id;
this.lat = lat;
this.lon = lon;
this.title = title;
}
interface PointOfInterestModelParams {
id: string;
key: string;
latitude: number;
longitude: number;
title: string;
}

export default PointOfInterest;
const PointOfInterestModel = ({
id,
key,
latitude,
longitude,
title,
}: PointOfInterestModelParams) => ({
id,
key,
latitude,
longitude,
title,
});

export default PointOfInterestModel;

0 comments on commit 7ac92b2

Please sign in to comment.