From 360326bd7153c23cfc1bd0375b022f99f0b96702 Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Tue, 8 Nov 2022 08:18:33 -0800 Subject: [PATCH] KATAMARI DAMACY --- .../Controllers/UserController.cs | 8 +- .../grosses-mitaines-ui/src/pages/Register.js | 97 ++++++++++++++----- 2 files changed, 79 insertions(+), 26 deletions(-) diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/UserController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/UserController.cs index a5153d9..c5f90f6 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/UserController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/UserController.cs @@ -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, diff --git a/GrossesMitaines/grosses-mitaines-ui/src/pages/Register.js b/GrossesMitaines/grosses-mitaines-ui/src/pages/Register.js index 5fc7d0a..e549414 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/pages/Register.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/pages/Register.js @@ -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 (