index.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { useTranslation } from 'react-i18next';
  2. import { useNavigate } from 'react-router-dom';
  3. import { useScrollToCenter } from '../../useScrollToCenter';
  4. import PlanCard from './PlanCard';
  5. import { useService } from './useService';
  6. import Wrapper from '../Wrapper';
  7. import { encryptUrlParams } from '@/utils/requestCrypto';
  8. export function Pricing() {
  9. const { t } = useTranslation();
  10. const navigate = useNavigate();
  11. const { plans, selectedPlanId, setSelectedPlanId } = useService();
  12. const scrollRef = useScrollToCenter();
  13. return (
  14. <section className="w-full pt-7 sm:pt-16 lg:pt-[176px]">
  15. <Wrapper>
  16. <div className="text-center max-w-[672px] mx-auto mb-8 sm:mb-12">
  17. <h2 className="text-2xl sm:text-[32px] font-medium text-white">
  18. {t('pages.home.pricing.title')}
  19. </h2>
  20. <p className="mt-4 text-white/60 text-base text-center">
  21. {t('pages.home.pricing.subtitle')}
  22. </p>
  23. </div>
  24. </Wrapper>
  25. <div
  26. ref={scrollRef}
  27. className="w-full sm:max-w-full sm:overflow-x-auto sm:overflow-y-hidden sm:no-scrollbar py-4"
  28. >
  29. <Wrapper className="w-fit min-w-full flex flex-wrap sm:flex-nowrap items-stretch gap-8">
  30. {plans.map((plan) => (
  31. <PlanCard
  32. key={plan.id}
  33. id={plan.id}
  34. title={plan.title}
  35. subTitle={plan.subTitle}
  36. introduce={plan.introduce}
  37. tag={plan.tag}
  38. tagType={plan.tagType}
  39. isSelected={selectedPlanId === plan.id}
  40. onSelected={() => setSelectedPlanId(plan.id)}
  41. onGetStarted={async () => {
  42. const d = await encryptUrlParams({ planId: plan.id });
  43. navigate(`/pricing?d=${d}`);
  44. }}
  45. />
  46. ))}
  47. </Wrapper>
  48. </div>
  49. </section>
  50. );
  51. }