From 13adcf89ff87358e0c216be1434962385e44bc50 Mon Sep 17 00:00:00 2001 From: zealves99 Date: Thu, 29 May 2025 18:50:54 +0100 Subject: [PATCH] feat: home page translations Added translations for the home page --- .../app/dashboard/layout/favorites-page.tsx | 2 +- .../marketplace/filters-section.tsx | 162 +++++++++++------- .../components/marketplace/marketplace.tsx | 34 ++-- .../components/marketplace/search-bar.tsx | 39 +++-- frontend/vizzy/messages/en.json | 24 +++ frontend/vizzy/messages/pt.json | 24 +++ 6 files changed, 192 insertions(+), 93 deletions(-) diff --git a/frontend/vizzy/app/dashboard/layout/favorites-page.tsx b/frontend/vizzy/app/dashboard/layout/favorites-page.tsx index a9d0ae96..b1e2d23e 100644 --- a/frontend/vizzy/app/dashboard/layout/favorites-page.tsx +++ b/frontend/vizzy/app/dashboard/layout/favorites-page.tsx @@ -10,7 +10,7 @@ import { PaginationControls } from '@/components/marketplace/pagination-controls import { useTranslations } from 'next-intl'; export function FavoritesPage() { - const t = useTranslations('favoritesPage'); + const t = useTranslations('dashboard.favoritesPage'); const [favorites, setFavorites] = useState([]); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); diff --git a/frontend/vizzy/components/marketplace/filters-section.tsx b/frontend/vizzy/components/marketplace/filters-section.tsx index 47c0ef1f..2a10cdf5 100644 --- a/frontend/vizzy/components/marketplace/filters-section.tsx +++ b/frontend/vizzy/components/marketplace/filters-section.tsx @@ -1,27 +1,33 @@ -"use client" +'use client'; -import { useState } from "react" -import { ChevronDown, ChevronUp, MapPin, SlidersHorizontal } from "lucide-react" -import { Checkbox } from "@/components/ui/forms/checkbox" -import { Label } from "@/components/ui/common/label" +import { useState } from 'react'; +import { + ChevronDown, + ChevronUp, + MapPin, + SlidersHorizontal, +} from 'lucide-react'; +import { Checkbox } from '@/components/ui/forms/checkbox'; +import { Label } from '@/components/ui/common/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, -} from "@/components/ui/forms/select" -import { Tabs, TabsList, TabsTrigger } from "@/components/ui/navigation/tabs" -import { cn } from "@/lib/utils/shadcn-merge" -import { Button } from "@/components/ui/common/button" +} from '@/components/ui/forms/select'; +import { Tabs, TabsList, TabsTrigger } from '@/components/ui/navigation/tabs'; +import { cn } from '@/lib/utils/shadcn-merge'; +import { Button } from '@/components/ui/common/button'; +import { useTranslations } from 'next-intl'; interface FiltersSectionProps { - listingType: string - handleTypeChange: (value: string) => void - userLocation: { lat: number; lon: number; full_address: string } | null - useLocation: boolean - handleLocationToggle: (checked: boolean) => void - locationDistance: string - handleDistanceChange: (value: string) => void + listingType: string; + handleTypeChange: (value: string) => void; + userLocation: { lat: number; lon: number; full_address: string } | null; + useLocation: boolean; + handleLocationToggle: (checked: boolean) => void; + locationDistance: string; + handleDistanceChange: (value: string) => void; } export function FiltersSection({ @@ -33,7 +39,8 @@ export function FiltersSection({ locationDistance, handleDistanceChange, }: FiltersSectionProps) { - const [isExpanded, setIsExpanded] = useState(false) + const [isExpanded, setIsExpanded] = useState(false); + const t = useTranslations('marketplace'); if (!userLocation) { return null; @@ -51,18 +58,31 @@ export function FiltersSection({ onClick={() => setIsExpanded(!isExpanded)} > - Filters - {isExpanded ? : } + {t('filters.title')} + {isExpanded ? ( + + ) : ( + + )}
- + - All - Sale - Swap - Rental - Free + {t('filterBadge.all')} + {t('filterBadge.sale')} + {t('filterBadge.swap')} + + {t('filterBadge.rental')} + + + {t('filterBadge.giveaway')} +
@@ -71,56 +91,68 @@ export function FiltersSection({ {/* Expanded Filters */}
{/* Location Filter */} - -
-

Location

-
- -
- -

- - {userLocation.full_address} -

-
-
- {useLocation && ( -
- - -
- )} +
+

{t('filters.location')}

+
+ +
+ +

+ + {userLocation.full_address} +

+
+ + {useLocation && ( +
+ + +
+ )} +
- ) + ); } diff --git a/frontend/vizzy/components/marketplace/marketplace.tsx b/frontend/vizzy/components/marketplace/marketplace.tsx index 1e4e6091..d2c30e72 100644 --- a/frontend/vizzy/components/marketplace/marketplace.tsx +++ b/frontend/vizzy/components/marketplace/marketplace.tsx @@ -1,10 +1,11 @@ -"use client" +'use client'; -import { useListings } from "@/hooks/use-listings" -import { SearchBar } from "./search-bar" -import { FiltersSection } from "./filters-section" -import { ListingsGrid } from "./listings-grid" -import { PaginationControls } from "./pagination-controls" +import { useListings } from '@/hooks/use-listings'; +import { SearchBar } from './search-bar'; +import { FiltersSection } from './filters-section'; +import { ListingsGrid } from './listings-grid'; +import { PaginationControls } from './pagination-controls'; +import { useTranslations } from 'next-intl'; export default function Marketplace() { const { @@ -23,16 +24,21 @@ export default function Marketplace() { handleTypeChange, handleLocationToggle, handleDistanceChange, - } = useListings() + } = useListings(); + const t = useTranslations('marketplace'); return (
-

Find what you need

+

{t('title')}

{/* Search Bar */} - + {/* Filters Section */}
-

Latest Listings

+

{t('latestListings')}

{/* Pagination */} - +
- ) + ); } diff --git a/frontend/vizzy/components/marketplace/search-bar.tsx b/frontend/vizzy/components/marketplace/search-bar.tsx index a6e0c641..d53fe05b 100644 --- a/frontend/vizzy/components/marketplace/search-bar.tsx +++ b/frontend/vizzy/components/marketplace/search-bar.tsx @@ -1,40 +1,49 @@ -"use client" - -import { Search, X } from "lucide-react" -import { Button } from "@/components/ui/common/button" -import { Input } from "@/components/ui/forms/input" +'use client'; +import { Search, X } from 'lucide-react'; +import { Button } from '@/components/ui/common/button'; +import { Input } from '@/components/ui/forms/input'; +import { useTranslations } from 'next-intl'; interface SearchBarProps { - searchInput: string - setSearchInput: (value: string) => void - handleSearch: () => void + searchInput: string; + setSearchInput: (value: string) => void; + handleSearch: () => void; } -export function SearchBar({ searchInput, setSearchInput, handleSearch }: SearchBarProps) { +export function SearchBar({ + searchInput, + setSearchInput, + handleSearch, +}: SearchBarProps) { + const t = useTranslations('marketplace'); return (
setSearchInput(e.target.value)} - onKeyDown={(e) => e.key === "Enter" && handleSearch()} + onKeyDown={(e) => e.key === 'Enter' && handleSearch()} /> {searchInput && ( )} -
- ) + ); } diff --git a/frontend/vizzy/messages/en.json b/frontend/vizzy/messages/en.json index e8f46cd4..920d5a08 100644 --- a/frontend/vizzy/messages/en.json +++ b/frontend/vizzy/messages/en.json @@ -391,5 +391,29 @@ "description": "Mark listings as favorites to see them here." } } + }, + "marketplace": { + "title": "Find what you need", + "latestListings": "Latest Listings", + "searchPlaceholder": "Search for items...", + "searchButton": "Search", + "noResults": "No results found", + "noResultsDescription": "Try different filters or search for something else.", + "seeAll": "See all", + "filters": { + "title": "Filters", + "clear": "Clear Filters", + "location": "Location", + "locationToggle": "Show listings near me", + "distance": "Distance", + "distancePlaceholder": "Select maximum distance" + }, + "filterBadge": { + "sale": "Sale", + "swap": "Swap", + "rental": "Rental", + "giveaway": "Free", + "all": "All" + } } } diff --git a/frontend/vizzy/messages/pt.json b/frontend/vizzy/messages/pt.json index cc1dc2f8..93020134 100644 --- a/frontend/vizzy/messages/pt.json +++ b/frontend/vizzy/messages/pt.json @@ -394,5 +394,29 @@ "description": "Marque anúncios como favoritos para vê-los aqui." } } + }, + "marketplace": { + "title": "Encontra o que precisas", + "latestListings": "Anúncios Recentes", + "searchPlaceholder": "Pesquisa por itens...", + "searchButton": "Pesquisar", + "noResults": "Nenhum resultado encontrado", + "noResultsDescription": "Tente diferentes filtros ou procure por algo diferente.", + "seeAll": "Ver todos", + "filters": { + "title": "Filtros", + "clear": "Limpar Filtros", + "location": "Localização", + "locationToggle": "Mostrar anúncios perto de mim", + "distance": "Distância", + "distancePlaceholder": "Seleciona a distância máxima" + }, + "filterBadge": { + "sale": "Venda", + "swap": "Troca", + "rental": "Aluguer", + "giveaway": "Oferta", + "all": "Todos" + } } }