From 98780ae31a6a88efdf6f241b7087224d17d297a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:25:44 -0600
Subject: [PATCH 01/18] Se crea la interface para un estado
---
web/src/infraestructure/entities/state.ts | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 web/src/infraestructure/entities/state.ts
diff --git a/web/src/infraestructure/entities/state.ts b/web/src/infraestructure/entities/state.ts
new file mode 100644
index 00000000..7079ff29
--- /dev/null
+++ b/web/src/infraestructure/entities/state.ts
@@ -0,0 +1,5 @@
+export interface State {
+ stateId?: number,
+ name?: string,
+ imageURL?: string
+}
\ No newline at end of file
--
GitLab
From 30ece949e8f854cb31d7ff5e166cfc602bdb1cbd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:26:09 -0600
Subject: [PATCH 02/18] Se instalan los paquetes de react dropzone y toastify
---
web/package-lock.json | 57 +++++++++++++++++++++++++++++++++++++++++++
web/package.json | 2 ++
2 files changed, 59 insertions(+)
diff --git a/web/package-lock.json b/web/package-lock.json
index 8d194350..dd8e9e47 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -20,10 +20,12 @@
"axios": "^1.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
+ "react-dropzone": "^14.2.3",
"react-hook-form": "^7.51.2",
"react-pro-sidebar": "^1.1.0",
"react-router-dom": "^6.22.3",
"react-scripts": "5.0.1",
+ "react-toastify": "^10.0.5",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
@@ -5394,6 +5396,14 @@
"node": ">= 4.0.0"
}
},
+ "node_modules/attr-accept": {
+ "version": "2.2.2",
+ "resolved": "https://registry.npmjs.org/attr-accept/-/attr-accept-2.2.2.tgz",
+ "integrity": "sha512-7prDjvt9HmqiZ0cl5CRjtS84sEyhsHP2coDkaZKRKVfCDo9s7iw7ChVmar78Gu9pC4SoR/28wFu/G5JJhTnqEg==",
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/autoprefixer": {
"version": "10.4.18",
"resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.18.tgz",
@@ -6209,6 +6219,14 @@
"wrap-ansi": "^7.0.0"
}
},
+ "node_modules/clsx": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz",
+ "integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/co": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
@@ -8439,6 +8457,17 @@
"webpack": "^4.0.0 || ^5.0.0"
}
},
+ "node_modules/file-selector": {
+ "version": "0.6.0",
+ "resolved": "https://registry.npmjs.org/file-selector/-/file-selector-0.6.0.tgz",
+ "integrity": "sha512-QlZ5yJC0VxHxQQsQhXvBaC7VRJ2uaxTf+Tfpu4Z/OcVQJVpZO+DGU0rkoVW5ce2SccxugvpBJoMvUs59iILYdw==",
+ "dependencies": {
+ "tslib": "^2.4.0"
+ },
+ "engines": {
+ "node": ">= 12"
+ }
+ },
"node_modules/filelist": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
@@ -15080,6 +15109,22 @@
"react": "^18.2.0"
}
},
+ "node_modules/react-dropzone": {
+ "version": "14.2.3",
+ "resolved": "https://registry.npmjs.org/react-dropzone/-/react-dropzone-14.2.3.tgz",
+ "integrity": "sha512-O3om8I+PkFKbxCukfIR3QAGftYXDZfOE2N1mr/7qebQJHs7U+/RSL/9xomJNpRg9kM5h9soQSdf0Gc7OHF5Fug==",
+ "dependencies": {
+ "attr-accept": "^2.2.2",
+ "file-selector": "^0.6.0",
+ "prop-types": "^15.8.1"
+ },
+ "engines": {
+ "node": ">= 10.13"
+ },
+ "peerDependencies": {
+ "react": ">= 16.8 || 18.0.0"
+ }
+ },
"node_modules/react-error-overlay": {
"version": "6.0.11",
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz",
@@ -15230,6 +15275,18 @@
}
}
},
+ "node_modules/react-toastify": {
+ "version": "10.0.5",
+ "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-10.0.5.tgz",
+ "integrity": "sha512-mNKt2jBXJg4O7pSdbNUfDdTsK9FIdikfsIE/yUCxbAEXl4HMyJaivrVFcn3Elvt5xvCQYhUZm+hqTIu1UXM3Pw==",
+ "dependencies": {
+ "clsx": "^2.1.0"
+ },
+ "peerDependencies": {
+ "react": ">=18",
+ "react-dom": ">=18"
+ }
+ },
"node_modules/read-cache": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
diff --git a/web/package.json b/web/package.json
index f36efbd5..3ac96a94 100644
--- a/web/package.json
+++ b/web/package.json
@@ -15,10 +15,12 @@
"axios": "^1.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
+ "react-dropzone": "^14.2.3",
"react-hook-form": "^7.51.2",
"react-pro-sidebar": "^1.1.0",
"react-router-dom": "^6.22.3",
"react-scripts": "5.0.1",
+ "react-toastify": "^10.0.5",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
--
GitLab
From 0ec3aa4a0825514b1a1ec378c989f4bd43a2ebcf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:29:47 -0600
Subject: [PATCH 03/18] Se modifica para que se desactive el boton del submenu
de login
---
.../admin_panel_navbar/admin_navbar.tsx | 22 +++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/web/src/components/admin_panel_navbar/admin_navbar.tsx b/web/src/components/admin_panel_navbar/admin_navbar.tsx
index 424bd063..6a65a776 100644
--- a/web/src/components/admin_panel_navbar/admin_navbar.tsx
+++ b/web/src/components/admin_panel_navbar/admin_navbar.tsx
@@ -5,7 +5,11 @@ import { useAuth } from "../../context/auth_context";
import { Link } from "react-router-dom";
import './assets/styles/style.css';
-export const AdminPanelNavBar = () => {
+interface props{
+ windowActive: boolean;
+}
+
+export const AdminPanelNavBar = ({windowActive}:props) => {
const {user, logout} = useAuth();
const [toggle, setToggle] = useState(false);
@@ -17,7 +21,21 @@ export const AdminPanelNavBar = () => {
setToggle(!toggle)}/>
+ onClick={() => {
+ windowActive
+ ?
+ setToggle(false)
+ :
+ setToggle(!toggle)
+ }}
+ style={
+ windowActive
+ ?
+ {cursor: "auto"}
+ :
+ {cursor: "pointer"}
+ }
+ />
{toggle &&
--
GitLab
From 50cf3ea207de44bc57cc5a03dc1e2507dec47152 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:30:43 -0600
Subject: [PATCH 04/18] Se modifica el submenu para que aparezca sobre todo
---
web/src/components/admin_panel_navbar/assets/styles/style.css | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/web/src/components/admin_panel_navbar/assets/styles/style.css b/web/src/components/admin_panel_navbar/assets/styles/style.css
index 0762a670..7e82ea47 100644
--- a/web/src/components/admin_panel_navbar/assets/styles/style.css
+++ b/web/src/components/admin_panel_navbar/assets/styles/style.css
@@ -15,12 +15,12 @@
.profile{
position: absolute;
right: 20px;
+ user-select: none;
}
.user-pic{
width: 30px;
border-radius: 50%;
- cursor: pointer;
background: white;
}
@@ -30,6 +30,7 @@
right: 10%;
max-width: 400px;
overflow: hidden;
+ z-index: 1000;
transition: max-height 0.5s;
}
--
GitLab
From 8805f1857c1299d39a0a76f908b7c3ce276225df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:31:18 -0600
Subject: [PATCH 05/18] Se crea el componente y los estilos de la zona donde se
agrega la imagen
---
.../image_dropzone/assets/css/styles.css | 27 +++++++
.../image_dropzone/image_dropzone.tsx | 73 +++++++++++++++++++
2 files changed, 100 insertions(+)
create mode 100644 web/src/components/image_dropzone/assets/css/styles.css
create mode 100644 web/src/components/image_dropzone/image_dropzone.tsx
diff --git a/web/src/components/image_dropzone/assets/css/styles.css b/web/src/components/image_dropzone/assets/css/styles.css
new file mode 100644
index 00000000..e5e00a1a
--- /dev/null
+++ b/web/src/components/image_dropzone/assets/css/styles.css
@@ -0,0 +1,27 @@
+.image_dropzone_container {
+ width: 90%;
+}
+
+.image_dropzone {
+ cursor: pointer;
+ border-color: #eeeeee;
+ border-style: dashed;
+ background-color: #fafafa;
+ outline: none;
+ color: #bdbdbd;
+ aspect-ratio: 1/1;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
+.image_dropzone:hover {
+ border-color: rgb(106, 188, 226);
+ color: rgb(43, 38, 38);
+}
+
+.image_dropzone img {
+ height: 100%;
+ width: 100%;
+ object-fit: contain;
+}
\ No newline at end of file
diff --git a/web/src/components/image_dropzone/image_dropzone.tsx b/web/src/components/image_dropzone/image_dropzone.tsx
new file mode 100644
index 00000000..add3c59c
--- /dev/null
+++ b/web/src/components/image_dropzone/image_dropzone.tsx
@@ -0,0 +1,73 @@
+import { ToastContainer, toast } from 'react-toastify';
+import './assets/css/styles.css'
+import { useDropzone } from "react-dropzone";
+import { useState } from 'react';
+import "react-toastify/dist/ReactToastify.css";
+import { UseFormSetValue } from 'react-hook-form';
+import { TownFormValues } from '../../infraestructure/entities/town_form_values';
+
+interface props {
+ setValue : UseFormSetValue
+}
+
+export const ImageDropzone = ({setValue}: props) => {
+ const MAX_SIZE = 10485760;
+ const [preview, setPreview] = useState(null);
+ const {fileRejections,getRootProps, getInputProps} = useDropzone(
+ {
+ multiple: false,
+ maxSize: MAX_SIZE,
+ accept: {
+ 'image/jpeg': [],
+ 'image/png': []
+ },
+ onDrop(acceptedFiles, fileRejections) {
+ const file = new FileReader;
+
+ fileRejections.map(({file, errors}) => (
+ toast.error(errors[0].message, {
+ position: "bottom-right",
+ autoClose: 1500,
+ hideProgressBar: false,
+ closeOnClick: true,
+ pauseOnHover: false,
+ draggable: true,
+ progress: undefined,
+ theme: "colored"
+ })));
+
+ acceptedFiles.map((file)=>{
+ {setValue('imageURL',file)}
+ });
+
+ file.onload = () => {
+ setPreview(file.result);
+ };
+
+ file.readAsDataURL(acceptedFiles[0]);
+ }
+ }
+ );
+
+ return (
+
+
+
+ {preview ? (
+
+ ) : (
+
Arrastra tu imagen o seleccionala dando click aquí.
+ )}
+
+
+
+
+ );
+}
\ No newline at end of file
--
GitLab
From c6b7cd41f87b2e8c1b136a4dba83e04042534f1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:32:08 -0600
Subject: [PATCH 06/18] Se crea el modelo para guardar a un estado como objeto
---
web/src/data/models/prod/StateModel.ts | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 web/src/data/models/prod/StateModel.ts
diff --git a/web/src/data/models/prod/StateModel.ts b/web/src/data/models/prod/StateModel.ts
new file mode 100644
index 00000000..41f2f827
--- /dev/null
+++ b/web/src/data/models/prod/StateModel.ts
@@ -0,0 +1,5 @@
+export interface StateModel {
+ stateId: number;
+ name: string;
+ imageURL: string;
+}
\ No newline at end of file
--
GitLab
From 9d07462ea2165346840d79e9c83632e4cd226bab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:32:43 -0600
Subject: [PATCH 07/18] Se elimina estilo que no se utiliza
---
web/src/components/sidebar_header/assets/css/styles.css | 4 ----
1 file changed, 4 deletions(-)
diff --git a/web/src/components/sidebar_header/assets/css/styles.css b/web/src/components/sidebar_header/assets/css/styles.css
index f47166b7..e8c78817 100644
--- a/web/src/components/sidebar_header/assets/css/styles.css
+++ b/web/src/components/sidebar_header/assets/css/styles.css
@@ -4,8 +4,4 @@
display: flex;
align-items: center;
padding: 0 20px;
-}
-
-.sidebar_header_content{
-
}
\ No newline at end of file
--
GitLab
From ab69c340514b06c303439de334f98f304e9a2721 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:34:09 -0600
Subject: [PATCH 08/18] Se crea el componente y los estilos para la ventana de
registro de pueblos
---
.../sa_panel_town_register/css/styles.css | 155 ++++++++++++++++++
.../sa_panel_town_register.tsx | 111 +++++++++++++
2 files changed, 266 insertions(+)
create mode 100644 web/src/components/sa_panel_town/sa_panel_town_register/css/styles.css
create mode 100644 web/src/components/sa_panel_town/sa_panel_town_register/sa_panel_town_register.tsx
diff --git a/web/src/components/sa_panel_town/sa_panel_town_register/css/styles.css b/web/src/components/sa_panel_town/sa_panel_town_register/css/styles.css
new file mode 100644
index 00000000..2445be2f
--- /dev/null
+++ b/web/src/components/sa_panel_town/sa_panel_town_register/css/styles.css
@@ -0,0 +1,155 @@
+*{
+ user-select: none;
+}
+
+.town_register_wrap {
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+ margin: auto;
+ width: 70vw;
+ height: 90vh;
+ background: green;
+ display: flex;
+ flex-direction: column;
+}
+
+.town_register_header {
+ display: flex;
+ width: 100%;
+ align-items: center;
+ justify-content: center;
+ padding: 5px;
+}
+
+.town_register_close_btn{
+ display: inline-block;
+ cursor: pointer;
+ position: absolute;
+ right: 5px;
+}
+
+.town_register_content {
+ background: white;
+ width: 100%;
+ flex-grow: 1;
+ display: flex;
+ flex-direction: column;
+}
+
+.town_register_content form{
+ display: flex;
+ flex-direction: column;
+ flex-grow: 1;
+}
+
+.town_description_image_cont {
+ width: 100%;
+ background: lightgray;
+ flex-grow: 1;
+ display: flex;
+ flex-direction: row;
+}
+
+.town_desc{
+ height: 100%;
+ width: 55%;
+ display: flex;
+ flex-direction: column;
+ padding: 20px;
+}
+
+.image_container {
+ height: 100%;
+ width: 45%;
+ background: white;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+}
+
+.image_container div {
+ justify-content: center;
+ align-items: center;
+}
+
+.town_desc div{
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.towm_desc_input_cnt{
+ height: 100%;
+ width: 100%;
+ flex-grow: 1;
+}
+
+.towm_desc_input_cnt textarea{
+ width: 100%;;
+ height: 100%;
+ padding: 5px;
+ overflow-y: auto;
+ resize: none;
+}
+
+.state_select{
+ display: flex;
+ flex-direction: column;
+ width: 40%;
+ justify-content: center;
+ align-items: center;
+}
+
+.state_select label {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ margin: 0 auto;
+}
+
+.state_select select{
+ width: 60%;
+}
+
+.town_name_state_input {
+ display: flex;
+ flex-direction: row;
+ margin-top: 5px;
+ margin-bottom: 5px;
+}
+
+.town_name_input{
+ width: 40%;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.town_name_input input{
+ width: 70%;
+ border-radius: 3px;
+}
+
+.town_name_input .form_input::focus {
+ border-width: 1px;
+}
+
+.language_change_cnt{
+ width: 20%;
+}
+
+.change_lang_btn{
+ cursor: pointer;
+}
+
+.language_change_cnt {
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
+ align-items: center;
+}
\ No newline at end of file
diff --git a/web/src/components/sa_panel_town/sa_panel_town_register/sa_panel_town_register.tsx b/web/src/components/sa_panel_town/sa_panel_town_register/sa_panel_town_register.tsx
new file mode 100644
index 00000000..9f796dd5
--- /dev/null
+++ b/web/src/components/sa_panel_town/sa_panel_town_register/sa_panel_town_register.tsx
@@ -0,0 +1,111 @@
+import { faWindowClose, faLanguage } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import './css/styles.css'
+import { ImageDropzone } from "../../image_dropzone/image_dropzone";
+import { Dispatch, SetStateAction, useState } from "react";
+import { useTownRegister } from "../../../hooks/useTownRegister";
+
+interface props {
+ setWindowActive: Dispatch>,
+ setShowRegisterPanel: Dispatch>
+}
+
+export const SuperadminPanelTownRegister = ({setWindowActive, setShowRegisterPanel}:props) => {
+ const {
+ statesList,
+ register,
+ setValue,
+ handleSubmit,
+ errors,
+ onSubmit
+ } = useTownRegister();
+ const [isEnglish, setIsEnglish] = useState(false);
+ const [spanishDescription, setSpanishDescription] = useState("");
+ const [englishDescription, setEnglishDescription] = useState("");
+
+ return (
+
+
+ Registra el pueblo mágico
+ {setShowRegisterPanel(false); setWindowActive(false)}}/>
+
+
+
+ );
+}
\ No newline at end of file
--
GitLab
From 37bcfa665580135eaea231806e00437460f8d111 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:34:53 -0600
Subject: [PATCH 09/18] Se crea un error personalizado
---
web/src/errors/CustomError.ts | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 web/src/errors/CustomError.ts
diff --git a/web/src/errors/CustomError.ts b/web/src/errors/CustomError.ts
new file mode 100644
index 00000000..1c8c5434
--- /dev/null
+++ b/web/src/errors/CustomError.ts
@@ -0,0 +1,15 @@
+export type CustomErrorContent = {
+ message: string;
+ context?: { [key: string]: any };
+};
+
+export abstract class CustomError extends Error {
+ abstract readonly statusCode: number;
+ abstract readonly logging: boolean;
+
+ constructor(message: string) {
+ super(message);
+ Object.setPrototypeOf(this, CustomError.prototype);
+ }
+}
+
\ No newline at end of file
--
GitLab
From cde33113f87b7bab2ebf46a182a67d24969466f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:35:06 -0600
Subject: [PATCH 10/18] Se crea el error de no autorizado
---
web/src/errors/UnautherizedError.ts | 31 +++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 web/src/errors/UnautherizedError.ts
diff --git a/web/src/errors/UnautherizedError.ts b/web/src/errors/UnautherizedError.ts
new file mode 100644
index 00000000..4b772a60
--- /dev/null
+++ b/web/src/errors/UnautherizedError.ts
@@ -0,0 +1,31 @@
+import { CustomError } from "./CustomError";
+
+export default class UnauthorizedError extends CustomError {
+ private static readonly _statusCode = 401;
+ private readonly _code: number;
+ private readonly _logging: boolean;
+ private readonly _context: { [key: string]: any };
+
+ constructor(params?: { code?: number; message?: string; logging?: boolean; context?: { [key: string]: any } }) {
+ const { code, message, logging } = params || {};
+
+ super(message || "You are not authorized");
+ this._code = code || UnauthorizedError._statusCode;
+ this._logging = logging || false;
+ this._context = params?.context || {};
+
+ Object.setPrototypeOf(this, UnauthorizedError.prototype);
+ }
+
+ get errors() {
+ return [{ message: this.message, context: this._context }];
+ }
+
+ get statusCode() {
+ return this._code;
+ }
+
+ get logging() {
+ return this._logging;
+ }
+}
--
GitLab
From d4046a7e30dddaf074225c5f42670ed93f354b4a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:36:07 -0600
Subject: [PATCH 11/18] =?UTF-8?q?Se=20desactivan=20algunos=20botones=20cua?=
=?UTF-8?q?ndo=20la=20ventana=20de=20registrar=20pueblo=20est=C3=A1=20acti?=
=?UTF-8?q?va?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../sa_panel_town_screen.tsx | 24 ++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/web/src/components/sa_panel_town/sa_panel_town_screen/sa_panel_town_screen.tsx b/web/src/components/sa_panel_town/sa_panel_town_screen/sa_panel_town_screen.tsx
index dc7bab0f..5d70ed4b 100644
--- a/web/src/components/sa_panel_town/sa_panel_town_screen/sa_panel_town_screen.tsx
+++ b/web/src/components/sa_panel_town/sa_panel_town_screen/sa_panel_town_screen.tsx
@@ -1,14 +1,32 @@
+import { Dispatch, SetStateAction, useState } from 'react';
+import { SuperadminPanelTownRegister } from '../sa_panel_town_register/sa_panel_town_register';
import './css/styles.css'
-export const SuperadminPanelTownScreen = () => {
+interface props {
+ windowActive: boolean;
+ setWindowActive: Dispatch>;
+}
+
+export const SuperadminPanelTownScreen = ({windowActive,setWindowActive}:props) => {
+ const [showRegisterPanel, setShowRegisterPanel] = useState(false);
+
return (
Administrar pueblos mágicos
-
+
-
+ {showRegisterPanel
+ &&
+ }
);
--
GitLab
From c4586ead8b9c6a9e89309634b4527e8687c85247 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:38:18 -0600
Subject: [PATCH 12/18] =?UTF-8?q?Se=20modifica=20el=20bot=C3=B3n=20de=20ag?=
=?UTF-8?q?regar=20pueblo=20para=20que=20cambie=20el=20cursor=20cuando=20e?=
=?UTF-8?q?st=C3=A1=20sobre=20=C3=A9l?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../sa_panel_town/sa_panel_town_screen/css/styles.css | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/web/src/components/sa_panel_town/sa_panel_town_screen/css/styles.css b/web/src/components/sa_panel_town/sa_panel_town_screen/css/styles.css
index 2713080d..d7bbeb9c 100644
--- a/web/src/components/sa_panel_town/sa_panel_town_screen/css/styles.css
+++ b/web/src/components/sa_panel_town/sa_panel_town_screen/css/styles.css
@@ -11,10 +11,12 @@
width: 100%;
align-items: center;
justify-content: center;
+ padding: 5px;
}
-.town_add_btn{
+.town_panel_header .town_add_btn{
+ display: inline-block;
+ cursor: pointer;
position: absolute;
- top: 50%;
right: 5px;
}
\ No newline at end of file
--
GitLab
From c40a2e9e5f8b165e83b7e381951b42296ecc521d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:38:58 -0600
Subject: [PATCH 13/18] =?UTF-8?q?Se=20desactivan=20algunas=20funciones=20c?=
=?UTF-8?q?uando=20la=20ventana=20de=20registro=20de=20pueblo=20est=C3=A1?=
=?UTF-8?q?=20activa?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../super_admin_home_page.tsx | 35 ++++++++++++++-----
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/web/src/pages/home/super_admin_page/super_admin_home_page.tsx b/web/src/pages/home/super_admin_page/super_admin_home_page.tsx
index 9c6d16fa..8fc5769f 100644
--- a/web/src/pages/home/super_admin_page/super_admin_home_page.tsx
+++ b/web/src/pages/home/super_admin_page/super_admin_home_page.tsx
@@ -3,8 +3,6 @@ import './assets/styles/style.css';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faMonument, faSignOut, faUser, faUserTie } from "@fortawesome/free-solid-svg-icons";
import { useState } from "react";
-import { useAuth } from "../../../context/auth_context";
-import { Link } from "react-router-dom";
import { AdminPanelNavBar } from "../../../components/admin_panel_navbar/admin_navbar";
import { SidebarHeader } from "../../../components/sidebar_header/sidebar_header";
import { SuperadminPanelTownScreen } from "../../../components/sa_panel_town/sa_panel_town_screen/sa_panel_town_screen";
@@ -12,28 +10,47 @@ import { SuperadminPanelAdminScreen } from "../../../components/sa_panel_admin/s
export const SuperAdminHomePage = () => {
const [collapsed, setCollapsed] = useState(true);
+ const [windowActive, setWindowActive] = useState(false);
const [townPanel, setTownPanel] = useState(true);
return (
setCollapsed(false)}
- onMouseOut={() => setCollapsed(true)}>
+ onMouseOver={() => {
+ windowActive ?
+ setCollapsed(true)
+ :
+ setCollapsed(false)
+ }}
+ onMouseOut={() => setCollapsed(true)}
+
+ >
-
+
- {townPanel ? : }
+ {townPanel
+ ?
+
+ :
+ }
--
GitLab
From a2f6d7b96b110bc7c4b46d5d4b16e03c3c6d825f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:39:47 -0600
Subject: [PATCH 14/18] Se crea la interface utilizada para enviar el pueblo en
el formulario
---
web/src/infraestructure/entities/town_form_values.ts | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 web/src/infraestructure/entities/town_form_values.ts
diff --git a/web/src/infraestructure/entities/town_form_values.ts b/web/src/infraestructure/entities/town_form_values.ts
new file mode 100644
index 00000000..ffd11e36
--- /dev/null
+++ b/web/src/infraestructure/entities/town_form_values.ts
@@ -0,0 +1,7 @@
+export interface TownFormValues {
+ name : string
+ descriptionES : string
+ descriptionEN : string
+ state : string
+ imageURL : File
+}
\ No newline at end of file
--
GitLab
From 3a83ab40c12695d3c787d216f62afbdd7817624b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:40:44 -0600
Subject: [PATCH 15/18] =?UTF-8?q?Se=20crean=20las=20interfaces=20para=20la?=
=?UTF-8?q?=20l=C3=B3gica=20detras=20de=20obtener=20los=20estados=20y=20re?=
=?UTF-8?q?gistrar=20un=20pueblo?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/src/infraestructure/datasources/town_datasource.ts | 7 +++++++
web/src/infraestructure/repositories/town_repository.ts | 7 +++++++
2 files changed, 14 insertions(+)
create mode 100644 web/src/infraestructure/datasources/town_datasource.ts
create mode 100644 web/src/infraestructure/repositories/town_repository.ts
diff --git a/web/src/infraestructure/datasources/town_datasource.ts b/web/src/infraestructure/datasources/town_datasource.ts
new file mode 100644
index 00000000..229d5124
--- /dev/null
+++ b/web/src/infraestructure/datasources/town_datasource.ts
@@ -0,0 +1,7 @@
+import { State } from "../entities/state";
+import { TownFormValues } from "../entities/town_form_values";
+
+export interface TownDatasourceInf{
+ getStates(): Promise;
+ registerTown(form: TownFormValues): void;
+}
\ No newline at end of file
diff --git a/web/src/infraestructure/repositories/town_repository.ts b/web/src/infraestructure/repositories/town_repository.ts
new file mode 100644
index 00000000..6a919e9f
--- /dev/null
+++ b/web/src/infraestructure/repositories/town_repository.ts
@@ -0,0 +1,7 @@
+import { State } from "../entities/state";
+import { TownFormValues } from "../entities/town_form_values";
+
+export interface TownRepositoryInf{
+ getStates(): Promise;
+ registerTown(form: TownFormValues): void;
+}
\ No newline at end of file
--
GitLab
From 1c77c14408f34c2ab1ec2da110f74a288423a878 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:41:53 -0600
Subject: [PATCH 16/18] Se implementa el repositorio utilizado para obtener los
estados y registrar un pueblo
---
.../data/repositories/prod/town_repository.ts | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 web/src/data/repositories/prod/town_repository.ts
diff --git a/web/src/data/repositories/prod/town_repository.ts b/web/src/data/repositories/prod/town_repository.ts
new file mode 100644
index 00000000..2ca49d14
--- /dev/null
+++ b/web/src/data/repositories/prod/town_repository.ts
@@ -0,0 +1,16 @@
+import { TownDatasourceInf } from "../../../infraestructure/datasources/town_datasource";
+import { State } from "../../../infraestructure/entities/state";
+import { TownFormValues } from "../../../infraestructure/entities/town_form_values";
+import { TownRepositoryInf } from "../../../infraestructure/repositories/town_repository";
+
+export class TownRepositoryProd implements TownRepositoryInf{
+ constructor(
+ private datasource: TownDatasourceInf
+ ){}
+ async getStates(): Promise {
+ return this.datasource.getStates();
+ }
+ async registerTown(form: TownFormValues): Promise {
+ return this.datasource.registerTown(form);
+ }
+}
\ No newline at end of file
--
GitLab
From c22a934ba1ee5f4107ea99391924e81b67401b2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:42:20 -0600
Subject: [PATCH 17/18] =?UTF-8?q?Se=20implementa=20la=20l=C3=B3gica=20para?=
=?UTF-8?q?=20obtener=20los=20estados=20y=20registrar=20un=20pueblo?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../data/datasources/prod/town_datasource.ts | 43 +++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 web/src/data/datasources/prod/town_datasource.ts
diff --git a/web/src/data/datasources/prod/town_datasource.ts b/web/src/data/datasources/prod/town_datasource.ts
new file mode 100644
index 00000000..f398dcff
--- /dev/null
+++ b/web/src/data/datasources/prod/town_datasource.ts
@@ -0,0 +1,43 @@
+import axios from "axios";
+import { APIUrl } from "../../../constants/api_url";
+import { TownDatasourceInf } from "../../../infraestructure/datasources/town_datasource";
+import { StateModel } from "../../models/prod/StateModel";
+import { State } from "../../../infraestructure/entities/state";
+import { TownFormValues } from "../../../infraestructure/entities/town_form_values";
+import UnauthorizedError from "../../../errors/UnautherizedError";
+
+export class TownDatasourceProd implements TownDatasourceInf{
+ async getStates(): Promise {
+ const {data} = await axios.get(APIUrl+"/state");
+ const states = data.map((value) => {
+ const state: State = {
+ stateId : value.stateId,
+ name: value.name,
+ imageURL: value.imageURL
+ }
+ return state;
+ })
+
+ return states;
+ }
+
+ async registerTown(form: TownFormValues): Promise {
+ const formToSend = new FormData;
+ formToSend.append('name',form.name);
+ formToSend.append('descriptionES',form.descriptionES);
+ formToSend.append('descriptionEN',form.descriptionEN);
+ formToSend.append('state', form.state);
+ formToSend.append('image',form.imageURL);
+
+ const headers = {
+ 'Content-Type': 'multipart/form-data'
+ };
+
+ const {status, data} = await axios.post(APIUrl + '/town', formToSend,{headers});
+ if (status === 401) {
+ throw new UnauthorizedError({code: 401, message: 'Unauthorized'});
+ }else {
+ console.log(data);
+ }
+ }
+}
\ No newline at end of file
--
GitLab
From 3d9f693b80d485b74918cc1893bc36b4ebb17814 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Omar=20Luna=20Hern=C3=A1ndez?= <42101656@uaz.edu.mx>
Date: Fri, 26 Apr 2024 09:43:24 -0600
Subject: [PATCH 18/18] =?UTF-8?q?Se=20crea=20el=20custom=20hook=20utilizad?=
=?UTF-8?q?o=20para=20llamar=20a=20los=20m=C3=A9todos=20de=20obtener=20tod?=
=?UTF-8?q?os=20los=20estados=20y=20registrar=20un=20pueblo?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/src/hooks/useTownRegister.tsx | 41 +++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 web/src/hooks/useTownRegister.tsx
diff --git a/web/src/hooks/useTownRegister.tsx b/web/src/hooks/useTownRegister.tsx
new file mode 100644
index 00000000..1c5bf209
--- /dev/null
+++ b/web/src/hooks/useTownRegister.tsx
@@ -0,0 +1,41 @@
+import { useEffect, useState } from "react";
+import { TownDatasourceProd } from "../data/datasources/prod/town_datasource"
+import { TownRepositoryProd } from "../data/repositories/prod/town_repository";
+import { State } from "../infraestructure/entities/state";
+import { SubmitHandler, useForm } from "react-hook-form";
+import { TownFormValues } from "../infraestructure/entities/town_form_values";
+
+const townDatasource = new TownDatasourceProd();
+const townRepository = new TownRepositoryProd(townDatasource);
+
+export const useTownRegister = () => {
+ const [statesList, setStatesList] = useState(null);
+ const {
+ register,
+ handleSubmit,
+ setError,
+ formState: {errors},
+ setValue
+ } = useForm();
+
+ useEffect(() => {
+ const getStates = async () => {
+ const states = await townRepository.getStates();
+ setStatesList(states);
+ }
+ getStates();
+ }, []);
+
+ const onSubmit: SubmitHandler = (data: TownFormValues) => {
+ const fetch = async () => {
+ try{
+ await townRepository.registerTown(data);
+ }catch(error: any){
+
+ }
+ }
+ fetch();
+ }
+
+ return {statesList, register, handleSubmit, errors, onSubmit, setValue};
+}
\ No newline at end of file
--
GitLab