From 7cd5d66a7a3f120d13d20731c4de35ff8d48fb4b Mon Sep 17 00:00:00 2001 From: Derian <59376626+derianrddev@users.noreply.github.com> Date: Sat, 4 Jan 2025 19:07:20 -0600 Subject: [PATCH] chore/code cleanup (#79) * chore: remove unnecessary dependencies from root package.json * docs: update issue template * chore: update frontend dependencies * chore: remove unnecessary imports * refactor: improve styles for delivery location component and rename to DeliveryCountry * refactor: update BreadcrumbNavigation to use shadcn/ui Breadcrumb component * refactor: remove Bounded component * style: update styles for product cards and pagination * style: update footer styles * style: update pagination styles * style: update layout styles * style: update header button styles * fix: display AddProductModal in Marketplace * style: center title of AddProductModal * style: update layout styles * refactor: reorganize component structure * refactor: reorganize imports for clarity * refactor: use shadcn/ui button in product page * chore: format code * fix: resolve type constraint error in ProductList * chore: remove unused react-icons package * chore: remove unused react-icons package * chore: clean code --- .github/ISSUE_TEMPLATE.md | 10 +- frontend/app/components/Bounded.tsx | 15 - .../app/components/home/feature-section.tsx | 92 +++ .../components/{ui => home}/hero-section.tsx | 6 +- .../components/{ui => home}/stats-section.tsx | 2 - .../{ui => marketplace}/add-product-modal.tsx | 22 +- .../marketplace/breadcrumb-navigation.tsx | 24 + .../app/components/marketplace/filters.tsx | 69 +++ frontend/app/components/marketplace/index.ts | 1 - .../marketplace/products-pagination.tsx | 13 +- frontend/app/components/products/Images.tsx | 67 +-- .../products/ProductDetailModal.tsx | 117 ---- .../components/products/images-carrousel.tsx | 50 ++ .../components/providers/theme-provider.tsx | 1 - .../components/shared/delivery-country.tsx | 48 ++ frontend/app/components/shared/footer.tsx | 22 + .../{header/Header.tsx => shared/header.tsx} | 82 +-- .../safe-swap-logo.tsx} | 1 + .../SubHeader.tsx => shared/sub-header.tsx} | 12 +- frontend/app/components/sidebar/Sidebar.tsx | 68 --- .../components/ui/breadcrumb-navigation.tsx | 48 -- frontend/app/components/ui/breadcrumb.tsx | 114 ++++ frontend/app/components/ui/button.tsx | 8 +- frontend/app/components/ui/card.tsx | 92 +-- frontend/app/components/ui/carousel.tsx | 432 ++++++------- .../ui/delivery-location-button.tsx | 35 -- frontend/app/components/ui/dropdown-menu.tsx | 320 +++++----- .../app/components/ui/feature-section.tsx | 93 --- frontend/app/components/ui/footer.tsx | 24 - .../app/components/ui/image-carrousel.tsx | 50 -- frontend/app/components/ui/sidebar.tsx | 158 ++--- frontend/app/components/ui/theme-toggle.tsx | 10 +- frontend/app/layout.tsx | 25 +- frontend/app/marketplace/[productId]/page.tsx | 106 ++++ frontend/app/marketplace/page.tsx | 91 ++- frontend/app/page.tsx | 21 +- frontend/app/products/[productId]/page.tsx | 115 ---- frontend/app/products/page.tsx | 71 --- frontend/constants/testDataProduct.ts | 174 +++--- frontend/entities/Product.ts | 18 +- frontend/package-lock.json | 569 ++++++++++++++++-- frontend/package.json | 1 - .../images/{costarica.svg => costa-rica.svg} | 0 frontend/utils/utils.hook.ts | 22 +- package.json | 4 - 45 files changed, 1854 insertions(+), 1469 deletions(-) delete mode 100644 frontend/app/components/Bounded.tsx create mode 100644 frontend/app/components/home/feature-section.tsx rename frontend/app/components/{ui => home}/hero-section.tsx (97%) rename frontend/app/components/{ui => home}/stats-section.tsx (97%) rename frontend/app/components/{ui => marketplace}/add-product-modal.tsx (85%) create mode 100644 frontend/app/components/marketplace/breadcrumb-navigation.tsx create mode 100644 frontend/app/components/marketplace/filters.tsx delete mode 100644 frontend/app/components/marketplace/index.ts delete mode 100644 frontend/app/components/products/ProductDetailModal.tsx create mode 100644 frontend/app/components/products/images-carrousel.tsx create mode 100644 frontend/app/components/shared/delivery-country.tsx create mode 100644 frontend/app/components/shared/footer.tsx rename frontend/app/components/{header/Header.tsx => shared/header.tsx} (56%) rename frontend/app/components/{ui/SafeSwapLogo.tsx => shared/safe-swap-logo.tsx} (99%) rename frontend/app/components/{header/subheader/SubHeader.tsx => shared/sub-header.tsx} (66%) delete mode 100644 frontend/app/components/sidebar/Sidebar.tsx delete mode 100644 frontend/app/components/ui/breadcrumb-navigation.tsx create mode 100644 frontend/app/components/ui/breadcrumb.tsx delete mode 100644 frontend/app/components/ui/delivery-location-button.tsx delete mode 100644 frontend/app/components/ui/feature-section.tsx delete mode 100644 frontend/app/components/ui/footer.tsx delete mode 100644 frontend/app/components/ui/image-carrousel.tsx create mode 100644 frontend/app/marketplace/[productId]/page.tsx delete mode 100644 frontend/app/products/[productId]/page.tsx delete mode 100644 frontend/app/products/page.tsx rename frontend/public/images/{costarica.svg => costa-rica.svg} (100%) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 6a46746..14932fb 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,9 +1,4 @@ -# 📘 Issue Description -- - ---- - -## 🔍 Steps to Reproduce +## 📘 Description - ## ✅ Acceptance Criteria @@ -15,3 +10,6 @@ ## 📜 Additional Notes - +⚠ Do not apply until the ODHack begins. + +⚠ Read our guidelines before applying. \ No newline at end of file diff --git a/frontend/app/components/Bounded.tsx b/frontend/app/components/Bounded.tsx deleted file mode 100644 index a90c26a..0000000 --- a/frontend/app/components/Bounded.tsx +++ /dev/null @@ -1,15 +0,0 @@ -interface BoundedProps { - children: React.ReactNode; - title: string; -} - -const Bounded = ({ children, title }: BoundedProps) => { - return ( -
-

{title}

-
{children}
-
- ); -}; - -export default Bounded; diff --git a/frontend/app/components/home/feature-section.tsx b/frontend/app/components/home/feature-section.tsx new file mode 100644 index 0000000..70a3653 --- /dev/null +++ b/frontend/app/components/home/feature-section.tsx @@ -0,0 +1,92 @@ +import { BarChart3, Coins, Lock, Shield, Users, Zap } from "lucide-react"; + +export function FeatureSection() { + const features = [ + { + icon: , + title: "Smart Contract Escrow", + description: ( + <> + Automated protection with Stellar smart contracts. Trustless Work API + abstracts the complexities of smart contract configuration. It + leverages the blockchain to ensure transactions are secure and + transparent, providing fairness without bias in the marketplace. Read + more on + + Trustless Work + + + ), + gradient: "from-blue-500 to-cyan-500", + }, + { + icon: , + title: "Lightning Settlement", + description: "3-5 second finality on Stellar network", + gradient: "from-yellow-500 to-orange-500", + }, + { + icon: , + title: "Non-Custodial Trading", + description: "Keep full control of your assets", + gradient: "from-purple-500 to-pink-500", + }, + { + icon: , + title: "Multi-Asset Support", + description: "Trade any Stellar-based token", + gradient: "from-green-500 to-emerald-500", + }, + { + icon: , + title: "DAO Governance", + description: "Community-driven protocol decisions", + gradient: "from-red-500 to-pink-500", + }, + { + icon: , + title: "Real-Time Analytics", + description: "Advanced trading metrics & insights", + gradient: "from-indigo-500 to-purple-500", + }, + ]; + + return ( +
+
+

+ Built for the Future of Finance +

+

+ Leveraging the power of Stellar blockchain to provide a secure, + efficient, and truly decentralized trading experience. +

+
+ {features.map((feature) => ( +
+
+
+
+ {feature.icon} +
+

{feature.title}

+

{feature.description}

+
+
+ ))} +
+
+
+ ); +} diff --git a/frontend/app/components/ui/hero-section.tsx b/frontend/app/components/home/hero-section.tsx similarity index 97% rename from frontend/app/components/ui/hero-section.tsx rename to frontend/app/components/home/hero-section.tsx index 83d2789..85a7095 100644 --- a/frontend/app/components/ui/hero-section.tsx +++ b/frontend/app/components/home/hero-section.tsx @@ -1,8 +1,8 @@ -import { Button } from "@/app/components/ui/button"; import { ArrowRight } from "lucide-react"; import Link from "next/link"; -import * as React from "react"; -import { SafeSwapLogo } from "./SafeSwapLogo"; + +import { SafeSwapLogo } from "@/app/components/shared/safe-swap-logo"; +import { Button } from "@/app/components/ui/button"; export function HeroSection() { return ( diff --git a/frontend/app/components/ui/stats-section.tsx b/frontend/app/components/home/stats-section.tsx similarity index 97% rename from frontend/app/components/ui/stats-section.tsx rename to frontend/app/components/home/stats-section.tsx index 91dc239..963c523 100644 --- a/frontend/app/components/ui/stats-section.tsx +++ b/frontend/app/components/home/stats-section.tsx @@ -1,5 +1,3 @@ -import * as React from "react"; - export function StatsSection() { return (
diff --git a/frontend/app/components/ui/add-product-modal.tsx b/frontend/app/components/marketplace/add-product-modal.tsx similarity index 85% rename from frontend/app/components/ui/add-product-modal.tsx rename to frontend/app/components/marketplace/add-product-modal.tsx index 9a6a356..fea7d79 100644 --- a/frontend/app/components/ui/add-product-modal.tsx +++ b/frontend/app/components/marketplace/add-product-modal.tsx @@ -1,15 +1,16 @@ import React from "react"; -import { Button } from "./button"; -import { Input } from "./input"; -import { Label } from "./label"; + +import { Button } from "@/app/components/ui/button"; +import { Input } from "@/app/components/ui/input"; +import { Label } from "@/app/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, -} from "./select"; -import { Textarea } from "./textarea"; +} from "@/app/components/ui/select"; +import { Textarea } from "@/app/components/ui/textarea"; interface AddProductModalProps { isOpen: boolean; @@ -24,8 +25,8 @@ const AddProductModal: React.FC = ({ return (
-
-

Add New Product

+
+

Add New Product

{/* Product Name */}
@@ -91,12 +92,7 @@ const AddProductModal: React.FC = ({ - +
diff --git a/frontend/app/components/marketplace/breadcrumb-navigation.tsx b/frontend/app/components/marketplace/breadcrumb-navigation.tsx new file mode 100644 index 0000000..8e837b6 --- /dev/null +++ b/frontend/app/components/marketplace/breadcrumb-navigation.tsx @@ -0,0 +1,24 @@ +import { + Breadcrumb, + BreadcrumbItem, + BreadcrumbLink, + BreadcrumbList, + BreadcrumbPage, + BreadcrumbSeparator, +} from "@/app/components/ui/breadcrumb"; + +export default function BreadcrumbNavigation() { + return ( + + + + Home + + + + Marketplace + + + + ); +} diff --git a/frontend/app/components/marketplace/filters.tsx b/frontend/app/components/marketplace/filters.tsx new file mode 100644 index 0000000..9fdd799 --- /dev/null +++ b/frontend/app/components/marketplace/filters.tsx @@ -0,0 +1,69 @@ +"use client"; + +import { Checkbox, Slider } from "@radix-ui/themes"; +import { useState } from "react"; + +import { SidebarContent, SidebarHeader } from "@/app/components/ui/sidebar"; + +const Filters = () => { + const [priceRange, setPriceRange] = useState<[number, number]>([0, 1500]); + const [selectedCategories, setSelectedCategories] = useState([]); + + const handleCategoryChange = (category: string) => { + setSelectedCategories((prev) => + prev.includes(category) + ? prev.filter((c) => c !== category) + : [...prev, category], + ); + }; + + return ( + <> + +

Filters

+
+ +
+
+

Price range

+ + setPriceRange(value as [number, number]) + } + className="mb-3" + /> +
+ ${priceRange[0]} + ${priceRange[1]} +
+
+
+

Categories

+
+ {["Electronics", "Furniture", "Appliances", "Sports"].map( + (category) => ( +
+ handleCategoryChange(category)} + /> + +
+ ), + )} +
+
+
+
+ + ); +}; + +export default Filters; diff --git a/frontend/app/components/marketplace/index.ts b/frontend/app/components/marketplace/index.ts deleted file mode 100644 index b7492fc..0000000 --- a/frontend/app/components/marketplace/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ProductsPagination } from "./products-pagination"; diff --git a/frontend/app/components/marketplace/products-pagination.tsx b/frontend/app/components/marketplace/products-pagination.tsx index 31bf175..1be064d 100644 --- a/frontend/app/components/marketplace/products-pagination.tsx +++ b/frontend/app/components/marketplace/products-pagination.tsx @@ -6,7 +6,7 @@ import { PaginationLink, PaginationNext, PaginationPrevious, -} from "../ui/pagination"; +} from "@/app/components/ui/pagination"; import { Select, SelectContent, @@ -14,15 +14,12 @@ import { SelectItem, SelectTrigger, SelectValue, -} from "../ui/select"; +} from "@/app/components/ui/select"; export const ProductsPagination = () => { return ( -
-
+
+
+ + + + + + Countries + +
+ CRC + Costa Rica flag +
+
+
+
+ +
+ ); +} + +export default DeliveryCountry; diff --git a/frontend/app/components/shared/footer.tsx b/frontend/app/components/shared/footer.tsx new file mode 100644 index 0000000..2cdd8af --- /dev/null +++ b/frontend/app/components/shared/footer.tsx @@ -0,0 +1,22 @@ +import Link from "next/link"; + +import { SafeSwapLogo } from "@/app/components/shared/safe-swap-logo"; + +export default function Footer() { + return ( +
+
+ +

Built on Stellar

+
+
+ + Marketplace + +
+
+ ); +} diff --git a/frontend/app/components/header/Header.tsx b/frontend/app/components/shared/header.tsx similarity index 56% rename from frontend/app/components/header/Header.tsx rename to frontend/app/components/shared/header.tsx index 1d5de3d..e5d73bb 100644 --- a/frontend/app/components/header/Header.tsx +++ b/frontend/app/components/shared/header.tsx @@ -1,16 +1,5 @@ "use client"; -import { SafeSwapLogo } from "@/app/components/ui/SafeSwapLogo"; -import { Button } from "@/app/components/ui/button"; -import DeliveryLocationButton from "@/app/components/ui/delivery-location-button"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "@/app/components/ui/dropdown-menu"; -import { Input } from "@/app/components/ui/input"; -import { ThemeToggle } from "@/app/components/ui/theme-toggle"; import { History, List, @@ -23,6 +12,18 @@ import { import Link from "next/link"; import { useState } from "react"; +import DeliveryCountry from "@/app/components/shared/delivery-country"; +import { SafeSwapLogo } from "@/app/components/shared/safe-swap-logo"; +import { Button } from "@/app/components/ui/button"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/app/components/ui/dropdown-menu"; +import { Input } from "@/app/components/ui/input"; +import { ThemeToggle } from "@/app/components/ui/theme-toggle"; + export default function Header() { const [searchTerm, setSearchTerm] = useState(""); const showSearchBar = searchTerm !== undefined && setSearchTerm !== undefined; @@ -34,39 +35,41 @@ export default function Header() { + +
+
+ {showSearchBar ? ( +
+ setSearchTerm(e.target.value)} + className="w-full h-10 pr-10" + /> + +
+ ) : null}
- {showSearchBar ? ( -
- setSearchTerm(e.target.value)} - className="w-full h-8 pr-10" - /> - -
- ) : null} -
- - - - @@ -88,7 +91,6 @@ export default function Header() { -
diff --git a/frontend/app/components/ui/SafeSwapLogo.tsx b/frontend/app/components/shared/safe-swap-logo.tsx similarity index 99% rename from frontend/app/components/ui/SafeSwapLogo.tsx rename to frontend/app/components/shared/safe-swap-logo.tsx index a3c0ef5..82aa849 100644 --- a/frontend/app/components/ui/SafeSwapLogo.tsx +++ b/frontend/app/components/shared/safe-swap-logo.tsx @@ -1,4 +1,5 @@ "use client"; + import Image from "next/image"; import { useEffect, useState } from "react"; diff --git a/frontend/app/components/header/subheader/SubHeader.tsx b/frontend/app/components/shared/sub-header.tsx similarity index 66% rename from frontend/app/components/header/subheader/SubHeader.tsx rename to frontend/app/components/shared/sub-header.tsx index d5d8468..cb6769e 100644 --- a/frontend/app/components/header/subheader/SubHeader.tsx +++ b/frontend/app/components/shared/sub-header.tsx @@ -1,10 +1,11 @@ "use client"; -import { Button } from "@radix-ui/themes"; import { CirclePlus } from "lucide-react"; import { useState } from "react"; -import AddProductModal from "../../ui/add-product-modal"; -import BreadcrumbNavigation from "../../ui/breadcrumb-navigation"; + +import AddProductModal from "@/app/components/marketplace/add-product-modal"; +import BreadcrumbNavigation from "@/app/components/marketplace/breadcrumb-navigation"; +import { Button } from "@/app/components/ui/button"; interface SubHeaderProps { name: string; @@ -19,10 +20,7 @@ const SubHeader = ({ name }: SubHeaderProps) => { {/* Breadcrumb Navigation */} - diff --git a/frontend/app/components/sidebar/Sidebar.tsx b/frontend/app/components/sidebar/Sidebar.tsx deleted file mode 100644 index 1192f1e..0000000 --- a/frontend/app/components/sidebar/Sidebar.tsx +++ /dev/null @@ -1,68 +0,0 @@ -"use client"; - -import { useState } from "react"; -import { SidebarContent, SidebarHeader } from "@/app/components/ui/sidebar"; -import { Checkbox, Slider } from "@radix-ui/themes"; - -const SidebarComponent = () => { - const [priceRange, setPriceRange] = useState<[number, number]>([0, 1500]); - const [selectedCategories, setSelectedCategories] = useState([]); - - const handleCategoryChange = (category: string) => { - setSelectedCategories((prev) => - prev.includes(category) - ? prev.filter((c) => c !== category) - : [...prev, category] - ); - }; - - return ( - <> - -

Filters

-
- -
-
-

Price range

- - setPriceRange(value as [number, number]) - } - className="mb-3" - /> -
- ${priceRange[0]} - ${priceRange[1]} -
-
-
-

Categories

-
- {["Electronics", "Furniture", "Appliances", "Sports"].map( - (category) => ( -
- handleCategoryChange(category)} - /> - -
- ) - )} -
-
-
-
- - ); -}; - -export default SidebarComponent; diff --git a/frontend/app/components/ui/breadcrumb-navigation.tsx b/frontend/app/components/ui/breadcrumb-navigation.tsx deleted file mode 100644 index 107abba..0000000 --- a/frontend/app/components/ui/breadcrumb-navigation.tsx +++ /dev/null @@ -1,48 +0,0 @@ -"use client"; - -import { ChevronRight } from "lucide-react"; -import React from "react"; - -export function Breadcrumb({ children }: { children: React.ReactNode }) { - return ; -} - -export function BreadcrumbList({ children }: { children: React.ReactNode }) { - return
    {children}
; -} - -export function BreadcrumbItem({ children }: { children: React.ReactNode }) { - return
  • {children}
  • ; -} - -export function BreadcrumbSeparator() { - return ( - - - - ); -} - -export default function BreadcrumbNavigation() { - return ( - - ); -} diff --git a/frontend/app/components/ui/breadcrumb.tsx b/frontend/app/components/ui/breadcrumb.tsx new file mode 100644 index 0000000..982c622 --- /dev/null +++ b/frontend/app/components/ui/breadcrumb.tsx @@ -0,0 +1,114 @@ +import { cn } from "@/lib/utils"; +import { ChevronRightIcon, DotsHorizontalIcon } from "@radix-ui/react-icons"; +import { Slot } from "@radix-ui/react-slot"; +import * as React from "react"; + +const Breadcrumb = React.forwardRef< + HTMLElement, + React.ComponentPropsWithoutRef<"nav"> & { + separator?: React.ReactNode; + } +>(({ ...props }, ref) =>