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.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. : view.type === 'collection'
  50. ? `${view.collection.name} - ${storeName}`
  51. : page
  52. ? `${page.title} - ${storeName}`
  53. : storeName;
  54. return (
  55. <>
  56. <Head
  57. title={
  58. preview
  59. ? `${title} (preview)`
  60. : storefrontTitlePrefix + title
  61. }
  62. >
  63. {fontUrl && <link rel="stylesheet" href={fontUrl} />}
  64. </Head>
  65. <StorefrontRenderer
  66. plan={plan}
  67. fonts={fonts}
  68. view={view}
  69. baseUrl={baseUrl}
  70. language={language}
  71. products={products}
  72. cart={cart}
  73. storeName={storeName}
  74. shop={shop}
  75. featuredProducts={featuredProducts}
  76. heroImages={heroImages}
  77. />
  78. </>
  79. );
  80. }