diff --git a/.env.development b/.env.development
index 141be67..327d04f 100644
--- a/.env.development
+++ b/.env.development
@@ -1,2 +1,4 @@
NEXT_PUBLIC_GOOGLE_CLIENT_ID=xxxx
-NEXT_PUBLIC_GOOGLE_USER_SCRIPT_URL=xxx
\ No newline at end of file
+NEXT_PUBLIC_GOOGLE_USER_SCRIPT_URL=xxxx
+NEXT_PUBLIC_GOOGLE_PLACES_SCRIPT_URL=xxxx
+NEXT_PUBLIC_GOOGLE_FAVORITE_PLACES_SCRIPT_URL=xxxx
\ No newline at end of file
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index a9bf156..5fdbc54 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -27,6 +27,8 @@ jobs:
env:
NEXT_PUBLIC_GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
NEXT_PUBLIC_GOOGLE_USER_SCRIPT_URL: ${{ secrets.GOOGLE_USER_SCRIPT_URL }}
+ NEXT_PUBLIC_GOOGLE_PLACES_SCRIPT_URL: ${{ secrets.GOOGLE_PLACES_SCRIPT_URL }}
+ NEXT_PUBLIC_GOOGLE_FAVORITE_PLACES_SCRIPT_URL: ${{ secrets.GOOGLE_FAVORITE_PLACES_SCRIPT_URL }}
run: yarn build
- name: Deploy to GitHub Pages
diff --git a/app/favoritos/page.tsx b/app/favoritos/page.tsx
index 35ba7f5..95249c0 100644
--- a/app/favoritos/page.tsx
+++ b/app/favoritos/page.tsx
@@ -1,4 +1,3 @@
-// app/routes/about/page.tsx
export default function FavoritesPage() {
return (
diff --git a/app/page.tsx b/app/page.tsx
index c74efed..8435e59 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -1,16 +1,19 @@
"use client";
-import PlaceCard from "@/components/PlaceCard";
import Filter from "@/components/Filters";
import NavbarSearch from "@/components/NavbarSearch";
-
-import usePlaces, { Place } from "@/hooks/usePlaces";
-
+import PlaceCard from "@/components/PlaceCard";
+import { useAuth } from "@/contexts/AuthContext";
+import { useFavorites } from "@/contexts/FavoritePlacesContext";
+import { usePlacesContext } from "@/contexts/PlacesContext";
+import { Place } from "@/domains/Places/types";
import { Button, Card, CardBody } from "@nextui-org/react";
import { useEffect, useState } from "react";
import { FaArrowLeft, FaArrowRight, FaSearch } from "react-icons/fa";
export default function HomePage() {
- const { places } = usePlaces();
+ const { user, isAnonymous } = useAuth();
+ const { favorites, fetchFavorites, isLoading } = useFavorites();
+ const { places, loading } = usePlacesContext();
const [currentPage, setCurrentPage] = useState(1);
const [filteredPlaces, setFilteredPlaces] = useState
(places);
const [searchValue, setSearchValue] = useState("");
@@ -45,6 +48,12 @@ export default function HomePage() {
setCurrentPage(1);
}, [searchValue, places]);
+ useEffect(() => {
+ if (user && !isAnonymous && favorites.length === 0)
+ fetchFavorites(user.internalId);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [user, isAnonymous]);
+
const handleSearch = (value: string) => {
setSearchValue(value);
};
@@ -74,17 +83,37 @@ export default function HomePage() {
- {currentPlaces.map((place) => (
-
- ))}
+ {loading || isLoading
+ ? Array.from({ length: 9 }).map((_, index) => (
+
+
+
+
+
+
+
+
+
+ ))
+ : currentPlaces.map((place) => (
+
f === place.id)}
+ />
+ ))}
- {currentPlaces.length > 0 ? (
+ {!loading && currentPlaces.length > 0 ? (
}
diff --git a/app/providers.tsx b/app/providers.tsx
index 7365762..45cd133 100644
--- a/app/providers.tsx
+++ b/app/providers.tsx
@@ -1,6 +1,7 @@
"use client";
-
import { AuthProvider } from "@/contexts/AuthContext";
+import { FavoriteProvider } from "@/contexts/FavoritePlacesContext";
+import { PlacesProvider } from "@/contexts/PlacesContext";
import { NextUIProvider } from "@nextui-org/system";
import { ThemeProvider as NextThemesProvider } from "next-themes";
import { ThemeProviderProps } from "next-themes/dist/types";
@@ -28,7 +29,11 @@ const Providers: React.FC
= ({ children, themeProps }) => {
return (
- {children}
+
+
+ {children}
+
+
);
diff --git a/components/Footer/index.tsx b/components/Footer/index.tsx
index 02c5245..d727c40 100644
--- a/components/Footer/index.tsx
+++ b/components/Footer/index.tsx
@@ -1,4 +1,3 @@
-// app/components/Footer.tsx
export default function Footer() {
return (