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

View File

@ -1,8 +1,10 @@
import { useState } from "react"; import { useState } from "react";
import { Button } from "react-bootstrap"; import { Button } from "react-bootstrap";
import { useForm } from "react-hook-form"; 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 [username, setUsername] = useState("");
// //const [password, setPassword] = 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 { register, handleSubmit, watch, formState: { errors } } = useForm();
const onSubmit = data => { const onSubmit = data => {
const response = fetch(`https://localhost:7292/api/User`, { fetch(`https://localhost:7292/api/User`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Accept': 'text/json', 'Accept': 'text/json',
'Content-Type': 'text/json' 'Content-Type': 'text/json'
}, },
body: JSON.stringify(data) 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 ( return (
@ -43,34 +52,76 @@ return (
<div className="Error_color"> <div className="Error_color">
<div className="form-group"> <div className="form-group">
<label>Prénom: </label> <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>
<div> <div>
{errors.Prénom && errors.Prénom.type === 'required' && <span>Vous devez entrer votre prénom!</span>} {errors.FirstName && errors.FirstName.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 === 'minLength' && <span>Votre prénom doit avoir au moins 2 lettres!</span>}
</div> </div>
<div className="form-group"> <div className="form-group">
<label>Nom: </label> <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>
<div> <div>
{errors.Nom && errors.Nom.type === 'required' && <span>Vous devez entrer votre nom!</span>} {errors.LastName && errors.LastName.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 === 'minLength' && <span>Votre nom doit avoir au moins 2 lettres!</span>}
</div> </div>
<div className="form-group"> <div className="form-group">
<label>Numéro de téléphone: </label> <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>
<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.Phone && errors.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 === 'pattern' && <span>Téléphone non valide!</span>}
</div> </div>
<div className="form-group"> <div className="form-group">
<label>Adresse civique: </label> <label>Numéro civique: </label>
<input placeholder="Votre adresse:" {...register("Adresse", { required: true })} /> <input placeholder="Votre numéro civique:" {...register("CivicNumber", { required: true })} />
</div> </div>
<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>
<div className="form-group"> <div className="form-group">
<label>Adresse courriel: </label> <label>Adresse courriel: </label>
@ -82,19 +133,17 @@ return (
</div> </div>
<div className="form-group"> <div className="form-group">
<label>Mot de passe: </label> <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>
<div> <div>
{errors.MotPasse && errors.MotPasse.type === 'required' && <span>Vous devez entrer un mot de passe!</span>} {errors.Password && errors.Password.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>} {errors.Password && errors.Password.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})} />
</div> </div>
</div> </div>
<Button className="btn-primary btn-ajouter-morceau" type="submit" >Confirmer</Button> <Button className="btn-primary btn-ajouter-morceau" type="submit" >Confirmer</Button>
</form> </form>
</div> </div>
) )
} }
export default Register;