KATAMARI DAMACY

This commit is contained in:
MarcEricMartel 2022-11-08 08:18:33 -08:00
parent b3e916e50b
commit 360326bd71
2 changed files with 79 additions and 26 deletions

View File

@ -43,10 +43,13 @@ public class UserController : Controller {
int x = 0;
InventoryUser usr;
try {
usr = new() {
usr = new() {
FirstName = sign.FirstName,
LastName = sign.LastName,
UserName = sign.FirstName + sign.LastName,
NormalizedUserName = (sign.FirstName + sign.LastName).ToUpper(),
Email = sign.Email,
NormalizedEmail = sign.Email.ToUpper(),
PhoneNumber = sign.Phone
};
} catch (Exception e){
@ -54,9 +57,10 @@ public class UserController : Controller {
}
try {
usr.Adresses = new();
usr.Adresses.Add(new AddressModel() {
CivicNumber = sign.CivicNumber,
Appartment = sign.Appartment,
Appartment = sign.Appartment is not null && sign.Appartment != ""? sign.Appartment: null,
Street = sign.Street,
City = sign.City,
Province = sign.Province,

View File

@ -1,8 +1,10 @@
import { useState } from "react";
import { Button } from "react-bootstrap";
import { useForm } from "react-hook-form";
import Swal from "sweetalert2";
import withReactContent from "sweetalert2-react-content";
// const Register = () => {
const Register = () => {
// //const [username, setUsername] = useState("");
// //const [password, setPassword] = useState("");
@ -23,17 +25,24 @@ import { useForm } from "react-hook-form";
// }
export default function App() {
//export default function App() {
const mySwal = withReactContent(Swal);
const { register, handleSubmit, watch, formState: { errors } } = useForm();
const onSubmit = data => {
const response = fetch(`https://localhost:7292/api/User`, {
fetch(`https://localhost:7292/api/User`, {
method: 'POST',
headers: {
'Accept': 'text/json',
'Content-Type': 'text/json'
},
body: JSON.stringify(data)
})
}).then((response) => {
if (response.ok)
mySwal.fire({
text: 'Vous vous êtes incrit avec succès!',
confirmButtonText: 'Ok'
}).then((response) => window.location.href = "/login");
})
}
return (
@ -43,34 +52,76 @@ return (
<div className="Error_color">
<div className="form-group">
<label>Prénom: </label>
<input placeholder="Votre prénom:" {...register("Prénom", { required: true, minLength: 2})} />
<input placeholder="Votre prénom:" {...register("FirstName", { required: true, minLength: 2})} />
</div>
<div>
{errors.Prénom && errors.Prénom.type === 'required' && <span>Vous devez entrer votre prénom!</span>}
{errors.Prénom && errors.Prénom.type === 'minLength' && <span>Votre prénom doit avoir au moins 2 lettres!</span>}
{errors.FirstName && errors.FirstName.type === 'required' && <span>Vous devez entrer votre prénom!</span>}
{errors.FirstName && errors.FirstName.type === 'minLength' && <span>Votre prénom doit avoir au moins 2 lettres!</span>}
</div>
<div className="form-group">
<label>Nom: </label>
<input placeholder="Votre nom:" {...register("Nom", { required: true, minLength: 2})} />
<input placeholder="Votre nom:" {...register("LastName", { required: true, minLength: 2})} />
</div>
<div>
{errors.Nom && errors.Nom.type === 'required' && <span>Vous devez entrer votre nom!</span>}
{errors.Nom && errors.Nom.type === 'minLength' && <span>Votre nom doit avoir au moins 2 lettres!</span>}
{errors.LastName && errors.LastName.type === 'required' && <span>Vous devez entrer votre nom!</span>}
{errors.LastName && errors.LastName.type === 'minLength' && <span>Votre nom doit avoir au moins 2 lettres!</span>}
</div>
<div className="form-group">
<label>Numéro de téléphone: </label>
<input placeholder="Exemple: 111-111-1111" {...register("Téléphone", { required: true, pattern: /^[0-9]{3}-[0-9]{3}-[0-9]{4}$/ })} />
<input placeholder="Exemple: 111-111-1111" {...register("Phone", { required: true, pattern: /^[0-9]{3}-[0-9]{3}-[0-9]{4}$/ })} />
</div>
<div>
{errors.Téléphone && errors.Téléphone.type === 'required' && <span>Vous devez entrer un numéro de téléphone!</span>}
{errors.Téléphone && errors.Téléphone.type === 'pattern' && <span>Téléphone non valide!</span>}
{errors.Phone && errors.Phone.type === 'required' && <span>Vous devez entrer un numéro de téléphone!</span>}
{errors.Phone && errors.Phone.type === 'pattern' && <span>Téléphone non valide!</span>}
</div>
<div className="form-group">
<label>Adresse civique: </label>
<input placeholder="Votre adresse:" {...register("Adresse", { required: true })} />
<label>Numéro civique: </label>
<input placeholder="Votre numéro civique:" {...register("CivicNumber", { required: true })} />
</div>
<div>
{errors.Adresse && errors.Adresse.type === 'required' && <span>Vous devez entrer une adresse!</span>}
{errors.CivicNumber && errors.CivicNumber.type === 'required' && <span>Vous devez entrer un numéro civique!</span>}
</div>
<div className="form-group">
<label>Appartement: </label>
<input placeholder="Votre identifiant d'appartement:" {...register("Appartment")} />
</div>
<div>
</div>
<div className="form-group">
<label>Rue: </label>
<input placeholder="Votre rue:" {...register("Street", { required: true })} />
</div>
<div>
{errors.Street && errors.Street.type === 'required' && <span>Vous devez entrer une rue!</span>}
</div>
<div className="form-group">
<label>Ville: </label>
<input placeholder="Votre ville:" {...register("City", { required: true })} />
</div>
<div>
{errors.City && errors.City.type === 'required' && <span>Vous devez entrer une vile!</span>}
</div>
<div className="form-group">
<label>Province: </label>
<input placeholder="Votre province:" {...register("Province", { required: true })} />
</div>
<div>
{errors.Province && errors.Province.type === 'required' && <span>Vous devez entrer une province!</span>}
</div>
<div className="form-group">
<label>Pays: </label>
<input placeholder="Votre pays:" {...register("Country", { required: true })} />
</div>
<div>
{errors.Country && errors.Country.type === 'required' && <span>Vous devez entrer un pays!</span>}
</div>
<div className="form-group">
<label>Code Postal: </label>
<input placeholder="Votre code postal:" {...register("PostalCode", { required: true })} />
</div>
<div>
{errors.PostalCode && errors.PostalCode.type === 'required' && <span>Vous devez entrer un code postal!</span>}
</div>
<div className="form-group">
<label>Adresse courriel: </label>
@ -82,19 +133,17 @@ return (
</div>
<div className="form-group">
<label>Mot de passe: </label>
<input placeholder="Mot de passe..." {...register("MotPasse", { required: true, minLength: 5})} />
<input placeholder="Mot de passe..." {...register("Password", { required: true, minLength: 5})} />
</div>
<div>
{errors.MotPasse && errors.MotPasse.type === 'required' && <span>Vous devez entrer un mot de passe!</span>}
{errors.MotPasse && errors.MotPasse.type === 'minLength' && <span>Votre mot de passe doit avoir au moins 5 caractères!</span>}
</div>
<div className="form-group">
<label>Pour un acount admin, entrer le mot de passe. Sinon laisser vide: </label>
<input placeholder="Mot de passe admin..." {...register("MotPasseAdmin", { minLength: 0})} />
{errors.Password && errors.Password.type === 'required' && <span>Vous devez entrer un mot de passe!</span>}
{errors.Password && errors.Password.type === 'minLength' && <span>Votre mot de passe doit avoir au moins 5 caractères!</span>}
</div>
</div>
<Button className="btn-primary btn-ajouter-morceau" type="submit" >Confirmer</Button>
</form>
</div>
)
}
}
export default Register;