"use client"; import { useCallback, useState } from 'react'; import PageTitle from '@/components/ui/PageTitle'; import { Typography, Button, Input, Form, Select, Switch, Flex } from 'antd'; import Link from 'next/link'; import { BankFilled, WalletFilled } from '@ant-design/icons'; import type { PaymentType } from '@/types/payment'; import { useQuery } from '@tanstack/react-query'; import { getPaymentType } from '@/app/api/general/paymentService'; import AltLayout from '@/components/layout/AltLayout'; const { Text, Title } = Typography; const CreatePersona: React.FC = () => { // Form states const [selectedPaymentID, setSelectedPaymentID] = useState(); const [companyName, setCompanyName] = useState(''); const [cardNumber, setCardNumber] = useState(''); const [cvc, setCvc] = useState(''); // Fetch payment types using React Query const { data: paymentType, error, isLoading } = useQuery({ queryKey: ['getPaymentType'], queryFn: getPaymentType }); const renderIcon = useCallback((nameId: string) => { if (nameId === "card") return else if (nameId === "bank") return else return <> }, []) if (isLoading) return

Loading...

; return ( PAYMENT}>
{/* Section intro */}

Enter your payment details
By continuing you agree to our Terms

{/* Payment type selection */}
{paymentType?.map(({ id, type, description, icon_id }) => (
setSelectedPaymentID(id)} > {renderIcon(icon_id)}

Transfer via card number

))}
{/* Payment form */}
{/* Company Name */} Company Name}> setCompanyName(e.target.value)} /> {/* Card Number with formatting */} Card Number}> { const rawValue = e.target.value.replace(/\D/g, '').slice(0, 16); const formattedValue = rawValue.replace(/(.{4})/g, '$1 ').trim(); setCardNumber(formattedValue); }} /> {/* Expiration Month & Year */}
Exp Month} className="w-full"> { const year = new Date().getFullYear() + i; return { label: String(year), value: String(year) }; })} />
{/* CVC with note */} CVC}>
{ const rawValue = e.target.value.replace(/\D/g, '').slice(0, 4); setCvc(rawValue); }} />

3 or 4 digits usually found on the signature strip

{/* Default payment switch */}
{ }} /> SET AS DEFAULT
{/* Submit Button */}
); }; export default CreatePersona;