Commit ef3a3a6a authored by Omar Luna Hernández's avatar Omar Luna Hernández
Browse files

Se agrega una notificacion cuando un error ocurre

parent 043ced56
Loading
Loading
Loading
Loading
+32 −3
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@ import { usePasswoordVisibility } from "../../../hooks/usePasswordVisibility";
import { State } from "../../../infraestructure/entities/state";
import { useTown } from "../../../hooks/useTown";
import { Town } from "../../../infraestructure/entities/town";
import axios from "axios";
import axios, { AxiosError } from "axios";
import { ToastContainer, toast } from "react-toastify";

interface props {
  setWindowActive: Dispatch<SetStateAction<boolean>>,
@@ -46,7 +47,26 @@ export const SuperadminPanelAdminRegister = ({setWindowActive, setShowRegisterPa
        }
      } catch (error: any) {
        if (axios.isAxiosError(error)) {
          //console.log(error)
          error as AxiosError;
          let message = "";
          switch(error.code){
            case(axios.AxiosError.ERR_BAD_REQUEST):
              message = "Acceso no autorizado";
              break;
            case(axios.AxiosError.ERR_NETWORK):
              message = "Conexión con el servidor fallida";
              break;
          }
          toast.error(message, {
            position: "bottom-right",
            autoClose: 1500,
            hideProgressBar: false,
            closeOnClick: true,
            pauseOnHover: false,
            draggable: true,
            progress: undefined,
            theme: "colored"
          });
        }
      }
    }
@@ -119,7 +139,7 @@ export const SuperadminPanelAdminRegister = ({setWindowActive, setShowRegisterPa

          <div className="admin_input_cnt">
            <label>Pueblo mágico al que representa</label>
            {townsList === null || townsList.length==0
            {townsList === null || townsList.length===0
            ?
              <label>No hay pueblo registrados</label>
            :
@@ -135,6 +155,15 @@ export const SuperadminPanelAdminRegister = ({setWindowActive, setShowRegisterPa
            <p className="error">{errors.townAdmin?.message}</p>
          </div>
          
          <ToastContainer
            position='bottom-right'
            autoClose = {1000}
            hideProgressBar = {true}
            closeOnClick
            rtl={false}
            pauseOnFocusLoss
          />

          <div className="admin_input_cnt">
            <input className="submit_btn" type="submit" content="Registrar"/>
          </div>