|
|
|
@ -1,19 +1,114 @@
|
|
|
|
|
import * as React from "react";
|
|
|
|
|
import React, { useState, useReducer } from "react";
|
|
|
|
|
import * as ReactDOM from "react-dom";
|
|
|
|
|
import "regenerator-runtime/runtime";
|
|
|
|
|
import {
|
|
|
|
|
MapContainer,
|
|
|
|
|
TileLayer,
|
|
|
|
|
Marker,
|
|
|
|
|
Popup,
|
|
|
|
|
useMapEvents,
|
|
|
|
|
} from "react-leaflet";
|
|
|
|
|
import "./styles/reset.css";
|
|
|
|
|
import "./styles/app.scss";
|
|
|
|
|
|
|
|
|
|
const App = () => {
|
|
|
|
|
const App: React.FC = () => {
|
|
|
|
|
const [files, setFiles] = useState([]);
|
|
|
|
|
const [mapPin, setMapPin] = useState([52.39663, 16.89866]);
|
|
|
|
|
|
|
|
|
|
const handleSubmit = async (
|
|
|
|
|
event: React.FormEvent<HTMLFormElement>
|
|
|
|
|
): Promise<void> => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
const files = e.target.files;
|
|
|
|
|
const newstate = [];
|
|
|
|
|
const readAndPreview = (file) => {
|
|
|
|
|
// Make sure `file.name` matches our extensions criteria
|
|
|
|
|
if (/\.(jpe?g|png|svg)$/i.test(file.name)) {
|
|
|
|
|
let reader = new FileReader();
|
|
|
|
|
reader.addEventListener(
|
|
|
|
|
"load",
|
|
|
|
|
function () {
|
|
|
|
|
newstate.push(this.result);
|
|
|
|
|
setFiles([...newstate]);
|
|
|
|
|
},
|
|
|
|
|
false
|
|
|
|
|
);
|
|
|
|
|
reader.readAsDataURL(file);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
if (files) {
|
|
|
|
|
[].forEach.call(files, readAndPreview);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const MapComponent = () => {
|
|
|
|
|
useMapEvents({
|
|
|
|
|
click: (e) => {
|
|
|
|
|
setMapPin([e.latlng.lat, e.latlng.lng]);
|
|
|
|
|
console.log(mapPin);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<div className="container">
|
|
|
|
|
<section className="container__section">
|
|
|
|
|
<h2>Photos</h2>
|
|
|
|
|
<h2 className="container__section__title">Zdjęcia</h2>
|
|
|
|
|
<div className="container__section__photos">
|
|
|
|
|
{files.map((file) => (
|
|
|
|
|
<div className="section__photos__item">
|
|
|
|
|
<img src={file} id="img" className="img" />
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
<input
|
|
|
|
|
type="file"
|
|
|
|
|
name="image-upload"
|
|
|
|
|
id="input"
|
|
|
|
|
accept="image/*"
|
|
|
|
|
multiple
|
|
|
|
|
onChange={(e) => handleUpload(e)}
|
|
|
|
|
/>
|
|
|
|
|
</section>
|
|
|
|
|
<section className="container__section">
|
|
|
|
|
<h2>Map</h2>
|
|
|
|
|
<h2 className="container__section__title">Mapa</h2>
|
|
|
|
|
<div>
|
|
|
|
|
<MapContainer
|
|
|
|
|
center={[52.39663, 16.89866]}
|
|
|
|
|
className="container__section__map"
|
|
|
|
|
zoom={18}
|
|
|
|
|
scrollWheelZoom={true}
|
|
|
|
|
>
|
|
|
|
|
<TileLayer
|
|
|
|
|
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
|
|
|
|
url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"
|
|
|
|
|
/>
|
|
|
|
|
<Marker position={mapPin}></Marker>
|
|
|
|
|
<MapComponent />
|
|
|
|
|
</MapContainer>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
<section className="container__section">
|
|
|
|
|
<h2>Form</h2>
|
|
|
|
|
<h2 className="container__section__title">Formularz zgłoszeniowy</h2>
|
|
|
|
|
<form
|
|
|
|
|
className="container__section__form"
|
|
|
|
|
onSubmit={(e) => handleSubmit(e)}
|
|
|
|
|
>
|
|
|
|
|
<label htmlFor="name">Twoje imię i nazwisko</label>
|
|
|
|
|
<input type="text" className="input" id="name" />
|
|
|
|
|
<label htmlFor="email">Twój adres email</label>
|
|
|
|
|
<input type="text" className="input" id="email" />
|
|
|
|
|
<label htmlFor="plate">Numer tablicy rejestracyjnej</label>
|
|
|
|
|
<input type="text" className="input" id="plate" />
|
|
|
|
|
<label htmlFor="message">Wiadomość dla straży miejskiej</label>
|
|
|
|
|
<textarea className="input input--textarea" id="message" />
|
|
|
|
|
<select className="input" id="reason">
|
|
|
|
|
<option value="0">Wybierz powód wysłania zgłoszenia</option>
|
|
|
|
|
</select>
|
|
|
|
|
<button className="button">Wysłanie zgłoszenia</button>
|
|
|
|
|
</form>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|