`
import * as React from 'react';
import { useState, useEffect } from 'react';
import StarIcon from '@mui/icons-material/Star';
import LocationOnIcon from '@mui/icons-material/LocationOn';
import axios from 'axios';
import { format } from 'timeago.js';
import Login from './components/Login';
import Register from './components/Register';
This is my code
` import * as React from 'react'; import { useState, useEffect } from 'react'; import StarIcon from '@mui/icons-material/Star'; import LocationOnIcon from '@mui/icons-material/LocationOn'; import axios from 'axios'; import { format } from 'timeago.js'; import Login from './components/Login'; import Register from './components/Register';
function App() { // const myStorage = window.localStorage; const [pins, setPins] = useState([]); const [login, setLogin] = useState(false); const [register, setRegister] = useState(false);
const [currUser, setCurrUser] = useState(null) const [currentPlaceId, setCurrentPlaceId] = useState(null); const [newPlace, setNewPlace] = useState(null); const [newPlaceName, setNewPlaceName] = useState(""); const [newPlaceDesc, setNewPlaceDesc] = useState("");
const [newRating, setNewRating] = useState(1);
// console.log(pins); const [viewState, setViewState] = React.useState({ longitude: 50, latitude: 37, zoom: 4, transitionDuration: 1000 });
const loginwindow = (e) => { e.preventDefault(); setRegister(false); setLogin(true); } const logoutclick = (e) => { e.preventDefault(); setCurrUser(null) } const registerwindow = (e) => { e.preventDefault(); setLogin(false); setRegister(true); } const handleSubmit = async (e) => { e.preventDefault(); const newPin = { username: currUser, desc: newPlaceDesc, title: newPlaceName, rating: newRating, long: newPlace.long, lat: newPlace.lat } setNewPlace(null)
} const handleMarkerClick = (id, lat, long) => { setCurrentPlaceId(id); }; const handleAddClick = (e) => { e.preventDefault(); if (currUser == null) { setLogin(true) } else { setCurrentPlaceId(null); const lat = e.lngLat.lat; const long = e.lngLat.lng;
}; // console.log(pins); useEffect(() => {
}, [])
// console.log(newPlace) return (
); }
export default App;
`