BuySimView.tsx 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import React from 'react';
  2. import { useNavigate, Link } from 'react-router-dom';
  3. import { SimProduct } from '../types';
  4. const BuySimView: React.FC = () => {
  5. const navigate = useNavigate();
  6. const popularSims: SimProduct[] = [
  7. { id: 'p1', country: 'China', flag: 'cn', originalPrice: '$0.94', discountPrice: '$0.85', discountLabel: '-10%' },
  8. { id: 'p2', country: 'Hong Kong', flag: 'hk', originalPrice: '$4.43', discountPrice: '$4.21', discountLabel: '-5%' },
  9. { id: 'p3', country: 'Japan', flag: 'jp', originalPrice: '$1.44', discountPrice: '$1.3', discountLabel: '-10%' },
  10. { id: 'p4', country: 'Singapore', flag: 'sg', originalPrice: '$4.43', discountPrice: '$4.21', discountLabel: '-5%' },
  11. { id: 'p5', country: 'South Korea', flag: 'kr', originalPrice: '$0.94', discountPrice: '$0.85', discountLabel: '-10%' },
  12. { id: 'p6', country: 'Taiwan', flag: 'tw', originalPrice: '$2.04', discountPrice: '$1.84', discountLabel: '-10%' },
  13. { id: 'p7', country: 'Thailand', flag: 'th', originalPrice: '$1.89', discountPrice: '$1.78', discountLabel: '-6%' },
  14. { id: 'p8', country: 'United States', flag: 'us', originalPrice: '$2.16', discountPrice: '$1.94', discountLabel: '-10%' },
  15. ];
  16. const handleSelect = (p: SimProduct) => {
  17. navigate(`/product/${p.country.toLowerCase()}`, { state: {
  18. country: p.country,
  19. flag: p.flag,
  20. image: p.isRegion
  21. ? 'https://images.unsplash.com/photo-1526772662000-3f88f10c053b?q=80&w=1000&auto=format&fit=crop'
  22. : (p.country === 'Thailand'
  23. ? 'https://images.unsplash.com/photo-1528181304800-2f140819898f?q=80&w=1000&auto=format&fit=crop'
  24. : `https://images.unsplash.com/photo-1526772662000-3f88f10c053b?q=80&w=1000&auto=format&fit=crop`)
  25. }});
  26. };
  27. const ProductCard: React.FC<{ p: SimProduct }> = ({ p }) => (
  28. <div
  29. onClick={() => handleSelect(p)}
  30. className="bg-white border border-slate-100 rounded-[20px] p-4 md:p-6 shadow-sm hover:shadow-lg transition-all relative flex items-center space-x-4 group cursor-pointer"
  31. >
  32. <div className="absolute top-0 right-0 bg-[#EE0434] text-white text-[10px] font-black px-3 py-1.5 rounded-tr-[19px] rounded-bl-[14px]">
  33. {p.discountLabel}
  34. </div>
  35. <div className="w-12 h-12 rounded-full overflow-hidden shrink-0 border border-slate-50 bg-slate-50">
  36. <img src={`https://flagcdn.com/w160/${p.flag}.png`} alt={p.country} className="w-full h-full object-cover scale-150" />
  37. </div>
  38. <div className="flex-1">
  39. <h3 className="text-slate-900 font-black text-base md:text-lg mb-0.5 group-hover:text-[#EE0434] transition-colors">{p.country}</h3>
  40. <p className="text-[#EE0434] font-bold text-sm md:text-lg">from: <span className="font-black">{p.discountPrice}</span></p>
  41. </div>
  42. </div>
  43. );
  44. return (
  45. <div className="bg-[#fcfdfe] min-h-screen">
  46. <div className="max-w-7xl mx-auto px-4 py-4 md:py-6 border-b border-slate-50">
  47. <nav className="flex items-center space-x-2 text-xs md:text-sm text-slate-500">
  48. <Link to="/" className="hover:text-[#EE0434]">Home</Link>
  49. <svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M9 5l7 7-7 7" strokeWidth={2.5} strokeLinecap="round" strokeLinejoin="round"/></svg>
  50. <span className="text-slate-900 font-bold">Buy Sim</span>
  51. </nav>
  52. </div>
  53. <div className="max-w-7xl mx-auto px-4 py-8 md:py-12">
  54. <div className="flex justify-center mb-12 md:mb-20">
  55. <div className="w-full max-w-3xl relative group">
  56. <input type="text" placeholder="Choose country you're going to" className="w-full bg-white rounded-full py-4 md:py-6 px-10 md:px-12 text-base md:text-xl text-slate-700 shadow-sm border border-slate-100 outline-none focus:ring-4 focus:ring-red-50 transition-all placeholder:text-slate-300" />
  57. <button className="absolute right-2 md:right-3 top-2 md:top-3 bottom-2 md:bottom-3 aspect-square bg-[#EE0434] rounded-full flex items-center justify-center text-white shadow-lg shadow-red-200 hover:scale-105 transition-all">
  58. <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" strokeWidth={2.5} strokeLinecap="round" strokeLinejoin="round"/></svg>
  59. </button>
  60. </div>
  61. </div>
  62. <section className="mb-12">
  63. <h2 className="text-xl md:text-[32px] font-black text-slate-900 mb-6 md:mb-8 tracking-tight">SIM Popular</h2>
  64. <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 md:gap-6">
  65. {popularSims.map(p => <ProductCard key={p.id} p={p} />)}
  66. </div>
  67. </section>
  68. </div>
  69. </div>
  70. );
  71. };
  72. export default BuySimView;