fix(buscar-passageiro): ✨ search passengers
This commit is contained in:
@@ -34,10 +34,10 @@ const BuscarPassageiro: React.FC = () => {
|
|||||||
// getUsersSearching(currentPoint);
|
// getUsersSearching(currentPoint);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
const [ currentPoint, setCurrentPoint ] = useState({ latitude: 40.8264691, longitude: -73.9549618 });
|
const [ currentPoint, setCurrentPoint ] = useState({ latitude: -22.907829, longitude: -47.062943 });
|
||||||
|
|
||||||
const records = RecordsStore.useState(fetchRecords);
|
const records = RecordsStore.useState(fetchRecords);
|
||||||
const center = { latitude: 40.8264691, longitude: -73.9549618 };
|
const center = { latitude: -22.907829, longitude: -47.062943 };
|
||||||
|
|
||||||
const [ results, setResults ] = useState([]);
|
const [ results, setResults ] = useState([]);
|
||||||
const [ zoom, setZoom ] = useState(14);
|
const [ zoom, setZoom ] = useState(14);
|
||||||
@@ -68,7 +68,6 @@ const BuscarPassageiro: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleMap = (e:any) => {
|
const handleMap = (e:any) => {
|
||||||
console.log(e)
|
|
||||||
setCurrentPoint({ latitude: e.center[0], longitude: e.center[1] });
|
setCurrentPoint({ latitude: e.center[0], longitude: e.center[1] });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,21 +83,20 @@ const BuscarPassageiro: React.FC = () => {
|
|||||||
<Map onBoundsChanged={e => handleMap(e)} defaultCenter={ [center.latitude, center.longitude] } defaultZoom={ zoom } provider={ maptilerProvider } touchEvents={ true }>
|
<Map onBoundsChanged={e => handleMap(e)} defaultCenter={ [center.latitude, center.longitude] } defaultZoom={ zoom } provider={ maptilerProvider } touchEvents={ true }>
|
||||||
|
|
||||||
{ results.map((record:{latitude:any, longitude:any}, index) => {
|
{ results.map((record:{latitude:any, longitude:any}, index) => {
|
||||||
|
return <Marker key={ index } color="#3578e5" width={ 50 } anchor={ [ parseFloat(record.latitude), parseFloat(record.longitude) ] } />
|
||||||
return <Marker key={ index } color="#3578e5" width={ 50 } anchor={ [ record.latitude, record.longitude ] } />
|
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{ results.map((record:{showInfo:boolean, latitude:any, longitude:any}, index) => {
|
{/* { results.map((record:{showInfo:boolean, latitude:any, longitude:any}, index) => {
|
||||||
|
|
||||||
if (record.showInfo) {
|
if (record.showInfo) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Overlay key={ index } anchor={ [ record.latitude, record.longitude ] } offset={[95, 304]}>
|
<Overlay key={ index } anchor={ [ record.latitude, record.longitude ] } offset={[95, 304]}> */}
|
||||||
{/* <MapOverlay record={ record } /> */}
|
{/* <MapOverlay record={ record } /> */}
|
||||||
</Overlay>
|
{/* </Overlay>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})}
|
})} */}
|
||||||
</Map>
|
</Map>
|
||||||
|
|
||||||
<IonFab vertical="bottom" horizontal="end" slot="fixed">
|
<IonFab vertical="bottom" horizontal="end" slot="fixed">
|
||||||
|
|||||||
@@ -50,7 +50,9 @@ export async function getUsersSearching(currentPoint: any) {
|
|||||||
// Allow choosing of radius?
|
// Allow choosing of radius?
|
||||||
// Offset could = amount loaded in an infinite scroll?
|
// Offset could = amount loaded in an infinite scroll?
|
||||||
var latitude = currentPoint.latitude, longitude = currentPoint.longitude, radius = 3000, offset = 0;
|
var latitude = currentPoint.latitude, longitude = currentPoint.longitude, radius = 3000, offset = 0;
|
||||||
const response = await fetch(`http://localhost:4000/get-records?latitude=${ latitude }&longitude=${ longitude }&radius=${ radius }&offset=${ offset }`);
|
// const response = await fetch(`http://localhost:4000/get-records?latitude=${ latitude }&longitude=${ longitude }&radius=${ radius }&offset=${ offset }`);
|
||||||
const data = await response.json();
|
const response = await instance.post("http://localhost:3333/search/inraio", currentPoint)
|
||||||
setStore(data);
|
// const data = await response.json();
|
||||||
|
console.log(response.data)
|
||||||
|
setStore(response.data);
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,6 @@ const RecordsStore = new Store({
|
|||||||
export default RecordsStore;
|
export default RecordsStore;
|
||||||
|
|
||||||
export const setStore = records => {
|
export const setStore = records => {
|
||||||
|
|
||||||
RecordsStore.update(state => { state.records = records.allRecords });
|
RecordsStore.update(state => { state.records = records.allRecords });
|
||||||
RecordsStore.update(state => { state.center = records.center });
|
RecordsStore.update(state => { state.center = records.center });
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user