Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/vizzy/app/dashboard/layout/favorites-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ListingBasic[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
Expand Down
162 changes: 97 additions & 65 deletions frontend/vizzy/components/marketplace/filters-section.tsx
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -33,7 +39,8 @@
locationDistance,
handleDistanceChange,
}: FiltersSectionProps) {
const [isExpanded, setIsExpanded] = useState(false)
const [isExpanded, setIsExpanded] = useState(false);
const t = useTranslations('marketplace');

if (!userLocation) {
return null;
Expand All @@ -51,18 +58,31 @@
onClick={() => setIsExpanded(!isExpanded)}
>
<SlidersHorizontal className="h-4 w-4" />
Filters
{isExpanded ? <ChevronUp className="h-3 w-3 ml-1" /> : <ChevronDown className="h-3 w-3 ml-1" />}
{t('filters.title')}

Check warning on line 61 in frontend/vizzy/components/marketplace/filters-section.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/filters-section.tsx#L61

Translation key 'filters.title' should match format 'MODULE.FEATURE.*'
{isExpanded ? (
<ChevronUp className="h-3 w-3 ml-1" />
) : (
<ChevronDown className="h-3 w-3 ml-1" />
)}
</Button>

<div className="flex-1 min-w-[200px]">
<Tabs defaultValue={listingType} className="w-full" onValueChange={handleTypeChange} value={listingType}>
<Tabs
defaultValue={listingType}
className="w-full"
onValueChange={handleTypeChange}
value={listingType}
>
<TabsList className="grid grid-cols-5 h-9">
<TabsTrigger value="all">All</TabsTrigger>
<TabsTrigger value="sale">Sale</TabsTrigger>
<TabsTrigger value="swap">Swap</TabsTrigger>
<TabsTrigger value="rental">Rental</TabsTrigger>
<TabsTrigger value="giveaway">Free</TabsTrigger>
<TabsTrigger value="all">{t('filterBadge.all')}</TabsTrigger>

Check warning on line 77 in frontend/vizzy/components/marketplace/filters-section.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/filters-section.tsx#L77

Translation key 'filterBadge.all' should match format 'MODULE.FEATURE.*'
<TabsTrigger value="sale">{t('filterBadge.sale')}</TabsTrigger>

Check warning on line 78 in frontend/vizzy/components/marketplace/filters-section.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/filters-section.tsx#L78

Translation key 'filterBadge.sale' should match format 'MODULE.FEATURE.*'
<TabsTrigger value="swap">{t('filterBadge.swap')}</TabsTrigger>

Check warning on line 79 in frontend/vizzy/components/marketplace/filters-section.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/filters-section.tsx#L79

Translation key 'filterBadge.swap' should match format 'MODULE.FEATURE.*'
<TabsTrigger value="rental">
{t('filterBadge.rental')}

Check warning on line 81 in frontend/vizzy/components/marketplace/filters-section.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/filters-section.tsx#L81

Translation key 'filterBadge.rental' should match format 'MODULE.FEATURE.*'
</TabsTrigger>
<TabsTrigger value="giveaway">
{t('filterBadge.giveaway')}

Check warning on line 84 in frontend/vizzy/components/marketplace/filters-section.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/filters-section.tsx#L84

Translation key 'filterBadge.giveaway' should match format 'MODULE.FEATURE.*'
</TabsTrigger>
</TabsList>
</Tabs>
</div>
Expand All @@ -71,56 +91,68 @@
{/* Expanded Filters */}
<div
className={cn(
"grid gap-4 transition-all duration-200 overflow-hidden",
isExpanded ? "grid-rows-[1fr] opacity-100 max-h-[500px]" : "grid-rows-[0fr] opacity-0 max-h-0",
'grid gap-4 transition-all duration-200 overflow-hidden',
isExpanded
? 'grid-rows-[1fr] opacity-100 max-h-[500px]'
: 'grid-rows-[0fr] opacity-0 max-h-0',
)}
>
<div className="overflow-hidden">
<div className="bg-card rounded-lg p-4 shadow-sm border border-border/40">
{/* Location Filter */}

<div className="space-y-3">
<h3 className="text-sm font-medium">Location</h3>
<div className="flex items-start gap-2">
<Checkbox
id="use-location"
checked={useLocation}
onCheckedChange={handleLocationToggle}
className="mt-1"
/>
<div>
<Label htmlFor="use-location" className="font-medium cursor-pointer">
Show listings near me
</Label>
<p className="text-xs text-muted-foreground flex items-center gap-1 mt-1">
<MapPin className="h-3 w-3" />
{userLocation.full_address}
</p>
</div>
</div>

{useLocation && (
<div className="mt-2">
<label className="text-xs font-medium mb-1 block">Distance</label>
<Select value={locationDistance} onValueChange={handleDistanceChange}>
<SelectTrigger className="w-full h-9">
<SelectValue placeholder="Select distance" />
</SelectTrigger>
<SelectContent>
<SelectItem value="1000">1 km</SelectItem>
<SelectItem value="5000">5 km</SelectItem>
<SelectItem value="10000">10 km</SelectItem>
<SelectItem value="25000">25 km</SelectItem>
<SelectItem value="50000">50 km</SelectItem>
</SelectContent>
</Select>
</div>
)}
<div className="space-y-3">
<h3 className="text-sm font-medium">{t('filters.location')}</h3>

Check warning on line 105 in frontend/vizzy/components/marketplace/filters-section.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/filters-section.tsx#L105

Translation key 'filters.location' should match format 'MODULE.FEATURE.*'
<div className="flex items-start gap-2">
<Checkbox
id="use-location"
checked={useLocation}
onCheckedChange={handleLocationToggle}
className="mt-1"
/>
<div>
<Label
htmlFor="use-location"
className="font-medium cursor-pointer"
>
{t('filters.locationToggle')}

Check warning on line 118 in frontend/vizzy/components/marketplace/filters-section.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/filters-section.tsx#L118

Translation key 'filters.locationToggle' should match format 'MODULE.FEATURE.*'
</Label>
<p className="text-xs text-muted-foreground flex items-center gap-1 mt-1">
<MapPin className="h-3 w-3" />
{userLocation.full_address}
</p>
</div>
</div>

{useLocation && (
<div className="mt-2">
<label className="text-xs font-medium mb-1 block">
{t('filters.distance')}

Check warning on line 130 in frontend/vizzy/components/marketplace/filters-section.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/filters-section.tsx#L130

Translation key 'filters.distance' should match format 'MODULE.FEATURE.*'
</label>
<Select
value={locationDistance}
onValueChange={handleDistanceChange}
>
<SelectTrigger className="w-full h-9">
<SelectValue
placeholder={t('filters.distancePlaceholder')}

Check warning on line 138 in frontend/vizzy/components/marketplace/filters-section.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/filters-section.tsx#L138

Translation key 'filters.distancePlaceholder' should match format 'MODULE.FEATURE.*'
/>
</SelectTrigger>
<SelectContent>
<SelectItem value="1000">1 km</SelectItem>
<SelectItem value="5000">5 km</SelectItem>
<SelectItem value="10000">10 km</SelectItem>
<SelectItem value="25000">25 km</SelectItem>
<SelectItem value="50000">50 km</SelectItem>
</SelectContent>
</Select>
</div>
)}
</div>
</div>
</div>
</div>
</div>
</div>
)
);
}
34 changes: 22 additions & 12 deletions frontend/vizzy/components/marketplace/marketplace.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -23,16 +24,21 @@
handleTypeChange,
handleLocationToggle,
handleDistanceChange,
} = useListings()
} = useListings();
const t = useTranslations('marketplace');

return (
<div className="container mx-auto xl:px-14 px-4 py-8">
<section className="mb-10">
<h1 className="text-3xl font-bold mb-6">Find what you need</h1>
<h1 className="text-3xl font-bold mb-6">{t('title')}</h1>

Check warning on line 33 in frontend/vizzy/components/marketplace/marketplace.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/marketplace.tsx#L33

Translation key 'title' should match format 'MODULE.FEATURE.*'

<div className="space-y-4">
{/* Search Bar */}
<SearchBar searchInput={searchInput} setSearchInput={setSearchInput} handleSearch={handleSearch} />
<SearchBar
searchInput={searchInput}
setSearchInput={setSearchInput}
handleSearch={handleSearch}
/>

{/* Filters Section */}
<FiltersSection
Expand All @@ -50,14 +56,18 @@
{/* Results Section */}
<section>
<div className="flex justify-between items-center mb-6">
<h2 className="text-2xl font-bold">Latest Listings</h2>
<h2 className="text-2xl font-bold">{t('latestListings')}</h2>

Check warning on line 59 in frontend/vizzy/components/marketplace/marketplace.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/marketplace.tsx#L59

Translation key 'latestListings' should match format 'MODULE.FEATURE.*'
</div>

<ListingsGrid listings={listings} loading={loading} />

{/* Pagination */}
<PaginationControls page={page} totalPages={totalPages} handlePageChange={handlePageChange} />
<PaginationControls
page={page}
totalPages={totalPages}
handlePageChange={handlePageChange}
/>
</section>
</div>
)
);
}
39 changes: 24 additions & 15 deletions frontend/vizzy/components/marketplace/search-bar.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="relative w-full">
<div className="relative">
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
<Input
placeholder="Search for items..."
placeholder={t('searchPlaceholder')}

Check warning on line 24 in frontend/vizzy/components/marketplace/search-bar.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/search-bar.tsx#L24

Translation key 'searchPlaceholder' should match format 'MODULE.FEATURE.*'
className="pl-10 pr-20 h-12 rounded-lg border-border/40 focus-visible:ring-primary focus-visible:border-primary"
value={searchInput}
onChange={(e) => setSearchInput(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && handleSearch()}
onKeyDown={(e) => e.key === 'Enter' && handleSearch()}
/>
{searchInput && (
<button
onClick={() => setSearchInput("")}
onClick={() => setSearchInput('')}
className="absolute right-[70px] top-1/2 transform -translate-y-1/2 text-muted-foreground hover:text-foreground"
aria-label="Clear search"
>
<X className="h-4 w-4" />
</button>
)}
<Button className="absolute right-1 top-1/2 transform -translate-y-1/2 h-10" onClick={handleSearch} size="sm">
Search
<Button
className="absolute right-1 top-1/2 transform -translate-y-1/2 h-10"
onClick={handleSearch}
size="sm"
>
{t('searchButton')}

Check warning on line 44 in frontend/vizzy/components/marketplace/search-bar.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

frontend/vizzy/components/marketplace/search-bar.tsx#L44

Translation key 'searchButton' should match format 'MODULE.FEATURE.*'
</Button>
</div>
</div>
)
);
}
24 changes: 24 additions & 0 deletions frontend/vizzy/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Loading