web client v0.5

//notifications
//delete restaurant
//change picture
//redesigned data store
This commit is contained in:
2020-09-27 18:40:39 +02:00
parent 3fdc93ef28
commit d2842a1db3
24 changed files with 810 additions and 501 deletions

View File

@@ -8,9 +8,9 @@ import ButtonSecondary from "../Input/ButtonSecondary";
import IconButton from "@material-ui/core/IconButton";
import TextField from "@material-ui/core/TextField";
import CloseIcon from "@material-ui/icons/Close";
import { useSelector, useDispatch } from "react-redux";
import { setRegisterResult, showRegulamin } from "../../actions/toggles";
import { tryRegister } from "../../actions";
import { useDispatch } from "react-redux";
import { showRegulamin } from "../../actions/toggles";
import { tryRegister, notification } from "../../actions";
import InputAdornment from "@material-ui/core/InputAdornment";
import AccountCircle from "@material-ui/icons/AccountCircle";
import BusinessIcon from "@material-ui/icons/Business";
@@ -18,12 +18,9 @@ import EmailIcon from "@material-ui/icons/Email";
import LockIcon from "@material-ui/icons/Lock";
import Link from "@material-ui/core/Link";
import validator from "validator";
import CircularProgress from "@material-ui/core/CircularProgress";
import { useHistory } from "react-router-dom";
export default function RegisterDialog(props) {
// SETUP
const initialFormData = {
firstname: "",
lastname: "",
@@ -43,13 +40,6 @@ export default function RegisterDialog(props) {
repeatPasswordError: false,
};
const [formData, setFormData] = useState(initialFormData);
var circularProgress = useSelector(
(state) => state.data.dialogs.registerCircularProgress
);
var registerForm = useSelector((state) => state.data.dialogs.registerForm);
var registerResult = useSelector(
(state) => state.data.dialogs.registerResult
);
const dispatch = useDispatch();
const history = useHistory();
@@ -138,7 +128,7 @@ export default function RegisterDialog(props) {
if (validateForm()) {
dispatch(tryRegister(form));
} else {
dispatch(setRegisterResult("Proszę poprawić formularz."));
dispatch(notification("Proszę poprawić formularz.", "error"));
}
};
@@ -162,179 +152,161 @@ export default function RegisterDialog(props) {
</IconButton>
<Divider />
<DialogContent>
{registerForm && (
<div>
<TextField
className={loginClass.textInput}
required
id="firstname"
label="Imię"
type="name"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<AccountCircle color="primary" />
</InputAdornment>
),
}}
error={formData.firstnameError}
onChange={(event) => (formData.firstname = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="lastname"
label="Nazwisko"
type="name"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<AccountCircle color="primary" />
</InputAdornment>
),
}}
error={formData.lastnameError}
onChange={(event) => (formData.lastname = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="companyName"
label="Nazwa firmy"
type="name"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<BusinessIcon color="primary" />
</InputAdornment>
),
}}
error={formData.companyNameError}
onChange={(event) =>
(formData.companyName = event.target.value)
}
/>
<TextField
className={loginClass.textInput}
required
id="adress"
label="Adres firmy"
type="name"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<BusinessIcon color="primary" />
</InputAdornment>
),
}}
error={formData.adressError}
onChange={(event) => (formData.adress = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="NIP"
label="NIP"
type="name"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<BusinessIcon color="primary" />
</InputAdornment>
),
}}
error={formData.NIPError}
onChange={(event) => (formData.NIP = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="email"
label="Email"
type="email"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<EmailIcon color="primary" />
</InputAdornment>
),
}}
error={formData.emailError}
onChange={(event) => (formData.email = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="password"
label="Hasło (min. 8 znaków)"
type="password"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<LockIcon color="primary" />
</InputAdornment>
),
}}
error={formData.passwordError}
onChange={(event) => (formData.password = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="repeat-password"
label="Powtórz hasło"
type="password"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<LockIcon color="primary" />
</InputAdornment>
),
}}
error={formData.repeatPasswordError}
onChange={(event) =>
(formData.repeatPassword = event.target.value)
}
/>
</div>
)}
<p>{registerResult}</p>
<div>
<TextField
className={loginClass.textInput}
required
id="firstname"
label="Imię"
type="name"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<AccountCircle color="primary" />
</InputAdornment>
),
}}
error={formData.firstnameError}
onChange={(event) => (formData.firstname = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="lastname"
label="Nazwisko"
type="name"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<AccountCircle color="primary" />
</InputAdornment>
),
}}
error={formData.lastnameError}
onChange={(event) => (formData.lastname = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="companyName"
label="Nazwa firmy"
type="name"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<BusinessIcon color="primary" />
</InputAdornment>
),
}}
error={formData.companyNameError}
onChange={(event) => (formData.companyName = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="adress"
label="Adres firmy"
type="name"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<BusinessIcon color="primary" />
</InputAdornment>
),
}}
error={formData.adressError}
onChange={(event) => (formData.adress = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="NIP"
label="NIP"
type="name"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<BusinessIcon color="primary" />
</InputAdornment>
),
}}
error={formData.NIPError}
onChange={(event) => (formData.NIP = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="email"
label="Email"
type="email"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<EmailIcon color="primary" />
</InputAdornment>
),
}}
error={formData.emailError}
onChange={(event) => (formData.email = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="password"
label="Hasło (min. 8 znaków)"
type="password"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<LockIcon color="primary" />
</InputAdornment>
),
}}
error={formData.passwordError}
onChange={(event) => (formData.password = event.target.value)}
/>
<TextField
className={loginClass.textInput}
required
id="repeat-password"
label="Powtórz hasło"
type="password"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<LockIcon color="primary" />
</InputAdornment>
),
}}
error={formData.repeatPasswordError}
onChange={(event) =>
(formData.repeatPassword = event.target.value)
}
/>
</div>
<Divider />
<div className="register-dialog-actions">
{circularProgress && <CircularProgress />}
{registerForm && (
<p>
Rejestracja oznacza akceptację{" "}
<span>
<Link
href="#"
onClick={(event) => handleRegulaminClick(event)}
>
regulaminu
</Link>
</span>
</p>
)}
<p>
Rejestracja oznacza akceptację{" "}
<span>
<Link href="#" onClick={(event) => handleRegulaminClick(event)}>
regulaminu
</Link>
</span>
</p>
<div className="register-dialog-button">
{registerForm ? (
<ButtonSecondary
onClick={() => sendForm(formData)}
text="Zarejestruj"
/>
) : (
<ButtonSecondary
onClick={() => history.push("/login")}
text="Logowanie"
/>
)}
<ButtonSecondary
onClick={() => sendForm(formData)}
text="Zarejestruj"
/>
</div>
</div>
</DialogContent>