diff --git a/client/components/views/dashboard-view.tsx b/client/components/views/dashboard-view.tsx index f49e080..ddb129f 100644 --- a/client/components/views/dashboard-view.tsx +++ b/client/components/views/dashboard-view.tsx @@ -5,10 +5,6 @@ import { PortfolioOverview } from "@/components/portfolio-overview"; import { AssetAllocationChart } from "@/components/asset-allocation-chart"; import { ShariaCertificationHub } from "@/components/sharia-certification-hub"; import { MetalPriceHistoryChart } from "@/components/charts/metal-price-history"; -import Image from 'next/image' -import { PortfolioOverview } from '@/components/portfolio-overview' -import { AssetAllocationChart } from '@/components/asset-allocation-chart' -import { ShariaCertificationHub } from '@/components/sharia-certification-hub' import BullionCard from '@/components/ui/bullion-card' export function DashboardView() { diff --git a/client/components/views/redemption-view.tsx b/client/components/views/redemption-view.tsx index bd8880e..c534ce3 100644 --- a/client/components/views/redemption-view.tsx +++ b/client/components/views/redemption-view.tsx @@ -9,72 +9,33 @@ import { Badge } from '@/components/ui/badge' import { useAPAXStore, formatCurrency } from '@/lib/store' const bullionOptions = [ - { - id: 'gold-1g', - metal: 'Gold', - weight: '1g', - weightGrams: 1, - image: '/images/image.png', - color: '#D4AF37', - tokensRequired: 1 - }, - { - id: 'gold-10g', - metal: 'Gold', - weight: '10g', - weightGrams: 10, - image: '/images/image.png', - color: '#D4AF37', - tokensRequired: 10 - }, - { - id: 'gold-100g', - metal: 'Gold', - weight: '100g', - weightGrams: 100, - image: '/images/image.png', - color: '#D4AF37', - tokensRequired: 100 - }, - { - id: 'silver-100g', - metal: 'Silver', - weight: '100g', - weightGrams: 100, - image: '/images/image.png', - color: '#C0C0C0', - tokensRequired: 100 - }, - { - id: 'silver-1kg', - metal: 'Silver', - weight: '1kg', - weightGrams: 1000, - image: '/images/image.png', - color: '#C0C0C0', - tokensRequired: 1000 - }, - { - id: 'platinum-50g', - metal: 'Platinum', - weight: '50g', - weightGrams: 50, - image: '/images/image.png', - color: '#E5E4E2', - tokensRequired: 50 - } + { id: 'gold-1g', metal: 'Gold', weight: '1g', weightGrams: 1, image: '/images/image.png', color: '#D4AF37', tokensRequired: 1 }, + { id: 'gold-10g', metal: 'Gold', weight: '10g', weightGrams: 10, image: '/images/image.png', color: '#D4AF37', tokensRequired: 10 }, + { id: 'gold-100g', metal: 'Gold', weight: '100g', weightGrams: 100, image: '/images/image.png', color: '#D4AF37', tokensRequired: 100 }, + { id: 'silver-100g', metal: 'Silver', weight: '100g', weightGrams: 100, image: '/images/image.png', color: '#C0C0C0', tokensRequired: 100 }, + { id: 'silver-1kg', metal: 'Silver', weight: '1kg', weightGrams: 1000, image: '/images/image.png', color: '#C0C0C0', tokensRequired: 1000 }, + { id: 'platinum-50g', metal: 'Platinum', weight: '50g', weightGrams: 50, image: '/images/image.png', color: '#E5E4E2', tokensRequired: 50 } ] +type Step = 1 | 2 | 3 + export function RedemptionView() { const { userHoldings, metalPrices } = useAPAXStore() const [selectedOption, setSelectedOption] = useState(null) + const [currentStep, setCurrentStep] = useState(1) + const [shippingInfo, setShippingInfo] = useState({ name: '', address: '', city: '', country: '' }) + const [isBurning, setIsBurning] = useState(false) + const [burnSuccess, setBurnSuccess] = useState(false) + + const selectedBullion = bullionOptions.find((b) => b.id === selectedOption) const calculatePrice = (metal: string, grams: number) => { - const pricePerGram = metal === 'Gold' - ? metalPrices.gold / 31.1035 - : metal === 'Silver' - ? metalPrices.silver / 31.1035 - : metalPrices.platinum / 31.1035 + const pricePerGram = + metal === 'Gold' + ? metalPrices.gold / 31.1035 + : metal === 'Silver' + ? metalPrices.silver / 31.1035 + : metalPrices.platinum / 31.1035 return pricePerGram * grams } @@ -84,8 +45,30 @@ export function RedemptionView() { return userHoldings.platinumGrams >= grams } + const handleNext = () => { + if (currentStep === 1 && selectedBullion && !canAfford(selectedBullion.metal, selectedBullion.weightGrams)) { + alert('Insufficient holdings for this option!') + return + } + setCurrentStep((prev) => (prev < 3 ? (prev + 1) as Step : prev)) + } + + const handleBack = () => setCurrentStep((prev) => (prev > 1 ? (prev - 1) as Step : prev)) + + const handleBurn = async () => { + setIsBurning(true) + setBurnSuccess(false) + + // simulate high-fidelity burn transaction + await new Promise((res) => setTimeout(res, 3000)) + + setIsBurning(false) + setBurnSuccess(true) + } + return (
+ {/* Page Header */}
@@ -96,10 +79,7 @@ export function RedemptionView() { Convert your tokens into physical bullion delivered to your door

- + Coming Soon @@ -164,14 +144,117 @@ export function RedemptionView() { - {/* Bullion Selection Grid */} + {/* Multi-Step Redemption Flow */} + + + {/* Step Indicators */} +
+ {['Select', 'Shipping', 'Verify'].map((label, idx) => { + const stepNum = idx + 1 + return ( +
+ ) + })} +
+ + {/* Step 1: Select Metal */} + {currentStep === 1 && ( +
+

Select Bullion

+
+ {bullionOptions.map((option) => { + const price = calculatePrice(option.metal, option.weightGrams) + const affordable = canAfford(option.metal, option.weightGrams) + return ( + setSelectedOption(option.id)} + > +
+
+

{option.metal}

+

{option.weight}

+
+

{formatCurrency(price)}

+
+ {!affordable && ( +
+ Insufficient balance +
+ )} +
+ ) + })} +
+
+ )} + + {/* Step 2: Shipping */} + {currentStep === 2 && selectedBullion && ( +
+

Shipping Information

+
+ {['name', 'address', 'city', 'country'].map((field) => ( + + setShippingInfo((prev) => ({ ...prev, [field]: e.target.value })) + } + className="w-full p-2 rounded bg-[#222] text-[#E8E8E8] placeholder-[#888]" + /> + ))} +
+
+ )} + + {/* Step 3: Verify & Burn */} + {currentStep === 3 && selectedBullion && ( +
+

Verify & Burn

+

+ Bullion: {selectedBullion.metal} {selectedBullion.weight}
+ Requires: {selectedBullion.tokensRequired} APX-{selectedBullion.metal} tokens +

+

+ Shipping to: {shippingInfo.name}, {shippingInfo.address}, {shippingInfo.city},{' '} + {shippingInfo.country} +

+ +
+ )} + + {/* Navigation */} +
+ {currentStep > 1 && } + {currentStep < 3 && ( + + )} +
+ + + + {/* Bullion Selection Grid (Original UI) */}

Available Bullion Options

{bullionOptions.map((option) => { const price = calculatePrice(option.metal, option.weightGrams) const affordable = canAfford(option.metal, option.weightGrams) - + return (
- {/* Info Cards */} + {/* Info Cards (Original UI) */}
@@ -242,8 +325,7 @@ export function RedemptionView() {

Secure Packaging

- All bullion is shipped in tamper-evident, insured packaging with - real-time tracking throughout delivery. + All bullion is shipped in tamper-evident, insured packaging with real-time tracking.

@@ -257,8 +339,7 @@ export function RedemptionView() {

Global Delivery

- We ship to 100+ countries worldwide. Delivery times vary from - 5-15 business days depending on location. + We ship to 100+ countries worldwide. Delivery times vary from 5-15 business days depending on location.