From c2216183d00756f857316c1151a38a40c9a75c06 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Wed, 4 Sep 2024 13:50:31 -0300 Subject: [PATCH 1/3] fix error for nextjs event component --- examples/nextjs/package-lock.json | 59 +++++++++----- examples/nextjs/package.json | 50 ++++++------ examples/nextjs/src/app/[[...slug]]/page.js | 5 +- .../components/content-types/calendarEvent.js | 81 +++++++++++-------- examples/nextjs/src/components/my-page.js | 9 ++- 5 files changed, 124 insertions(+), 80 deletions(-) diff --git a/examples/nextjs/package-lock.json b/examples/nextjs/package-lock.json index 6b2d41b01204..b73338b95df4 100644 --- a/examples/nextjs/package-lock.json +++ b/examples/nextjs/package-lock.json @@ -8,9 +8,9 @@ "name": "nextjs-dotcms-ema", "version": "0.1.0", "dependencies": { - "@dotcms/client": "0.0.1-alpha.31", - "@dotcms/experiments": "0.0.1-alpha.31", - "@dotcms/react": "0.0.1-alpha.31", + "@dotcms/client": "0.0.1-alpha.35", + "@dotcms/experiments": "0.0.1-alpha.35", + "@dotcms/react": "0.0.1-alpha.35", "next": "14.1.1", "react": "^18", "react-dom": "^18" @@ -49,29 +49,33 @@ } }, "node_modules/@dotcms/client": { - "version": "0.0.1-alpha.31", - "resolved": "https://registry.npmjs.org/@dotcms/client/-/client-0.0.1-alpha.31.tgz", - "integrity": "sha512-FD9c8j20nTNY+ATlQHuESjBg+5DkyX0idTBCLMOadZJmNftIf5niDHd1y6VMS+p0xN3RyKeBxYIeUsH7YTOU5g==" + "version": "0.0.1-alpha.35", + "resolved": "https://registry.npmjs.org/@dotcms/client/-/client-0.0.1-alpha.35.tgz", + "integrity": "sha512-1y5ShVeWGDWtKHSHdjo8+b8z6eKyyc1ELKsM/oB2BgWQ920T7Nqld7wkHrQHuc5H9zUW4wpUHw6nGoT595Be4Q==", + "license": "MIT" }, "node_modules/@dotcms/experiments": { - "version": "0.0.1-alpha.31", - "resolved": "https://registry.npmjs.org/@dotcms/experiments/-/experiments-0.0.1-alpha.31.tgz", - "integrity": "sha512-dKsbHTw7qsmBjJ67z8oZV6SpfKPeB9XbiC7rfm1hyh30BnBwpBrKOSuzSLXLSpQVONj1uteKqGHar/nvGIAIOA==", + "version": "0.0.1-alpha.35", + "resolved": "https://registry.npmjs.org/@dotcms/experiments/-/experiments-0.0.1-alpha.35.tgz", + "integrity": "sha512-7jp4tSW9Oy9JV5Fy4viElBDwQhfOucymeWBkr37DDhi9QjeH5/2HsyA7mCnUfKU0V3DhSfjWSWcZjaRZ3Oi6Zw==", + "license": "MIT", "dependencies": { "@jitsu/sdk-js": "^3.1.5" }, "peerDependencies": { - "@dotcms/client": "0.0.1-alpha.31", + "@dotcms/client": "0.0.1-alpha.35", "react": ">=18", "react-dom": ">=18" } }, "node_modules/@dotcms/react": { - "version": "0.0.1-alpha.31", - "resolved": "https://registry.npmjs.org/@dotcms/react/-/react-0.0.1-alpha.31.tgz", - "integrity": "sha512-NDH9TeasIImm+Jc5j7TNJFaeix7qie+pTXFbBGZdmSRr2gZyBuVTeujjVVtLLy4DNj/B8J38pqFlA0urlRTQsA==", + "version": "0.0.1-alpha.35", + "resolved": "https://registry.npmjs.org/@dotcms/react/-/react-0.0.1-alpha.35.tgz", + "integrity": "sha512-fEt7DN63Ujv1czMTuvXNCWzlBNGGJo/m0HHB9vtLM/6IFz5Fc6iY3AjcYc6MAgBc3AlnfL4aeVJh0+yTtArXGA==", + "license": "MIT", "peerDependencies": { - "@dotcms/client": "0.0.1-alpha.31", + "@dotcms/client": "0.0.1-alpha.35", + "@tinymce/tinymce-react": "^5.1.1", "react": ">=18", "react-dom": ">=18" } @@ -501,6 +505,21 @@ "node": ">=4" } }, + "node_modules/@tinymce/tinymce-react": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@tinymce/tinymce-react/-/tinymce-react-5.1.1.tgz", + "integrity": "sha512-DQ0wpvnf/9z8RsOEAmrWZ1DN1PKqcQHfU+DpM3llLze7FHmxVtzuN8O+FYh0oAAF4stzAXwiCIVacfqjMwRieQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "prop-types": "^15.6.2", + "tinymce": "^7.0.0 || ^6.0.0 || ^5.5.1" + }, + "peerDependencies": { + "react": "^18.0.0 || ^17.0.1 || ^16.7.0", + "react-dom": "^18.0.0 || ^17.0.1 || ^16.7.0" + } + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -3315,7 +3334,6 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -3786,7 +3804,6 @@ "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dev": true, "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -3848,8 +3865,7 @@ "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "dev": true + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/read-cache": { "version": "1.0.0", @@ -4539,6 +4555,13 @@ "node": ">=0.8" } }, + "node_modules/tinymce": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/tinymce/-/tinymce-7.3.0.tgz", + "integrity": "sha512-Ls4PgYlpk73XAxBSBqbVmSl8Mb3DuNfgF01GZ0lY6/MOEVRl3IL+VxC1Oe6165e8WqbqVsxO3Qj/PmoYNvQKGQ==", + "license": "GPL-2.0-or-later", + "peer": true + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", diff --git a/examples/nextjs/package.json b/examples/nextjs/package.json index 668481704b5a..5abd92861846 100644 --- a/examples/nextjs/package.json +++ b/examples/nextjs/package.json @@ -1,27 +1,27 @@ { - "name": "nextjs-dotcms-ema", - "version": "0.1.0", - "private": true, - "scripts": { - "dev": "next dev", - "build": "next build", - "start": "next start", - "lint": "next lint" - }, - "dependencies": { - "@dotcms/client": "0.0.1-alpha.35", - "@dotcms/react": "0.0.1-alpha.35", - "@dotcms/experiments": "0.0.1-alpha.35", - "next": "14.1.1", - "react": "^18", - "react-dom": "^18" - }, - "devDependencies": { - "@tailwindcss/typography": "^0.5.13", - "autoprefixer": "^10", - "eslint": "^8", - "eslint-config-next": "14.0.4", - "postcss": "^8", - "tailwindcss": "^3" - } + "name": "nextjs-dotcms-ema", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "next dev", + "build": "next build", + "start": "next start", + "lint": "next lint" + }, + "dependencies": { + "@dotcms/client": "0.0.1-alpha.35", + "@dotcms/react": "0.0.1-alpha.35", + "@dotcms/experiments": "0.0.1-alpha.35", + "next": "14.1.1", + "react": "^18", + "react-dom": "^18" + }, + "devDependencies": { + "@tailwindcss/typography": "^0.5.13", + "autoprefixer": "^10", + "eslint": "^8", + "eslint-config-next": "14.0.4", + "postcss": "^8", + "tailwindcss": "^3" + } } diff --git a/examples/nextjs/src/app/[[...slug]]/page.js b/examples/nextjs/src/app/[[...slug]]/page.js index b8b45b9ba742..a62110805d0f 100644 --- a/examples/nextjs/src/app/[[...slug]]/page.js +++ b/examples/nextjs/src/app/[[...slug]]/page.js @@ -42,7 +42,10 @@ export default async function Home({ searchParams, params }) { path, params: searchParams, }); - const pageAsset = await client.page.get(pageRequestParams); + const pageAsset = await client.page.get({ + ...pageRequestParams, + depth: 3, + }); const nav = await client.nav.get({ path: "/", depth: 2, diff --git a/examples/nextjs/src/components/content-types/calendarEvent.js b/examples/nextjs/src/components/content-types/calendarEvent.js index 9a96c136f5b9..20025cf65d1c 100644 --- a/examples/nextjs/src/components/content-types/calendarEvent.js +++ b/examples/nextjs/src/components/content-types/calendarEvent.js @@ -2,14 +2,21 @@ import Image from "next/image"; import Link from "next/link"; function extractLocationsAndActivities(contentlet) { - return contentlet.reduce( - (acc, { activities, ...location }) => { + const initialValue = { + locations: [], + activities: [], + }; + + return ( + contentlet?.reduce((acc, { activities, ...location }) => { + // This is a relationshipt between Contentlets + // Event -> Location -> Activities + // Depth 3 acc.activities = acc.activities.concat(activities); acc.locations.push(location); return acc; - }, - { locations: [], activities: [] } + }, initialValue) ?? initialValue ); } @@ -31,36 +38,42 @@ function CalendarEvent({ image, title, urlMap, description, location }) {

{title}

-
- - Locations: - -   - {locations.map(({ title, url }, index) => { - return ( - - - {title} - - - ); - })} -
-
- - Activities: - -   - {activities.slice(0, 3).map(({ title, urlMap }, index) => { - return ( - - - {title} - - - ); - })} -
+ {!!locations.length && !!locations[0]?.title && ( +
+ + Locations: + +   + {locations.map(({ title, url }, index) => { + return ( + + + {title} + + + ); + })} +
+ )} + {!!activities.length && !!activities[0]?.title && ( +
+ + Activities: + +   + {activities + .slice(0, 3) + .map(({ title, urlMap }, index) => { + return ( + + + {title} + + + ); + })} +
+ )}
From 938f9ae108b31fb277cfc0d89a7232efc2de04e0 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Wed, 4 Sep 2024 16:56:32 -0300 Subject: [PATCH 2/3] Update calendarEvent.js --- examples/nextjs/src/components/content-types/calendarEvent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/nextjs/src/components/content-types/calendarEvent.js b/examples/nextjs/src/components/content-types/calendarEvent.js index 20025cf65d1c..becd257b00e3 100644 --- a/examples/nextjs/src/components/content-types/calendarEvent.js +++ b/examples/nextjs/src/components/content-types/calendarEvent.js @@ -9,7 +9,7 @@ function extractLocationsAndActivities(contentlet) { return ( contentlet?.reduce((acc, { activities, ...location }) => { - // This is a relationshipt between Contentlets + // This is a relationship between Contentlets // Event -> Location -> Activities // Depth 3 acc.activities = acc.activities.concat(activities); From 011815722ca575f5920ef68c2b8ba415cce8d5d3 Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Wed, 4 Sep 2024 19:19:10 -0300 Subject: [PATCH 3/3] update package.json --- core-web/libs/sdk/angular/package.json | 4 ++-- core-web/libs/sdk/client/package.json | 2 +- core-web/libs/sdk/experiments/package.json | 4 ++-- core-web/libs/sdk/react/package.json | 4 ++-- examples/angular/package.json | 4 ++-- examples/astro/package.json | 4 ++-- examples/nextjs/package.json | 6 +++--- examples/vuejs/package.json | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core-web/libs/sdk/angular/package.json b/core-web/libs/sdk/angular/package.json index 07f487d304e6..14afa4ed05a4 100644 --- a/core-web/libs/sdk/angular/package.json +++ b/core-web/libs/sdk/angular/package.json @@ -1,11 +1,11 @@ { "name": "@dotcms/angular", - "version": "0.0.1-alpha.37", + "version": "0.0.1-alpha.36", "peerDependencies": { "@angular/common": "^17.1.0", "@angular/core": "^17.1.0", "@angular/router": "^17.1.0", - "@dotcms/client": "0.0.1-alpha.37", + "@dotcms/client": "0.0.1-alpha.36", "@tinymce/tinymce-angular": "^8.0.0", "rxjs": "^7.8.0" }, diff --git a/core-web/libs/sdk/client/package.json b/core-web/libs/sdk/client/package.json index 10f66719bcaf..c5d958f9c362 100644 --- a/core-web/libs/sdk/client/package.json +++ b/core-web/libs/sdk/client/package.json @@ -1,6 +1,6 @@ { "name": "@dotcms/client", - "version": "0.0.1-alpha.37", + "version": "0.0.1-alpha.36", "description": "Official JavaScript library for interacting with DotCMS REST APIs.", "repository": { "type": "git", diff --git a/core-web/libs/sdk/experiments/package.json b/core-web/libs/sdk/experiments/package.json index fc3b1d608ae8..9bf2d4949869 100644 --- a/core-web/libs/sdk/experiments/package.json +++ b/core-web/libs/sdk/experiments/package.json @@ -1,6 +1,6 @@ { "name": "@dotcms/experiments", - "version": "0.0.1-alpha.37", + "version": "0.0.1-alpha.36", "description": "Official JavaScript library to use Experiments with DotCMS.", "repository": { "type": "git", @@ -25,6 +25,6 @@ "peerDependencies": { "react": ">=18", "react-dom": ">=18", - "@dotcms/client": "0.0.1-alpha.37" + "@dotcms/client": "0.0.1-alpha.36" } } diff --git a/core-web/libs/sdk/react/package.json b/core-web/libs/sdk/react/package.json index 056f59f36cd1..e9993c8ae772 100644 --- a/core-web/libs/sdk/react/package.json +++ b/core-web/libs/sdk/react/package.json @@ -1,10 +1,10 @@ { "name": "@dotcms/react", - "version": "0.0.1-alpha.37", + "version": "0.0.1-alpha.36", "peerDependencies": { "react": ">=18", "react-dom": ">=18", - "@dotcms/client": "0.0.1-alpha.37", + "@dotcms/client": "0.0.1-alpha.36", "@tinymce/tinymce-react": "^5.1.1" }, "description": "Official React Components library to render a dotCMS page.", diff --git a/examples/angular/package.json b/examples/angular/package.json index bfbeb2ea8f8e..69d4c4d7f725 100644 --- a/examples/angular/package.json +++ b/examples/angular/package.json @@ -18,8 +18,8 @@ "@angular/platform-browser": "^17.1.0", "@angular/platform-browser-dynamic": "^17.1.0", "@angular/router": "^17.1.0", - "@dotcms/angular": "0.0.1-alpha.37", - "@dotcms/client": "0.0.1-alpha.37", + "@dotcms/angular": "0.0.1-alpha.36", + "@dotcms/client": "0.0.1-alpha.36", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.14.2" diff --git a/examples/astro/package.json b/examples/astro/package.json index 17d1de33a8f0..0e6162a0d1ed 100644 --- a/examples/astro/package.json +++ b/examples/astro/package.json @@ -14,8 +14,8 @@ "@astrojs/react": "^3.6.2", "@astrojs/tailwind": "^5.1.0", "@astrojs/vercel": "^7.8.0", - "@dotcms/client": "0.0.1-alpha.37", - "@dotcms/react": "0.0.1-alpha.37", + "@dotcms/client": "0.0.1-alpha.36", + "@dotcms/react": "0.0.1-alpha.36", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "astro": "^4.14.3", diff --git a/examples/nextjs/package.json b/examples/nextjs/package.json index 6c8d4734e9d7..00f7e4bc9265 100644 --- a/examples/nextjs/package.json +++ b/examples/nextjs/package.json @@ -9,9 +9,9 @@ "lint": "next lint" }, "dependencies": { - "@dotcms/client": "0.0.1-alpha.37", - "@dotcms/react": "0.0.1-alpha.37", - "@dotcms/experiments": "0.0.1-alpha.37", + "@dotcms/client": "0.0.1-alpha.36", + "@dotcms/react": "0.0.1-alpha.36", + "@dotcms/experiments": "0.0.1-alpha.36", "next": "14.1.1", "react": "^18", "react-dom": "^18" diff --git a/examples/vuejs/package.json b/examples/vuejs/package.json index 09b0a2f8015c..3f47d593c565 100644 --- a/examples/vuejs/package.json +++ b/examples/vuejs/package.json @@ -11,7 +11,7 @@ "format": "prettier --write src/" }, "dependencies": { - "@dotcms/client": "0.0.1-alpha.37", + "@dotcms/client": "0.0.1-alpha.36", "vue": "^3.4.15", "vue-router": "^4.2.5" },