Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coloca data nos cards de terapias e oficinas #158

Merged
merged 5 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions src/components/carrossel-oficinas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}, [])

Expand Down Expand Up @@ -60,7 +67,7 @@ const WorkshopsCarrossel = () => {
breakpoints={{
320: { slidesPerView: 1, spaceBetween: 1 },
660: { slidesPerView: 2 },
1280: { slidesPerView: 3, spaceBetween: 1 },
1280: { slidesPerView: 3, spaceBetween: 1 }
}}
modules={[Navigation, Pagination]}
className="mySwiper"
Expand All @@ -76,7 +83,14 @@ const WorkshopsCarrossel = () => {
<img className="img" src={workshops.imageUrl} />
</div>
<div>
<p className="date">{workshops.data}</p>
{
workshops.date === "01/01/1970" ? (
<p></p>
) : (
<p className="date">
{workshops.date}
</p>
)}
<h3 className="title">{workshops.name}</h3>
</div>
<VerMais>
Expand Down
20 changes: 16 additions & 4 deletions src/components/carrossel-terapias/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ 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,
image_url: data.attributes.foto_divulgacao.data[0].attributes.url
}
}
return data.attributes
})
const therapiesSortedByName = therapies.sort((a, b) =>
a.nome < b.nome ? -1 : 1,
a.nome < b.nome ? -1 : 1
)
setAttributes(therapiesSortedByName)
})
Expand Down Expand Up @@ -57,7 +61,7 @@ const TherapiesCarrossel = () => {
breakpoints={{
320: { slidesPerView: 1, spaceBetween: 1 },
660: { slidesPerView: 2 },
1280: { slidesPerView: 3, spaceBetween: 1 },
1280: { slidesPerView: 3, spaceBetween: 1 }
}}
modules={[Navigation, Pagination]}
className="mySwiper"
Expand All @@ -73,7 +77,15 @@ const TherapiesCarrossel = () => {
<img className="img" src={therapies.image_url} />
</div>
<div>
<h1 className="title">{therapies.name}</h1>
{
therapies.date === "01/01/1970" ? (
<p></p>
) : (
<p className="date">
{therapies.date}
</p>
)}
<h3 className="title">{therapies.name}</h3>
</div>
<VerMais>
<div className="styled-button">
Expand Down
16 changes: 10 additions & 6 deletions src/components/events-carrosel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Events = () => {
type: data.attributes.tipo,
location: data.attributes.local,
price: data.attributes.preco,
description: data.attributes.descricao,
description: data.attributes.descricao
}
})
const eventsOrdered = events
Expand Down Expand Up @@ -64,7 +64,7 @@ const Events = () => {
breakpoints={{
320: { slidesPerView: 1, spaceBetween: 1 },
660: { slidesPerView: 2 },
1280: { slidesPerView: 3, spaceBetween: 1 },
1280: { slidesPerView: 3, spaceBetween: 1 }
}}
modules={[Navigation, Pagination]}
className="mySwiper"
Expand All @@ -80,11 +80,15 @@ const Events = () => {
<img className="img" src={events.image_url} />
</div>
<div>
<p className="date">
{events.date.toLocaleDateString('pt-BR', {
Timezone: 'UTF',
})}
{
events.date === "01/01/1970" ? (
<p></p>

) : (
<p className="date">
{events.date}
</p>
)}
<h3 className="title">{events.name}</h3>
</div>
<EventsComponent>
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/format-data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const formatDate = (date) => {
day: '2-digit',
month: 'short',
year: 'numeric',
weekday: 'long',
weekday: 'long'
}).format(date)
return dateFormated[0].toUpperCase() + dateFormated.slice(1)
}
Expand Down
Loading