From 10e8e28c52d65a8243d65450283181b21ae3636c Mon Sep 17 00:00:00 2001 From: CycroftX Date: Tue, 3 Feb 2026 21:04:57 +0530 Subject: [PATCH] Add Payment Gateway selection to Settings page --- .../components/PaymentGatewayCard.tsx | 132 ++++++++++++++++++ src/pages/Settings.tsx | 37 +---- 2 files changed, 138 insertions(+), 31 deletions(-) create mode 100644 src/features/settings/components/PaymentGatewayCard.tsx diff --git a/src/features/settings/components/PaymentGatewayCard.tsx b/src/features/settings/components/PaymentGatewayCard.tsx new file mode 100644 index 0000000..d8db0c8 --- /dev/null +++ b/src/features/settings/components/PaymentGatewayCard.tsx @@ -0,0 +1,132 @@ + +import { CreditCard, CheckCircle2, RotateCw } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { Badge } from "@/components/ui/badge"; +import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; +import { Label } from "@/components/ui/label"; +import { useState } from "react"; +import { toast } from "sonner"; +import { cn } from "@/lib/utils"; + +const availableGateways = [ + { + id: "stripe", + name: "Stripe", + logo: "https://upload.wikimedia.org/wikipedia/commons/b/ba/Stripe_Logo%2C_revised_2016.svg", + fee: "2.9% + ₹30", + status: "Connected", + }, + { + id: "razorpay", + name: "Razorpay", + logo: "https://upload.wikimedia.org/wikipedia/commons/8/89/Razorpay_logo.svg", + fee: "2%", + status: "Available", + }, + { + id: "phonepe", + name: "PhonePe", + logo: "https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/PhonePe_Logo.svg/2560px-PhonePe_Logo.svg.png", + fee: "1.9%", + status: "Available", + }, + { + id: "cashfree", + name: "Cashfree", + logo: "https://upload.wikimedia.org/wikipedia/commons/thumb/1/12/Cashfree_Payments_Logo.svg/2560px-Cashfree_Payments_Logo.svg.png", + fee: "1.95%", + status: "Available", + } +]; + +export function PaymentGatewayCard() { + const [activeGateway, setActiveGateway] = useState("stripe"); + const [loading, setLoading] = useState(null); + + const handleGatewayChange = (id: string) => { + if (activeGateway === id) return; + setLoading(id); + + // Simulate connection lag + setTimeout(() => { + setActiveGateway(id); + setLoading(null); + toast.success(`Switched active payment gateway to ${availableGateways.find(g => g.id === id)?.name}`); + }, 1500); + }; + + return ( +
+
+
+ +
+
+

Payment Gateway

+

Collection preferences

+
+
+ {loading ? ( + + ) : ( + +
+ Processing + + )} +
+
+ +
+ + {availableGateways.map((gateway) => ( +
handleGatewayChange(gateway.id)} + > +
+ +
+ {/* Placeholder for logos if external works, else text */} + {/* Using text fallback for safety/offline dev */} + {gateway.name} +
+
+ +

Fee: {gateway.fee}

+
+
+ {gateway.status === "Connected" || activeGateway === gateway.id ? ( + + ) : ( + + )} +
+ ))} +
+
+ +
+

+ Processing payments settled in T+2 days via selected gateway. +

+
+
+ ); +} diff --git a/src/pages/Settings.tsx b/src/pages/Settings.tsx index 55814f8..5bbebc2 100644 --- a/src/pages/Settings.tsx +++ b/src/pages/Settings.tsx @@ -3,6 +3,7 @@ import { OrganizationProfileCard } from '@/features/settings/components/Organiza import { PayoutBankingCard } from '@/features/settings/components/PayoutBankingCard'; import { TeamSecurityCard } from '@/features/settings/components/TeamSecurityCard'; import { DeveloperSection } from '@/features/settings/components/DeveloperSection'; +import { PaymentGatewayCard } from '@/features/settings/components/PaymentGatewayCard'; export default function Settings() { return ( @@ -11,42 +12,16 @@ export default function Settings() { description="Manage platform configuration and critical operations." >
- {/* Top Grid */} + {/* Top Grid: Identity & Banking */}
- {/* Box 1: Organization Identity (High Priority) */} - - {/* Box 2: Financials & Banking (High Priority) */}
-
- {/* Box 3: Security (Full Width on Mobile, 2/3 on Desktop if needed, but here simple 1/3 stack or full width row) */} - {/* Adjusting layout: Let's make Security taking full row or sidebar style. - Based on requirements "2x2 Grid or Vertical Stack". - Let's stick to a clean layout where Security sits next to maybe a logs panel or just takes full width. - Actually, the requirements said "Layout: 2x2 Grid". - Let's put Team & Security as the 3rd box, and maybe Developer as 4th? - But Developer is collapsible. - */} -
- -
-
- {/* Placeholder or Tip card? Or maybe just make TeamSecurityCard full width if it has lists. - The TeamSecurityCard design I made is card-like. - Let's span it across 2 columns for better readability of the list. - */} -
-

Need Help?

-

- Contact our dedicated support team for assistance with account configurations. -

- -
-
+ {/* Middle Grid: Gateways & Security */} +
+ +
{/* Collapsible Developer Section */}