diff --git a/app/user/backing-history/page.tsx b/app/user/backing-history/page.tsx deleted file mode 100644 index b42193df7..000000000 --- a/app/user/backing-history/page.tsx +++ /dev/null @@ -1,109 +0,0 @@ -'use client'; - -import { useState } from 'react'; -import { Button } from '@/components/ui/button'; -import BackingHistory from '@/components/flows/backing-history/index'; - -// Sample data matching the images -const sampleBackers = [ - { - id: '1', - name: 'Collins Odumeje', - avatar: '/placeholder.svg?height=32&width=32', - amount: 2300, - date: new Date('2025-08-05'), - walletId: 'GDS3...GB7', - isAnonymous: false, - }, - { - id: '2', - name: 'Collins Odumeje', - avatar: '/placeholder.svg?height=32&width=32', - amount: 2300, - date: new Date('2025-08-05'), - walletId: 'GDS3...GB7', - isAnonymous: false, - }, - { - id: '3', - name: 'Collins Odumeje', - avatar: '/placeholder.svg?height=32&width=32', - amount: 2300, - date: new Date('2025-08-05'), - walletId: 'GDS3...GB7', - isAnonymous: false, - }, - { - id: '4', - name: 'Anonymous', - amount: 2300, - date: new Date('2025-08-05'), - walletId: 'GDS3...GB7', - isAnonymous: true, - }, - { - id: '5', - name: 'Collins Odumeje', - avatar: '/placeholder.svg?height=32&width=32', - amount: 2300, - date: new Date('2025-08-05'), - walletId: 'GDS3...GB7', - isAnonymous: false, - }, - { - id: '6', - name: 'Anonymous', - amount: 2300, - date: new Date('2025-08-05'), - walletId: 'GDS3...GB7', - isAnonymous: true, - }, - { - id: '7', - name: 'Anonymous', - amount: 2300, - date: new Date('2025-08-05'), - walletId: 'GDS3...GB7', - isAnonymous: true, - }, - { - id: '8', - name: 'Collins Odumeje', - avatar: '/placeholder.svg?height=32&width=32', - amount: 2300, - date: new Date('2025-08-05'), - walletId: 'GDS3...GB7', - isAnonymous: false, - }, - { - id: '9', - name: 'Anonymous', - amount: 2300, - date: new Date('2025-08-05'), - walletId: 'GDS3...GB7', - isAnonymous: true, - }, -]; - -export default function Home() { - const [showBackingHistory, setShowBackingHistory] = useState(false); - - return ( -
-
- - - -
-
- ); -} diff --git a/components/campaigns/CampaignTable.tsx b/components/campaigns/CampaignTable.tsx index f2a8ee2f0..3cf47c587 100644 --- a/components/campaigns/CampaignTable.tsx +++ b/components/campaigns/CampaignTable.tsx @@ -25,6 +25,8 @@ import { TabFilter, mockApiService, } from '@/lib/data/campaigns-mock'; +import BackingHistory from './backing-history'; +import { sampleBackers } from '@/lib/data/backing-history-mock'; const CampaignRow = ({ campaign, @@ -420,6 +422,7 @@ const CampaignTable = () => { const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [campaignSummaryOpen, setCampaignSummaryOpen] = useState(false); + const [backingHistoryOpen, setBackingHistoryOpen] = useState(false); const [currentPage, setCurrentPage] = useState(1); const [totalPages, setTotalPages] = useState(1); const itemsPerPage = 10; @@ -477,8 +480,8 @@ const CampaignTable = () => { setCampaignSummaryOpen(true); break; case 'view-history': - // TODO: Navigate to history page toast.info('Opening history...'); + setBackingHistoryOpen(true); break; case 'campaign-details': // TODO: Navigate to details page @@ -719,6 +722,11 @@ const CampaignTable = () => { open={campaignSummaryOpen} setOpen={setCampaignSummaryOpen} /> + ); }; diff --git a/components/campaigns/back-project/back-project-form.tsx b/components/campaigns/back-project/back-project-form.tsx new file mode 100644 index 000000000..21c52022d --- /dev/null +++ b/components/campaigns/back-project/back-project-form.tsx @@ -0,0 +1,201 @@ +'use client'; + +import type React from 'react'; +import { useState } from 'react'; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@/components/ui/select'; +import { Checkbox } from '@/components/ui/checkbox'; +import { ArrowLeft, Check, Copy } from 'lucide-react'; +import { BoundlessButton } from '@/components/buttons'; + +interface BackProjectFormProps { + onSubmit: (data: { + amount: string; + currency: string; + token: string; + network: string; + walletAddress: string; + keepAnonymous: boolean; + }) => void; + isLoading?: boolean; +} + +const QUICK_AMOUNTS = [10, 20, 30, 50, 100, 500, 1000]; + +export function BackProjectForm({ + onSubmit, + isLoading = false, +}: BackProjectFormProps) { + const [amount, setAmount] = useState(''); + const [currency] = useState('USDT'); + const [token, setToken] = useState(''); + const [network, setNetwork] = useState('Stella / Soroban'); + const [walletAddress] = useState('GDS3...GB7'); + const [keepAnonymous, setKeepAnonymous] = useState(false); + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + onSubmit({ + amount, + currency, + token, + network, + walletAddress, + keepAnonymous, + }); + }; + + const handleQuickAmount = (quickAmount: number) => { + setAmount(quickAmount.toString()); + }; + + const handleCopyAddress = async (e: React.MouseEvent) => { + e.preventDefault(); + try { + await navigator.clipboard.writeText(walletAddress); + // Could add toast notification here instead of state + } catch { + // Fallback for browsers that don't support clipboard API + const textArea = document.createElement('textarea'); + // Silent fallback for older browsers + textArea.value = walletAddress; + document.body.appendChild(textArea); + textArea.select(); + try { + document.execCommand('copy'); + } catch { + // Copy failed, but no need to log in production + } + document.body.removeChild(textArea); + } + }; + + const isFormValid = amount && currency && token && walletAddress; + + return ( +
+
+ +

Back Project

+
+
+
+

+ Funds will be held in escrow and released only upon milestone + approvals. +

+
+ +
+ +
+ {currency} + setAmount(e.target.value)} + type='number' + className='w-full bg-transparent font-normal text-base text-placeholder focus:outline-none' + placeholder='1000' + disabled={isLoading} + /> +
+

min. amount: $10

+ +
+ {QUICK_AMOUNTS.map(quickAmount => ( + + ))} +
+
+ +
+ + +
+ +
+ +
+ setNetwork(e.target.value)} + type='text' + className='w-full bg-transparent font-normal text-base text-placeholder focus:outline-none' + disabled={isLoading} + /> +
+
+ +
+ + + + {walletAddress} + + +
+ +
+ setKeepAnonymous(checked as boolean)} + disabled={isLoading} + className='border-stepper-border data-[state=checked]:bg-primary data-[state=checked]:border-primary' + /> + +
+ + + Confirm Contribution + +
+
+ ); +} diff --git a/components/campaigns/back-project/index.tsx b/components/campaigns/back-project/index.tsx new file mode 100644 index 000000000..c8a3207ba --- /dev/null +++ b/components/campaigns/back-project/index.tsx @@ -0,0 +1,112 @@ +'use client'; + +import { useState } from 'react'; +import { BoundlessButton } from '@/components/buttons'; +import { ProjectSubmissionSuccess } from '@/components/project'; +import BoundlessSheet from '@/components/sheet/boundless-sheet'; +import { ProjectSubmissionLoading } from '@/components/flows/back-project/project-submission-loading'; +import { BackProjectForm } from './back-project-form'; + +type BackProjectState = 'form' | 'loading' | 'success'; + +interface BackProjectData { + amount: string; + currency: string; + token: string; + network: string; + walletAddress: string; + keepAnonymous: boolean; +} + +const BackProject = () => { + const [isSheetOpen, setIsSheetOpen] = useState(false); + const [backProjectState, setBackProjectState] = + useState('form'); + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const handleBackProject = (data: BackProjectData) => { + setBackProjectState('loading'); + // TODO: Send data to actual API endpoint when backend is ready + + // Simulate API call - data will be used when API is implemented + setTimeout(() => { + setBackProjectState('success'); + }, 2000); + }; + + // const handleContinue = () => { + // setIsSheetOpen(false) + // setBackProjectState("form") + // } + + // const handleViewHistory = () => { + // // Navigate to history page or open history modal + // setIsSheetOpen(false) + // // TODO: Implement backing history modal or navigation + // } + + // const handleBack = () => { + // if (backProjectState === "success") { + // setBackProjectState("form") + // } + // } + + const renderSheetContent = () => { + if (backProjectState === 'success') { + return ( +
+
+ {/* */} +
+ +
+ ); + } + + return ( +
+ + + {backProjectState === 'loading' && ( +
+ +
+ )} +
+ ); + }; + + return ( +
+ + {renderSheetContent()} + + + setIsSheetOpen(true)}> + Back Project + +
+ ); +}; + +export default BackProject; diff --git a/components/campaigns/back-project/project-submission-loading.tsx b/components/campaigns/back-project/project-submission-loading.tsx new file mode 100644 index 000000000..4dc27ea2d --- /dev/null +++ b/components/campaigns/back-project/project-submission-loading.tsx @@ -0,0 +1,15 @@ +export function ProjectSubmissionLoading() { + return ( +
+
+ {/* Outer spinning ring */} +
+ {/* Inner spinning arc */} +
+
+

+ Processing your contribution... +

+
+ ); +} diff --git a/components/flows/backing-history/backing-history-table.tsx b/components/campaigns/backing-history/backing-history-table.tsx similarity index 100% rename from components/flows/backing-history/backing-history-table.tsx rename to components/campaigns/backing-history/backing-history-table.tsx diff --git a/components/campaigns/backing-history/backing-history.tsx b/components/campaigns/backing-history/backing-history.tsx new file mode 100644 index 000000000..6f8e85275 --- /dev/null +++ b/components/campaigns/backing-history/backing-history.tsx @@ -0,0 +1,506 @@ +'use client'; + +import type React from 'react'; +import { useState, useMemo } from 'react'; +import { + Search, + Filter, + ArrowUpDown, + Calendar, + DollarSign, + User, + Wallet, + Check, + CheckIcon, +} from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import { Slider } from '@/components/ui/slider'; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@/components/ui/select'; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from '@/components/ui/popover'; +import { format } from 'date-fns'; +import BoundlessSheet from '@/components/sheet/boundless-sheet'; + +interface Backer { + id: string; + name: string; + avatar?: string; + amount: number; + date: Date; + walletId: string; + isAnonymous: boolean; +} + +interface BackingHistoryProps { + open: boolean; + setOpen: (open: boolean) => void; + backers: Backer[]; +} + +type SortOption = 'newest' | 'oldest' | 'alphabetical' | 'highest' | 'lowest'; +type IdentityFilter = 'all' | 'identified' | 'anonymous'; + +const BackingHistory: React.FC = ({ + open, + setOpen, + backers, +}) => { + const [searchQuery, setSearchQuery] = useState(''); + const [sortBy, setSortBy] = useState('newest'); + const [amountRange, setAmountRange] = useState([0, 10000]); + const [dateRange, setDateRange] = useState<{ from?: Date; to?: Date }>({}); + const [identityFilter, setIdentityFilter] = useState('all'); + const [showFilters, setShowFilters] = useState(false); + const [showSortPopover, setShowSortPopover] = useState(false); + + const setQuickDateFilter = (days: number) => { + const today = new Date(); + const pastDate = new Date(today.getTime() - days * 24 * 60 * 60 * 1000); + setDateRange({ from: pastDate, to: today }); + }; + + const resetFilters = () => { + setSearchQuery(''); + setSortBy('newest'); + setAmountRange([0, 10000]); + setDateRange({}); + setIdentityFilter('all'); + }; + + const resetDateRange = () => { + setDateRange({}); + }; + + const resetAmountRange = () => { + setAmountRange([10, 1000]); + }; + + const resetIdentityFilter = () => { + setIdentityFilter('all'); + }; + + const applyFilters = () => { + setShowSortPopover(false); + }; + + const filteredAndSortedBackers = useMemo(() => { + const filtered = backers.filter(backer => { + const matchesSearch = + backer.name.toLowerCase().includes(searchQuery.toLowerCase()) || + backer.walletId.toLowerCase().includes(searchQuery.toLowerCase()); + + const matchesAmount = + backer.amount >= amountRange[0] && backer.amount <= amountRange[1]; + + const matchesDate = + !dateRange.from || + !dateRange.to || + (backer.date >= dateRange.from && backer.date <= dateRange.to); + + const matchesIdentity = + identityFilter === 'all' || + (identityFilter === 'anonymous' && backer.isAnonymous) || + (identityFilter === 'identified' && !backer.isAnonymous); + + return matchesSearch && matchesAmount && matchesDate && matchesIdentity; + }); + + filtered.sort((a, b) => { + switch (sortBy) { + case 'newest': + return b.date.getTime() - a.date.getTime(); + case 'oldest': + return a.date.getTime() - b.date.getTime(); + case 'alphabetical': + return a.name.localeCompare(b.name); + case 'highest': + return b.amount - a.amount; + case 'lowest': + return a.amount - b.amount; + default: + return 0; + } + }); + + return filtered; + }, [backers, searchQuery, sortBy, amountRange, dateRange, identityFilter]); + + const formatDate = (date: Date) => { + const now = new Date(); + const diffInDays = Math.floor( + (now.getTime() - date.getTime()) / (1000 * 60 * 60 * 24) + ); + + if (diffInDays === 0) return 'Today'; + if (diffInDays === 1) return '1d'; + if (diffInDays < 7) return `${diffInDays}d`; + if (diffInDays < 30) return `${Math.floor(diffInDays / 7)}w`; + return format(date, 'MMM dd, yyyy'); + }; + + return ( + +
+
+ {/* Search and Controls */} +
+
+ + setSearchQuery(e.target.value)} + className='pl-10 py-5 placeholder:font-medium bg-muted/20 border-muted-foreground/20 text-white placeholder:text-muted-foreground' + /> +
+ + + + + + +
+ {/* Date Range Section */} +
+
+

+ Date range +

+ +
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ + + +
+
+
+ + {/* Amount Range Section */} +
+
+

+ Amount range +

+ +
+
+
+
+ +
+ + + setAmountRange([ + Number.parseInt(e.target.value) || 0, + amountRange[1], + ]) + } + className='bg-muted/20 border-muted-foreground/20 text-white pl-8' + /> +
+
+
+ +
+ + + setAmountRange([ + amountRange[0], + Number.parseInt(e.target.value) || 0, + ]) + } + className='bg-muted/20 border-muted-foreground/20 text-white pl-8' + /> +
+
+
+ +
+
+ + {/* Identity Type Section */} +
+
+

+ Identity Type +

+ +
+
+ + + +
+
+ + {/* Action Buttons */} +
+ + +
+
+
+
+
+ + {/* Filters Panel */} + {showFilters && ( +
+ {/* Sort Options */} +
+
+ + +
+ +
+
+ )} + + {/* Results Header */} +
+
Backer
+
Amount
+
Date
+
+ + {/* Backing List */} +
+ {filteredAndSortedBackers.map(backer => ( +
+
+
+ + + + {backer.isAnonymous ? ( + + ) : ( + backer.name.charAt(0) + )} + + +
+ +
+
+
+
{backer.name}
+
+ + {backer.walletId} +
+
+
+
+ ${backer.amount.toLocaleString()} +
+
+ {formatDate(backer.date)} +
+
+ ))} +
+ + {filteredAndSortedBackers.length === 0 && ( +
+ No backers found matching your criteria +
+ )} +
+
+
+ ); +}; + +export default BackingHistory; diff --git a/components/flows/backing-history/filter-popover.tsx b/components/campaigns/backing-history/filter-popover.tsx similarity index 100% rename from components/flows/backing-history/filter-popover.tsx rename to components/campaigns/backing-history/filter-popover.tsx diff --git a/components/flows/backing-history/index.tsx b/components/campaigns/backing-history/index.tsx similarity index 98% rename from components/flows/backing-history/index.tsx rename to components/campaigns/backing-history/index.tsx index af9bf4c98..f457a3f33 100644 --- a/components/flows/backing-history/index.tsx +++ b/components/campaigns/backing-history/index.tsx @@ -119,6 +119,7 @@ const BackingHistory: React.FC = ({
+

Backing History

{/* Search and Controls */}
diff --git a/components/flows/backing-history/sort-filter-popover.tsx b/components/campaigns/backing-history/sort-filter-popover.tsx similarity index 100% rename from components/flows/backing-history/sort-filter-popover.tsx rename to components/campaigns/backing-history/sort-filter-popover.tsx diff --git a/lib/data/backing-history-mock.ts b/lib/data/backing-history-mock.ts index 3de9417e2..e20b387a4 100644 --- a/lib/data/backing-history-mock.ts +++ b/lib/data/backing-history-mock.ts @@ -1,142 +1,79 @@ -import type { BackingHistoryItem } from '@/types/backing-history'; - -export const mockBackingHistory: BackingHistoryItem[] = [ +export const sampleBackers = [ { id: '1', - backer: { - name: 'Collins Odumeje', - isAnonymous: false, - avatar: '/diverse-user-avatars.png', - walletAddress: 'GDS3...GB7', - }, + name: 'Collins Odumeje', + avatar: '/placeholder.svg?height=32&width=32', amount: 2300, - currency: 'USDT', - date: new Date('2025-08-17'), - timeAgo: '3s', + date: new Date('2025-08-05'), + walletId: 'GDS3...GB7', + isAnonymous: false, }, { id: '2', - backer: { - name: 'Sarah Chen', - isAnonymous: false, - avatar: '/diverse-user-avatars.png', - walletAddress: 'ABC1...XYZ', - }, - amount: 1500, - currency: 'USDT', - date: new Date('2025-08-16'), - timeAgo: '1d', + name: 'Collins Odumeje', + avatar: '/placeholder.svg?height=32&width=32', + amount: 2300, + date: new Date('2025-08-05'), + walletId: 'GDS3...GB7', + isAnonymous: false, }, { id: '3', - backer: { - name: 'Anonymous', - isAnonymous: true, - avatar: '/anonymous-user-concept.png', - walletAddress: 'DEF4...789', - }, - amount: 5000, - currency: 'USDT', - date: new Date('2025-08-15'), - timeAgo: '2d', + name: 'Collins Odumeje', + avatar: '/placeholder.svg?height=32&width=32', + amount: 2300, + date: new Date('2025-08-05'), + walletId: 'GDS3...GB7', + isAnonymous: false, }, { id: '4', - backer: { - name: 'Michael Rodriguez', - isAnonymous: false, - avatar: '/diverse-user-avatars.png', - walletAddress: 'HIJ7...456', - }, - amount: 750, - currency: 'USDT', - date: new Date('2025-08-14'), - timeAgo: '3d', + name: 'Anonymous', + amount: 2300, + date: new Date('2025-08-05'), + walletId: 'GDS3...GB7', + isAnonymous: true, }, { id: '5', - backer: { - name: 'Anonymous', - isAnonymous: true, - avatar: '/anonymous-user-concept.png', - walletAddress: 'KLM0...123', - }, - amount: 3200, - currency: 'USDT', - date: new Date('2025-08-13'), - timeAgo: '4d', + name: 'Collins Odumeje', + avatar: '/placeholder.svg?height=32&width=32', + amount: 2300, + date: new Date('2025-08-05'), + walletId: 'GDS3...GB7', + isAnonymous: false, }, { id: '6', - backer: { - name: 'Emma Thompson', - isAnonymous: false, - avatar: '/diverse-user-avatars.png', - walletAddress: 'NOP3...890', - }, - amount: 1800, - currency: 'USDT', - date: new Date('2025-08-12'), - timeAgo: '5d', + name: 'Anonymous', + amount: 2300, + date: new Date('2025-08-05'), + walletId: 'GDS3...GB7', + isAnonymous: true, }, { id: '7', - backer: { - name: 'David Kim', - isAnonymous: false, - avatar: '/diverse-user-avatars.png', - walletAddress: 'QRS6...567', - }, - amount: 4500, - currency: 'USDT', - date: new Date('2025-08-11'), - timeAgo: '6d', + name: 'Anonymous', + amount: 2300, + date: new Date('2025-08-05'), + walletId: 'GDS3...GB7', + isAnonymous: true, }, { id: '8', - backer: { - name: 'Anonymous', - isAnonymous: true, - avatar: '/anonymous-user-concept.png', - walletAddress: 'TUV9...234', - }, - amount: 950, - currency: 'USDT', - date: new Date('2025-08-10'), - timeAgo: '1w', + name: 'Collins Odumeje', + avatar: '/placeholder.svg?height=32&width=32', + amount: 2300, + date: new Date('2025-08-05'), + walletId: 'GDS3...GB7', + isAnonymous: false, }, { id: '9', - backer: { - name: 'Lisa Wang', - isAnonymous: false, - avatar: '/diverse-user-avatars.png', - walletAddress: 'WXY2...901', - }, - amount: 2750, - currency: 'USDT', - date: new Date('2025-08-09'), - timeAgo: '1w', - }, - { - id: '10', - backer: { - name: 'Anonymous', - isAnonymous: true, - avatar: '/anonymous-user-concept.png', - walletAddress: 'ZAB5...678', - }, - amount: 6200, - currency: 'USDT', - date: new Date('2025-08-08'), - timeAgo: '1w', + name: 'Anonymous', + amount: 2300, + date: new Date('2025-08-05'), + walletId: 'GDS3...GB7', + isAnonymous: true, }, ]; - -export const sortOptions = [ - { value: 'newest', label: 'Newest first' }, - { value: 'oldest', label: 'Oldest first' }, - { value: 'alphabetical', label: 'Alphabetical' }, - { value: 'amount-high', label: 'Highest first' }, - { value: 'amount-low', label: 'Lowest first' }, -];