umwd-components 0.1.861 → 0.1.862
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/umwd-components/src/components/e-commerce/products/ProductCard.js +1 -1
- package/dist/cjs/umwd-components/src/data/loaders/page-elements/getSinglePage.js +1 -1
- package/dist/esm/umwd-components/src/components/e-commerce/products/ProductCard.js +7 -1
- package/dist/esm/umwd-components/src/data/loaders/page-elements/getSinglePage.js +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),i=require("@mui/material/Card"),t=require("@mui/material/CardActions"),a=require("@mui/material/CardContent"),l=require("@mui/material/CardMedia"),u=require("@mui/material/Button"),s=require("@mui/material/Typography"),n=require("@mui/material/Stack"),c=require("./Price.js"),o=require("../../../lib/utils.js"),d=require("../../StyledLink.js"),m=require("../cart/AddToCartButton.client.js"),p=require("../../common/markdown/MarkdownDisplay.js");exports.default=function({product:x,sx:v=[]}){const{documentId:_,uuid:f,product_number:h,title:j,description:q,slug:y,price:g,image:b,stock:k}=x,C=o.getStrapiMedia(b?.url),w=o.getStrapiMedia(b?.formats?.thumbnail?.url);return e.jsxs(i,{sx:[{width:"100%",height:"100%"},{display:"flex",flexDirection:"column"},...Array.isArray(v)?v:[v]],children:[e.jsx(l,{component:"img",height:"140",src:`${C}`,alt:b?.alternativeText||"fallback alt text"}),e.jsxs(a,{children:[e.jsxs(n,{direction:"row",justifyContent:"space-between",sx:{pb:2},children:[e.jsx(d.StyledLink,{href:`/shop/${y}`,target:"_self",children:j}),g&&void 0!==g.price&&void 0!==g.vat&&void 0!==g.vat_rate&&void 0!==g.price_incl_vat?e.jsx(c.default,{price:g.price,vat:g.vat,vat_rate:g.vat_rate,price_incl_vat:g.price_incl_vat}):e.jsx(s,{color:"error",children:"Price information is unavailable for this product."})]}),q&&e.jsx(p.default,{children:q.substring(0,150)+"..."})]}),e.jsx(r,{sx:{flexGrow:1}}),e.jsxs(t,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"flex-end"},children:[e.jsx(u,{size:"small",href:`/shop/${y}`,children:"Learn More"}),e.jsx(m.default,{product:{documentId:_,uuid:f,slug:y,thumb:w,title:j,vat_rate:g.vat_rate,price_excl_vat:g.price,price_incl_vat:g.price_incl_vat,quantity:1,product_number:h,stock:k}})]})]})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("../../../../node_modules/qs/lib/index.js"),t=require("../../../lib/utils.js"),
|
|
7
|
+
"use strict";var e=require("../../../../node_modules/qs/lib/index.js"),t=require("../../../lib/utils.js"),o=require("next/cache");const a=t.getStrapiURL();exports.getSinglePage=async function(p){o.unstable_noStore(),p||(p="home");const l=new URL(`/api/pages/slug/${p}`,a);l.search=e.default.stringify({populate:{blocks:{on:{"page-elements.features-section":{populate:{feature:{populate:"*"}}},"page-elements.hero-section":{populate:{bgImage:"*",link:"*",logoImage:"*"}},"page-elements.review-section":{populate:{review:{populate:"*"}}},"page-elements.text-image-section":{populate:{image:"*"}},"page-elements.icon-section":{populate:{icon:{populate:"*"}}},"page-elements.contact-section":{populate:"*"},"page-elements.fleet-section":{populate:{airplane:{populate:{floorplan:"*"}}}},"page-elements.columns-section":{populate:{column:"*"}},"page-elements.personalia-section":{populate:{partner:"*"}},"page-elements.picture-bar-section":{populate:{pictures:"*"}},"page-elements.logo-bar-section":{populate:{companies:{populate:"*"}}},"page-elements.category-block":{populate:{category:{populate:{products:{populate:{image:!0,price:!0}}}}}},"page-elements.product-block":{populate:{products:{populate:{image:!0,price:!0}}}}}}}});const n={method:"GET",headers:{"Content-Type":"application/json"}};try{const e=await fetch(l,n),o=await e.json();return console.log("Fetched page data:",o),console.dir(o.blocks,{depth:null}),t.flattenAttributes(o)}catch(e){return console.error("Error fetching data:",e),null}};
|
|
@@ -12,6 +12,7 @@ import CardActions from '@mui/material/CardActions';
|
|
|
12
12
|
import CardContent from '@mui/material/CardContent';
|
|
13
13
|
import CardMedia from '@mui/material/CardMedia';
|
|
14
14
|
import Button from '@mui/material/Button';
|
|
15
|
+
import Typography from '@mui/material/Typography';
|
|
15
16
|
import Stack from '@mui/material/Stack';
|
|
16
17
|
import Price from './Price.js';
|
|
17
18
|
import { getStrapiMedia } from '../../../lib/utils.js';
|
|
@@ -21,6 +22,7 @@ import MarkdownDisplay from '../../common/markdown/MarkdownDisplay.js';
|
|
|
21
22
|
|
|
22
23
|
function ProductCard({ product, sx = [] }) {
|
|
23
24
|
const { documentId, uuid, product_number, title, description, slug, price, image, stock, } = product;
|
|
25
|
+
// check if price exists and has required fields
|
|
24
26
|
const imgURL = getStrapiMedia(image?.url);
|
|
25
27
|
const thumbURL = getStrapiMedia(image?.formats?.thumbnail?.url);
|
|
26
28
|
return (jsxs(Card, { sx: [
|
|
@@ -28,7 +30,11 @@ function ProductCard({ product, sx = [] }) {
|
|
|
28
30
|
{ width: "100%", height: "100%" },
|
|
29
31
|
{ display: "flex", flexDirection: "column" },
|
|
30
32
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
31
|
-
], children: [jsx(CardMedia, { component: "img", height: "140", src: `${imgURL}`, alt: image?.alternativeText || "fallback alt text" }), jsxs(CardContent, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", sx: { pb: 2 }, children: [jsx(StyledLink, { href: `/shop/${slug}`, target: "_self", children: title }),
|
|
33
|
+
], children: [jsx(CardMedia, { component: "img", height: "140", src: `${imgURL}`, alt: image?.alternativeText || "fallback alt text" }), jsxs(CardContent, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", sx: { pb: 2 }, children: [jsx(StyledLink, { href: `/shop/${slug}`, target: "_self", children: title }), !price ||
|
|
34
|
+
price.price === undefined ||
|
|
35
|
+
price.vat === undefined ||
|
|
36
|
+
price.vat_rate === undefined ||
|
|
37
|
+
price.price_incl_vat === undefined ? (jsx(Typography, { color: "error", children: "Price information is unavailable for this product." })) : (jsx(Price, { price: price.price, vat: price.vat, vat_rate: price.vat_rate, price_incl_vat: price.price_incl_vat }))] }), description && (jsx(MarkdownDisplay, { children: description.substring(0, 150) + "..." }))] }), jsx(Box, { sx: { flexGrow: 1 } }), jsxs(CardActions, { sx: {
|
|
32
38
|
display: "flex",
|
|
33
39
|
justifyContent: "flex-end",
|
|
34
40
|
alignItems: "flex-end",
|
|
@@ -120,6 +120,7 @@ async function getSinglePage(slug) {
|
|
|
120
120
|
const response = await fetch(url, headers);
|
|
121
121
|
const data = await response.json();
|
|
122
122
|
console.log("Fetched page data:", data);
|
|
123
|
+
console.dir(data.blocks, { depth: null });
|
|
123
124
|
return flattenAttributes(data);
|
|
124
125
|
}
|
|
125
126
|
catch (error) {
|