From 76bfcfc51d2dd06dfd05e0e41dcd7ea429734a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?La=C3=A9rcio=20Fernandes=20Correia=20de=20Melo=20Neto?= Date: Thu, 15 Feb 2024 11:11:24 -0300 Subject: [PATCH] coloca data nos cards de terapias e oficinas --- src/components/carrossel-oficinas/index.js | 44 ++++++++++++---------- src/components/carrossel-terapias/index.js | 7 +++- src/components/events-carrosel/index.js | 1 + 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/components/carrossel-oficinas/index.js b/src/components/carrossel-oficinas/index.js index 892f500..14b55cf 100644 --- a/src/components/carrossel-oficinas/index.js +++ b/src/components/carrossel-oficinas/index.js @@ -17,18 +17,25 @@ const WorkshopsCarrossel = () => { useEffect(() => { cms.get('api/workshops/?populate=foto_divulgacao').then((response) => { const { data } = response.data - const workshops = data - .filter(workshop => workshop !== null && workshop !== undefined) - .map(workshop => ({ - id: workshop.id, - name: workshop.attributes.nome, - imageUrl: workshop.attributes.foto_divulgacao.data[0].attributes.url - })) + if (data) { + const workshops = data.map((workshop) => { + return { + id: workshop.id, + name: workshop.attributes.nome, + date: new Date(workshop.attributes.data_inicio).toLocaleDateString( + 'pt-BR', + { timeZone: 'UTC' }, + ), + imageUrl: + workshop.attributes.foto_divulgacao.data[0].attributes.url, + } + }) - const workshopsSortedByName = workshops.sort((a, b) => - a.nome < b.nome ? -1 : 1 - ) - setAttributes(workshopsSortedByName) + const workshopsSortedByName = workshops.sort((a, b) => + a.nome < b.nome ? -1 : 1, + ) + setAttributes(workshopsSortedByName) + } }) }, []) @@ -48,11 +55,11 @@ const WorkshopsCarrossel = () => { {
- +
-

{workshops.data}

+

{workshops.date}

{workshops.name}

diff --git a/src/components/carrossel-terapias/index.js b/src/components/carrossel-terapias/index.js index a9728f4..a3297b7 100644 --- a/src/components/carrossel-terapias/index.js +++ b/src/components/carrossel-terapias/index.js @@ -18,6 +18,10 @@ const TherapiesCarrossel = () => { if (data) { return { id: data.id, + date: new Date(data.attributes.data_inicio).toLocaleDateString( + 'pt-BR', + { timeZone: 'UTC' }, + ), name: data.attributes.nome, image_url: data.attributes.foto_divulgacao.data[0].attributes.url } @@ -75,7 +79,8 @@ const TherapiesCarrossel = () => { />
-

{therapies.name}

+

{therapies.date}

+

{therapies.name}

diff --git a/src/components/events-carrosel/index.js b/src/components/events-carrosel/index.js index b84d2aa..be82631 100644 --- a/src/components/events-carrosel/index.js +++ b/src/components/events-carrosel/index.js @@ -66,6 +66,7 @@ const Events = () => {

{events.date}

+ {console.log(events.date)}

{events.name}