Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
refactor: cambia tipo "any" por interfaces correspondientes
Browse files Browse the repository at this point in the history
  • Loading branch information
Merlina committed Oct 3, 2024
1 parent a231eca commit ec96173
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const Navbar: React.FC = () => {
const [scrollPosition, setScrollPosition] = useState(0);
const [showModal, setShowModal] = useState<boolean>(false);
const [notificationsModal, setNotificationsModal] = useState<boolean>(false);
const [notifications, setNotifications] = useState<any[]>([])
// const [notifications, setNotifications] = useState<any[]>([])

const modalRef = useRef<HTMLDivElement | null>(null);
const currentClickRef = useRef<EventTarget | null>(null);
Expand Down Expand Up @@ -246,15 +246,15 @@ const Navbar: React.FC = () => {
ref={modalRef}>
<div className="flex flex-col items-center">
<h5 className="text-base font-medium text-[#05264E] mt-5">Your Notifications</h5>
{notifications && (
{/* {notifications && (
<div className="w-full">
<ul>
{notifications.map((notification) => (
<></>
))}
</ul>
</div>
)}
)} */}
</div>
</div>
)}
Expand Down
7 changes: 4 additions & 3 deletions src/pages/FincaInfo/FincaInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import { useGetFincaDataQuery } from '../../store/services/fincaApi';
import './FincaInfo.css';
import { Arbol, Hacienda } from '../../types/types';

const FincaInfo: React.FC = () => {

const { data: fincaData, isLoading, isError } = useGetFincaDataQuery();
const { data: fincaData, isLoading, isError } = useGetFincaDataQuery(1);

if (isLoading) {
return <div>Cargando...</div>;
Expand All @@ -17,7 +18,7 @@ const FincaInfo: React.FC = () => {

return (
<div className="finca-info-container">
{fincaData.map((finca: any) => (
{fincaData.map((finca: Hacienda) => (
<div key={finca.id} className="finca-info">
{/* Sección del título y descripción */}
<div className="finca-info-header">
Expand All @@ -37,7 +38,7 @@ const FincaInfo: React.FC = () => {
<span className="practice-icon" aria-hidden="true">🌳</span>
<h3>Árboles</h3>
<ul>
{finca.arbol.map((tree: any, index: number) => (
{finca.arbol.map((tree: Arbol, index: number) => (
<li key={index}>{tree.type}</li>
))}
</ul>
Expand Down
20 changes: 20 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,23 @@ export type GoogleAuthError = {
// Para propiedades desconocidas, usamos un tipo de unión
[key: string]: string | number | undefined;
};


export interface UserFinca {
name: string;
}

export interface Arbol {
active: boolean;
statusTree: "ARBOL_JOVEN" | string; // Puedes agregar más valores si los conoces
type: string;
user: UserFinca;
}

export interface Hacienda {
id: number;
name: string;
ubication: string;
practicesSustainable: string;
arbol: Arbol[];
}

0 comments on commit ec96173

Please sign in to comment.