2023-12-23 20:33:25 -06:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
import { Carousel } from 'primereact/carousel';
|
2024-02-27 18:29:57 -06:00
|
|
|
import { useRouter } from 'next/router';
|
2024-03-19 17:47:16 -05:00
|
|
|
import { useNostr } from '@/hooks/useNostr';
|
2024-02-11 21:32:46 -06:00
|
|
|
import { useImageProxy } from '@/hooks/useImageProxy';
|
2024-02-27 18:29:57 -06:00
|
|
|
import { parseEvent } from '@/utils/nostr';
|
2024-03-26 18:14:32 -05:00
|
|
|
import WorkshopTemplate from '@/components/content/carousels/templates/WorkshopTemplate';
|
2023-12-23 20:33:25 -06:00
|
|
|
|
2024-03-17 19:43:19 -05:00
|
|
|
const responsiveOptions = [
|
|
|
|
{
|
2024-03-19 12:32:05 -05:00
|
|
|
breakpoint: '3000px',
|
2024-03-17 19:43:19 -05:00
|
|
|
numVisible: 3,
|
|
|
|
numScroll: 1
|
|
|
|
},
|
|
|
|
{
|
2024-03-19 12:32:05 -05:00
|
|
|
breakpoint: '1462px',
|
2024-03-17 19:43:19 -05:00
|
|
|
numVisible: 2,
|
|
|
|
numScroll: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
breakpoint: '575px',
|
|
|
|
numVisible: 1,
|
|
|
|
numScroll: 1
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2024-03-13 17:45:55 -05:00
|
|
|
export default function WorkshopsCarousel() {
|
2024-03-17 16:16:47 -05:00
|
|
|
const [processedWorkshops, setProcessedWorkshops] = useState([]);
|
2024-03-19 17:47:16 -05:00
|
|
|
const [workshops, setWorkshops] = useState([]);
|
|
|
|
const router = useRouter();
|
|
|
|
const { fetchWorkshops, events } = useNostr();
|
2024-02-11 21:32:46 -06:00
|
|
|
const { returnImageProxy } = useImageProxy();
|
2023-12-23 20:33:25 -06:00
|
|
|
|
2024-03-19 17:47:16 -05:00
|
|
|
useEffect(() => {
|
|
|
|
if (events && events.workshops && events.workshops.length > 0) {
|
|
|
|
setWorkshops(events.workshops);
|
|
|
|
} else {
|
|
|
|
fetchWorkshops();
|
|
|
|
}
|
|
|
|
}, [events]);
|
2024-02-27 18:29:57 -06:00
|
|
|
|
2024-02-11 21:32:46 -06:00
|
|
|
useEffect(() => {
|
2024-03-17 16:16:47 -05:00
|
|
|
const processWorkshops = workshops.map(workshop => {
|
|
|
|
const { id, content, title, summary, image, published_at } = parseEvent(workshop);
|
2024-02-27 18:29:57 -06:00
|
|
|
return { id, content, title, summary, image, published_at };
|
2024-02-11 21:32:46 -06:00
|
|
|
});
|
2024-03-17 16:16:47 -05:00
|
|
|
setProcessedWorkshops(processWorkshops);
|
|
|
|
}, [workshops]);
|
2024-02-11 16:26:33 -06:00
|
|
|
|
2023-12-23 20:33:25 -06:00
|
|
|
return (
|
|
|
|
<>
|
2024-03-19 12:32:05 -05:00
|
|
|
<h2 className="ml-[6%] mt-4">workshops</h2>
|
2024-03-26 18:14:32 -05:00
|
|
|
<Carousel value={[...processedWorkshops, ...processedWorkshops]} numVisible={2} itemTemplate={WorkshopTemplate} responsiveOptions={responsiveOptions} />
|
2023-12-23 20:33:25 -06:00
|
|
|
</>
|
2024-02-11 21:32:46 -06:00
|
|
|
);
|
2023-12-23 20:33:25 -06:00
|
|
|
}
|