diff --git a/.eslintrc.js b/.eslintrc.js index ee707c94a..3c62d7deb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,30 +1,31 @@ -module.exports = { - parser: '@typescript-eslint/parser', +module.exports = { + parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint/eslint-plugin', 'import'], parserOptions: { - ecmaVersion: 2020, - sourceType: 'module', - project: './tsconfig.json', - tsconfigRootDir: __dirname, - }, - settings: { - 'import/resolver': { - typescript: {}, - node: { - extensions: ['.js', '.jsx', '.ts', '.tsx'] - } - } + ecmaVersion: 2020, + sourceType: 'module', + project: './tsconfig.json', + tsconfigRootDir: __dirname, + }, + settings: { + 'import/resolver': { + typescript: {}, + node: { + extensions: ['.js', '.jsx', '.ts', '.tsx'], + }, }, + }, extends: [ - 'eslint:recommended', + 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', ], rules: { + 'prettier/prettier': 'off', 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': ['error'], 'import/no-unresolved': 'error', 'import/named': 'error', }, ignorePatterns: ['.eslintrc.js'], -} +}; diff --git a/.prettierrc.js b/.prettierrc.js index dcfc519ac..76c37f482 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,7 +1,7 @@ module.exports = { - semi: true, - trailingComma: 'es5', - singleQuote: true, - printWidth: 100, - tabWidth: 2, - }; + semi: true, + trailingComma: 'es5', + singleQuote: true, + printWidth: 100, + tabWidth: 2, +}; diff --git a/README.md b/README.md index 48c3d6982..bf0386719 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ **Revolutionary Farmers** is a Next.js project focused on advancing agriculture by providing a platform with escrow services. This project aims to bring innovative solutions to farmers, suppliers, and buyers in the agriculture sector by ensuring secure transactions through escrow as a service. ## ✨ Features + - **Escrow Service:** Secure transactions for agriculture. - **User Authentication:** Secure login for all users. - **Product Listings:** Manage and view agricultural products. @@ -12,7 +13,7 @@ ## 📝 Prerequisites Ensure you have **Node.js** installed (version 18.x or higher). -To verify the installed version, use the following command: +To verify the installed version, use the following command: ```bash node -v @@ -23,17 +24,20 @@ If Node.js is not installed, download it from the official [Node.js website](htt ## 🚀 Getting Started 1. Clone the Repository: + ```bash git clone https://github.com/your-username/Revolutionary_Farmers.git cd Revolutionary_Farmers/web/ ``` 2. Install dependencies: + ```bash npm install ``` 3. Run development server: + ```bash npm run dev ``` @@ -41,11 +45,12 @@ If Node.js is not installed, download it from the official [Node.js website](htt 4. Open [http://localhost:3001](http://localhost:3001) in your browser Available Commands: + - `npm run dev` - Start development server - `npm run build` - Create production build - `npm run start` - Start production server - `npm run lint` - Run ESLint linter -- `npm run format` - Format code with Prettier +- `npm run format` - Format code with Prettier ## 🛠 Tech Stack @@ -65,4 +70,4 @@ Available Commands: - [ESLint](https://eslint.org) (v8.57.1) - Linting tool for JavaScript/TypeScript - [PostCSS](https://postcss.org) (v8) - CSS tool for transforming styles - [Freighter API](https://github.com/stellar/freighter) - API for interacting with Stellar blockchain wallets -- [Stellar SDK](https://stellar.github.io/js-stellar-sdk) (v12.3.0) - JavaScript library for Stellar blockchain \ No newline at end of file +- [Stellar SDK](https://stellar.github.io/js-stellar-sdk) (v12.3.0) - JavaScript library for Stellar blockchain diff --git a/components.json b/components.json index 0e8b6332f..405a08cd6 100644 --- a/components.json +++ b/components.json @@ -18,4 +18,4 @@ "hooks": "@/hooks" }, "iconLibrary": "lucide" -} \ No newline at end of file +} diff --git a/messages/en.json b/messages/en.json index 07d5dacef..d1c2177ba 100644 --- a/messages/en.json +++ b/messages/en.json @@ -51,4 +51,4 @@ }, "submitButtonText": "Fund escrow" } -} \ No newline at end of file +} diff --git a/messages/es.json b/messages/es.json index 259e2ba23..cdf2e55b3 100644 --- a/messages/es.json +++ b/messages/es.json @@ -51,4 +51,4 @@ }, "submitButtonText": "Financiar fideicomiso" } -} \ No newline at end of file +} diff --git a/middleware.ts b/middleware.ts index d486574b0..53f589125 100644 --- a/middleware.ts +++ b/middleware.ts @@ -1,21 +1,21 @@ -import { NextRequest, NextResponse } from 'next/server' - -const PUBLIC_FILE = /\.(.*)$/ - +import { NextRequest, NextResponse } from 'next/server'; + +const PUBLIC_FILE = /\.(.*)$/; + export async function middleware(req: NextRequest) { if ( req.nextUrl.pathname.startsWith('/_next') || req.nextUrl.pathname.includes('/api/') || PUBLIC_FILE.test(req.nextUrl.pathname) ) { - return + return; } - + if (req.nextUrl.locale === 'default') { - const locale = req.cookies.get('NEXT_LOCALE')?.value || 'en' - + const locale = req.cookies.get('NEXT_LOCALE')?.value || 'en'; + return NextResponse.redirect( new URL(`/${locale}${req.nextUrl.pathname}${req.nextUrl.search}`, req.url) - ) + ); } -} \ No newline at end of file +} diff --git a/next.config.mjs b/next.config.mjs index 720e3adc3..00dc8ae23 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,8 +1,8 @@ import createNextIntlPlugin from 'next-intl/plugin'; - + const withNextIntl = createNextIntlPlugin(); - + /** @type {import('next').NextConfig} */ const nextConfig = {}; - -export default withNextIntl(nextConfig); \ No newline at end of file + +export default withNextIntl(nextConfig); diff --git a/src/app/[locale]/escrow/cancel-escrow/page.tsx b/src/app/[locale]/escrow/cancel-escrow/page.tsx index ee1782514..1171cda23 100644 --- a/src/app/[locale]/escrow/cancel-escrow/page.tsx +++ b/src/app/[locale]/escrow/cancel-escrow/page.tsx @@ -1,8 +1,8 @@ -"use client"; +'use client'; -import Bounded from "@/components/Bounded"; -import { CancelEscrowForm } from "@/components/modules/escrow/CancelEscrowForm"; -import WithAuthProtect from "@/constants/helpers/WithAuth"; +import Bounded from '@/components/Bounded'; +import { CancelEscrowForm } from '@/components/modules/escrow/CancelEscrowForm'; +import WithAuthProtect from '@/constants/helpers/WithAuth'; const CancelEscrow = () => { return ( diff --git a/src/app/[locale]/escrow/claim-escrow-earnings/page.tsx b/src/app/[locale]/escrow/claim-escrow-earnings/page.tsx index 293d92ea9..554c783c2 100644 --- a/src/app/[locale]/escrow/claim-escrow-earnings/page.tsx +++ b/src/app/[locale]/escrow/claim-escrow-earnings/page.tsx @@ -1,8 +1,8 @@ -"use client"; +'use client'; -import Bounded from "@/components/Bounded"; -import { ClaimEscrowEarningsForm } from "@/components/modules/escrow/ClaimEscrowEarningsForm"; -import WithAuthProtect from "@/constants/helpers/WithAuth"; +import Bounded from '@/components/Bounded'; +import { ClaimEscrowEarningsForm } from '@/components/modules/escrow/ClaimEscrowEarningsForm'; +import WithAuthProtect from '@/constants/helpers/WithAuth'; const ClaimEscrowEarnings = () => { return ( diff --git a/src/app/[locale]/escrow/complete-escrow/page.tsx b/src/app/[locale]/escrow/complete-escrow/page.tsx index a3d9e21ba..a22654f44 100644 --- a/src/app/[locale]/escrow/complete-escrow/page.tsx +++ b/src/app/[locale]/escrow/complete-escrow/page.tsx @@ -1,8 +1,8 @@ -"use client"; +'use client'; -import Bounded from "@/components/Bounded"; -import { CompleteEscrowForm } from "@/components/modules/escrow/CompleEscrowForm"; -import WithAuthProtect from "@/constants/helpers/WithAuth"; +import Bounded from '@/components/Bounded'; +import { CompleteEscrowForm } from '@/components/modules/escrow/CompleEscrowForm'; +import WithAuthProtect from '@/constants/helpers/WithAuth'; const CompleteEscrow = () => { return ( diff --git a/src/app/[locale]/escrow/fund-escrow/page.tsx b/src/app/[locale]/escrow/fund-escrow/page.tsx index fddec18d7..0a07e3d4c 100644 --- a/src/app/[locale]/escrow/fund-escrow/page.tsx +++ b/src/app/[locale]/escrow/fund-escrow/page.tsx @@ -1,10 +1,10 @@ -"use client"; +'use client'; -import Bounded from "@/components/Bounded"; -import { FundEscrowForm } from "@/components/modules/escrow/FundEscrowForm"; -import Loader from "@/components/utils/Loader"; -import WithAuthProtect from "@/constants/helpers/WithAuth"; -import { useLoaderStore } from "@/store/utilsStore"; +import Bounded from '@/components/Bounded'; +import { FundEscrowForm } from '@/components/modules/escrow/FundEscrowForm'; +import Loader from '@/components/utils/Loader'; +import WithAuthProtect from '@/constants/helpers/WithAuth'; +import { useLoaderStore } from '@/store/utilsStore'; const FundEscrow = () => { const isLoading = useLoaderStore((state) => state.isLoading); diff --git a/src/app/[locale]/escrow/get-engagement/page.tsx b/src/app/[locale]/escrow/get-engagement/page.tsx index 15680309d..50db336dc 100644 --- a/src/app/[locale]/escrow/get-engagement/page.tsx +++ b/src/app/[locale]/escrow/get-engagement/page.tsx @@ -1,8 +1,8 @@ -"use client"; +'use client'; -import Bounded from "@/components/Bounded"; -import { GetEngagementForm } from "@/components/modules/escrow/GetEngagementForm"; -import WithAuthProtect from "@/constants/helpers/WithAuth"; +import Bounded from '@/components/Bounded'; +import { GetEngagementForm } from '@/components/modules/escrow/GetEngagementForm'; +import WithAuthProtect from '@/constants/helpers/WithAuth'; const GetEngagement = () => { return ( diff --git a/src/app/[locale]/escrow/initialize-escrow/page.tsx b/src/app/[locale]/escrow/initialize-escrow/page.tsx index 2da47a532..7ef188114 100644 --- a/src/app/[locale]/escrow/initialize-escrow/page.tsx +++ b/src/app/[locale]/escrow/initialize-escrow/page.tsx @@ -1,10 +1,10 @@ -"use client"; +'use client'; -import Bounded from "@/components/Bounded"; -import { InitializeEscrowForm } from "@/components/modules/escrow/InitializeEscrowForm"; -import Loader from "@/components/utils/Loader"; -import WithAuthProtect from "@/constants/helpers/WithAuth"; -import { useLoaderStore } from "@/store/utilsStore/store"; +import Bounded from '@/components/Bounded'; +import { InitializeEscrowForm } from '@/components/modules/escrow/InitializeEscrowForm'; +import Loader from '@/components/utils/Loader'; +import WithAuthProtect from '@/constants/helpers/WithAuth'; +import { useLoaderStore } from '@/store/utilsStore/store'; const CreateEscrow = () => { const isLoading = useLoaderStore((state) => state.isLoading); diff --git a/src/app/[locale]/escrow/refund-remaining-funds/page.tsx b/src/app/[locale]/escrow/refund-remaining-funds/page.tsx index d3628626f..1fcf599c4 100644 --- a/src/app/[locale]/escrow/refund-remaining-funds/page.tsx +++ b/src/app/[locale]/escrow/refund-remaining-funds/page.tsx @@ -1,8 +1,8 @@ -"use client"; +'use client'; -import Bounded from "@/components/Bounded"; -import { RefundRemainingFundsForm } from "@/components/modules/escrow/RefundRemainingFundsForm"; -import WithAuthProtect from "@/constants/helpers/WithAuth"; +import Bounded from '@/components/Bounded'; +import { RefundRemainingFundsForm } from '@/components/modules/escrow/RefundRemainingFundsForm'; +import WithAuthProtect from '@/constants/helpers/WithAuth'; const RefundRemainingFuns = () => { return ( diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 476d44b75..0e3add314 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -1,22 +1,22 @@ -"use client"; +'use client'; -import { useEffect, useState } from "react"; -import { useRouter } from "next/navigation"; -import { NextIntlClientProvider } from "next-intl"; -import localFont from "next/font/local"; -import { Toaster } from "@/components/ui/toaster"; -import Header from "@/components/header/Header"; -import "./globals.css"; +import { useEffect, useState } from 'react'; +import { useRouter } from 'next/navigation'; +import { NextIntlClientProvider } from 'next-intl'; +import localFont from 'next/font/local'; +import { Toaster } from '@/components/ui/toaster'; +import Header from '@/components/header/Header'; +import './globals.css'; const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", + src: './fonts/GeistVF.woff', + variable: '--font-geist-sans', + weight: '100 900', }); const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", + src: './fonts/GeistMonoVF.woff', + variable: '--font-geist-mono', + weight: '100 900', }); export default function RootLayout({ @@ -31,14 +31,12 @@ export default function RootLayout({ const router = useRouter(); useEffect(() => { - const storedLocale = localStorage.getItem("language") || locale; + const storedLocale = localStorage.getItem('language') || locale; if (storedLocale !== currentLocale) { - const newPathname = window.location.pathname.replace( - /^\/[a-z]{2}/, - `/${storedLocale}` - ); + const newPathname = window.location.pathname.replace(/^\/[a-z]{2}/, `/${storedLocale}`); if (newPathname !== window.location.pathname) { - setCurrentLocale(storedLocale); router.replace(newPathname); + setCurrentLocale(storedLocale); + router.replace(newPathname); } } }, [locale, currentLocale, router]); @@ -46,9 +44,7 @@ export default function RootLayout({ useEffect(() => { const loadMessages = async () => { try { - const importedMessages = ( - await import(`../../../messages/${currentLocale}.json`) - ).default; + const importedMessages = (await import(`../../../messages/${currentLocale}.json`)).default; setMessages(importedMessages); } catch (error) { console.error(`Failed to load messages for locale: ${currentLocale}`, error); diff --git a/src/app/[locale]/page.tsx b/src/app/[locale]/page.tsx index f0734ede2..c06a5ff7d 100644 --- a/src/app/[locale]/page.tsx +++ b/src/app/[locale]/page.tsx @@ -1,11 +1,10 @@ -"use client"; +'use client'; -import Bounded from "@/components/Bounded"; -import { useTranslations } from "next-intl"; +import Bounded from '@/components/Bounded'; +import { useTranslations } from 'next-intl'; export default function Home() { - - const t = useTranslations("HomePage"); + const t = useTranslations('HomePage'); return ( @@ -13,15 +12,12 @@ export default function Home() {

+{' '} - {t("title")} - - - {t("subtitle")} + {t('title')} - +{' '} + {t('subtitle')}+{' '}

- {t("description")} + {t('description')}

diff --git a/src/components/Bounded.tsx b/src/components/Bounded.tsx index 5c1ac5651..b97e91797 100644 --- a/src/components/Bounded.tsx +++ b/src/components/Bounded.tsx @@ -1,4 +1,4 @@ -import { ReactNode } from "react"; +import { ReactNode } from 'react'; type BoundedProps = { children: ReactNode; @@ -9,7 +9,7 @@ const Bounded = ({ children, center }: BoundedProps) => { return (
{children} diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index b18c1f639..ab659ddd6 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -1,21 +1,21 @@ -"use client"; +'use client'; -import React, { useState, useCallback, useEffect } from "react"; -import { useWalletStore } from "@/store/walletStore"; -import { useWallet } from "@/wallet/hooks/useWallet.hook"; -import { FaUserCircle } from "react-icons/fa"; -import { Menu, X } from "lucide-react"; -import Image from "next/image"; -import ItemsHeader from "./ItemsHeader"; -import LanguageSwitcher from "./LanguageSwitcher"; -import { usePathname, useRouter } from "next/navigation"; -import { useLanguageStore } from "@/store/languageStore"; +import React, { useState, useCallback, useEffect } from 'react'; +import { useWalletStore } from '@/store/walletStore'; +import { useWallet } from '@/wallet/hooks/useWallet.hook'; +import { FaUserCircle } from 'react-icons/fa'; +import { Menu, X } from 'lucide-react'; +import Image from 'next/image'; +import ItemsHeader from './ItemsHeader'; +import LanguageSwitcher from './LanguageSwitcher'; +import { usePathname, useRouter } from 'next/navigation'; +import { useLanguageStore } from '@/store/languageStore'; const Header = () => { const [isMenuOpen, setIsMenuOpen] = useState(false); const { connectWallet, disconnectWallet } = useWallet(); const { address, name } = useWalletStore(); - const { language } = useLanguageStore(); + const { language } = useLanguageStore(); const pathname = usePathname(); const router = useRouter(); @@ -24,9 +24,9 @@ const Header = () => { }, []); useEffect(() => { - document.body.style.overflow = isMenuOpen ? "hidden" : "unset"; + document.body.style.overflow = isMenuOpen ? 'hidden' : 'unset'; return () => { - document.body.style.overflow = "unset"; + document.body.style.overflow = 'unset'; }; }, [isMenuOpen]); @@ -34,7 +34,7 @@ const Header = () => { try { await connectWallet(); } catch (error) { - console.error("Error connecting wallet:", error); + console.error('Error connecting wallet:', error); } }; @@ -45,13 +45,13 @@ const Header = () => { setIsMenuOpen(false); } } catch (error) { - console.error("Error disconnecting wallet:", error); + console.error('Error disconnecting wallet:', error); } }; const handleLogoClick = () => { const basePath = `/${language}`; - router.push(basePath); + router.push(basePath); }; return ( @@ -61,13 +61,7 @@ const Header = () => { className="md:m-0 focus:outline-none focus:ring-2 focus:ring-primary rounded-lg" aria-label="Home" > - Website logo + Website logo