AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

preview.tsx 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { Head } from '@inertiajs/react';
  2. import { StorefrontRenderer } from '@/storefront/renderer';
  3. import { fontStylesheetUrl, storefrontTitlePrefix } from '@/storefront/theme';
  4. import type {
  5. FontMap,
  6. HeroImageSet,
  7. ShopInfo,
  8. StoreCart,
  9. StorePlan,
  10. StoreProduct,
  11. StorefrontView,
  12. } from '@/storefront/types';
  13. export default function PreviewStore({
  14. storeName,
  15. language,
  16. plan,
  17. fonts,
  18. baseUrl,
  19. preview,
  20. view,
  21. products,
  22. cart,
  23. shop,
  24. featuredProducts,
  25. heroImages,
  26. }: {
  27. storeName: string;
  28. language: string;
  29. plan: StorePlan;
  30. fonts: FontMap;
  31. baseUrl: string;
  32. /** True in the owner's preview, false on the live store. */
  33. preview: boolean;
  34. view: StorefrontView;
  35. products: StoreProduct[];
  36. cart: StoreCart;
  37. shop: ShopInfo;
  38. featuredProducts: Record<string, StoreProduct>;
  39. heroImages: HeroImageSet;
  40. }) {
  41. const fontUrl = fontStylesheetUrl(plan.theme, fonts);
  42. const page =
  43. view.type === 'page' && view.pageId !== 'home'
  44. ? plan.pages.find((candidate) => candidate.id === view.pageId)
  45. : undefined;
  46. const title =
  47. view.type === 'product'
  48. ? view.product.name
  49. : page
  50. ? `${page.title} - ${storeName}`
  51. : storeName;
  52. return (
  53. <>
  54. <Head
  55. title={
  56. preview
  57. ? `${title} (preview)`
  58. : storefrontTitlePrefix + title
  59. }
  60. >
  61. {fontUrl && <link rel="stylesheet" href={fontUrl} />}
  62. </Head>
  63. <StorefrontRenderer
  64. plan={plan}
  65. fonts={fonts}
  66. view={view}
  67. baseUrl={baseUrl}
  68. language={language}
  69. products={products}
  70. cart={cart}
  71. storeName={storeName}
  72. shop={shop}
  73. featuredProducts={featuredProducts}
  74. heroImages={heroImages}
  75. />
  76. </>
  77. );
  78. }