|
1 | 1 | import { motion } from 'framer-motion' |
2 | 2 |
|
| 3 | +// E-commerce Tutorials |
| 4 | +export function EcommerceTutorials() { |
| 5 | + const tutorials = [ |
| 6 | + { |
| 7 | + title: "Online Store Integration", |
| 8 | + description: "Complete e-commerce store with Solana payments", |
| 9 | + level: "Beginner", |
| 10 | + time: "30 minutes", |
| 11 | + code: `// E-commerce checkout with SVM-Pay |
| 12 | +import { SVMPay, PaymentForm } from '@svm-pay/sdk' |
| 13 | +
|
| 14 | +const EcommerceCheckout = ({ cartItems, total }) => { |
| 15 | + const handlePayment = async (paymentData) => { |
| 16 | + const payment = SVMPay.createPayment({ |
| 17 | + recipient: process.env.STORE_WALLET, |
| 18 | + amount: total, |
| 19 | + token: 'USDC', |
| 20 | + metadata: { |
| 21 | + orderId: generateOrderId(), |
| 22 | + items: cartItems, |
| 23 | + customerEmail: paymentData.email |
| 24 | + } |
| 25 | + }) |
| 26 | +
|
| 27 | + const result = await payment.execute() |
| 28 | + |
| 29 | + if (result.status === 'SUCCESS') { |
| 30 | + // Update inventory |
| 31 | + await updateInventory(cartItems) |
| 32 | + // Send confirmation email |
| 33 | + await sendOrderConfirmation(paymentData.email, result.transactionId) |
| 34 | + // Redirect to success page |
| 35 | + router.push('/order-success') |
| 36 | + } |
| 37 | + } |
| 38 | +
|
| 39 | + return <PaymentForm onSubmit={handlePayment} amount={total} /> |
| 40 | +}` |
| 41 | + } |
| 42 | + ] |
| 43 | + |
| 44 | + return ( |
| 45 | + <div className="pt-20 p-8 max-w-6xl"> |
| 46 | + <motion.div |
| 47 | + initial={{ opacity: 0, y: 20 }} |
| 48 | + animate={{ opacity: 1, y: 0 }} |
| 49 | + transition={{ duration: 0.5 }} |
| 50 | + > |
| 51 | + <h1 className="text-4xl font-bold text-slate-900 mb-6">E-commerce Tutorials</h1> |
| 52 | + <p className="text-xl text-slate-600 mb-8"> |
| 53 | + Build sophisticated e-commerce solutions with Solana payments |
| 54 | + </p> |
| 55 | + |
| 56 | + <div className="space-y-8"> |
| 57 | + {tutorials.map((tutorial, index) => ( |
| 58 | + <div key={index} className="bg-white border border-slate-200 rounded-lg p-6"> |
| 59 | + <div className="flex items-start justify-between mb-4"> |
| 60 | + <div> |
| 61 | + <h3 className="text-xl font-semibold text-slate-900 mb-2">{tutorial.title}</h3> |
| 62 | + <p className="text-slate-600 mb-2">{tutorial.description}</p> |
| 63 | + <div className="flex space-x-4 text-sm text-slate-500"> |
| 64 | + <span>Level: {tutorial.level}</span> |
| 65 | + <span>Time: {tutorial.time}</span> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + |
| 70 | + <div className="bg-slate-900 rounded-lg p-4"> |
| 71 | + <pre className="text-sm text-slate-100 overflow-x-auto"> |
| 72 | + <code>{tutorial.code}</code> |
| 73 | + </pre> |
| 74 | + </div> |
| 75 | + </div> |
| 76 | + ))} |
| 77 | + </div> |
| 78 | + </motion.div> |
| 79 | + </div> |
| 80 | + ) |
| 81 | +} |
| 82 | + |
3 | 83 | // Gaming & NFT Tutorials |
4 | 84 | export function GamingTutorials() { |
5 | 85 | const tutorials = [ |
|
0 commit comments