From 567f03d1280bbfe413f736b15f2635c24f041ab0 Mon Sep 17 00:00:00 2001 From: francesco Date: Fri, 6 Dec 2024 12:14:32 +0100 Subject: [PATCH] Updated next js previews --- .../collections/components/CMSBlogPreview.tsx | 21 +++++- .../components/CMSProductPreview.tsx | 18 ++++- .../src/app/cms/collections/products.tsx | 6 +- .../common/components/ProductDetailView.tsx | 63 +++++++++++------- .../src/template/collections/products.tsx | 2 +- .../collections/components/CMSBlogPreview.tsx | 21 +++++- .../components/CMSProductPreview.tsx | 20 ++++-- .../src/app/cms/collections/products.tsx | 6 +- .../common/components/ProductDetailView.tsx | 65 +++++++++++-------- .../template_pro/src/collections/products.tsx | 2 +- 10 files changed, 153 insertions(+), 71 deletions(-) diff --git a/examples/example_next/src/app/cms/collections/components/CMSBlogPreview.tsx b/examples/example_next/src/app/cms/collections/components/CMSBlogPreview.tsx index b59541d3b..4b57c4031 100644 --- a/examples/example_next/src/app/cms/collections/components/CMSBlogPreview.tsx +++ b/examples/example_next/src/app/cms/collections/components/CMSBlogPreview.tsx @@ -2,9 +2,13 @@ import { BlogEntry, BlogEntryWithId } from "@/app/common/types"; import { convertBlogEntry } from "@/app/common/database"; import React, { useEffect } from "react"; import { BlogEntryView } from "@/app/common/components/BlogEntryView"; -import { CircularProgress } from "@firecms/ui"; +import { Button, CircularProgress, OpenInNewIcon } from "@firecms/ui"; +import Link from "next/link"; -export function CMSBlogPreview({ blogEntry, id }: { +export function CMSBlogPreview({ + blogEntry, + id + }: { blogEntry?: BlogEntry, id: string }) { @@ -18,6 +22,17 @@ export function CMSBlogPreview({ blogEntry, id }: { if (!convertedBlogEntry) { return ; } - return ; + + return
+
+ + + +
+ +
; } diff --git a/examples/example_next/src/app/cms/collections/components/CMSProductPreview.tsx b/examples/example_next/src/app/cms/collections/components/CMSProductPreview.tsx index a3883f799..ff472305a 100644 --- a/examples/example_next/src/app/cms/collections/components/CMSProductPreview.tsx +++ b/examples/example_next/src/app/cms/collections/components/CMSProductPreview.tsx @@ -1,10 +1,14 @@ import { Product, ProductWithId } from "@/app/common/types"; import { convertProduct } from "@/app/common/database"; import React, { useEffect } from "react"; -import { CircularProgress } from "@firecms/ui"; +import { Button, CircularProgress, OpenInNewIcon } from "@firecms/ui"; import { ProductDetailView } from "@/app/common/components/ProductDetailView"; +import Link from "next/link"; -export function CMSBProductPreview({ product, id }: { +export function CMSProductPreview({ + product, + id + }: { product?: Product, id: string }) { @@ -19,6 +23,14 @@ export function CMSBProductPreview({ product, id }: { return ; } - return ; + return
+
+ + + +
+ +
; } diff --git a/examples/example_next/src/app/cms/collections/products.tsx b/examples/example_next/src/app/cms/collections/products.tsx index d77862dd5..d64f27d23 100644 --- a/examples/example_next/src/app/cms/collections/products.tsx +++ b/examples/example_next/src/app/cms/collections/products.tsx @@ -1,7 +1,7 @@ import { buildCollection, EnumValues } from "@firecms/core"; import { localeCollection } from "./locales"; import { Product } from "@/app/common/types"; -import { CMSBProductPreview } from "./components/CMSProductPreview"; +import { CMSProductPreview } from "./components/CMSProductPreview"; export const categories: EnumValues = { art_and_decoration: "Art and decoration", @@ -59,9 +59,9 @@ export const productsCollection = buildCollection({ subcollections: [localeCollection], entityViews: [ { - key: "product_preview", + key: "preview", name: "Product preview", - Builder: ({ modifiedValues, entity }) => } diff --git a/examples/example_next/src/app/common/components/ProductDetailView.tsx b/examples/example_next/src/app/common/components/ProductDetailView.tsx index 1fdf79e98..1ab4c6e03 100644 --- a/examples/example_next/src/app/common/components/ProductDetailView.tsx +++ b/examples/example_next/src/app/common/components/ProductDetailView.tsx @@ -1,14 +1,24 @@ "use client"; import React from "react"; -import { AddIcon, Button, CenteredView, Label, Markdown, RadioGroup, RadioGroupItem, Select, SelectItem } from "@firecms/ui"; +import { + AddIcon, + Button, + CenteredView, + Label, + Markdown, + RadioGroup, + RadioGroupItem, + Select, + SelectItem +} from "@firecms/ui"; import { useSnackbarController } from "@firecms/core"; import { Product } from "../types"; import { getCurrencySymbol } from "@/app/common/utils"; export function ProductDetailView({ - product - }: { + product + }: { product?: Product; }) { @@ -25,16 +35,19 @@ export function ProductDetailView({ return ( -
+
{product.images?.map((image, index) => (
-
-
-

{product.name ?? "Product name"}

- -
-
- - - - - -
+
+
+

{product.name ?? "Product name"}

+
+ {getCurrencySymbol(product.currency)}{product.price} +
+
+ +
+
+ + + + +
-
{getCurrencySymbol(product.currency)}{product.price}
-
+
setQuantity(Number(value))}> 1 diff --git a/packages/cli/templates/template_pro/src/collections/products.tsx b/packages/cli/templates/template_pro/src/collections/products.tsx index 66e7f3a4a..f9328d1ff 100644 --- a/packages/cli/templates/template_pro/src/collections/products.tsx +++ b/packages/cli/templates/template_pro/src/collections/products.tsx @@ -22,7 +22,7 @@ export const productsCollection = buildCollection({ subcollections: [localeCollection], entityViews: [ { - key: "product_preview", + key: "preview", name: "Sample preview", Builder: ProductDetailPreview }