diff --git a/src/components/content/carousels/templates/CourseTemplate.js b/src/components/content/carousels/templates/CourseTemplate.js index a6b0f30..b50fb8b 100644 --- a/src/components/content/carousels/templates/CourseTemplate.js +++ b/src/components/content/carousels/templates/CourseTemplate.js @@ -1,78 +1,74 @@ -import React, {use, useEffect, useState} from "react"; +import React, { useEffect, useState } from "react"; import Image from "next/image"; import { useRouter } from "next/router"; -import useResponsiveImageDimensions from "@/hooks/useResponsiveImageDimensions"; import { formatTimestampToHowLongAgo } from "@/utils/time"; import { useImageProxy } from "@/hooks/useImageProxy"; import { useNostr } from "@/hooks/useNostr"; -import {getSatAmountFromInvoice} from "@/utils/lightning"; +import { getSatAmountFromInvoice } from "@/utils/lightning"; const CourseTemplate = (course) => { - const [zaps, setZaps] = useState([]); - const [zapAmount, setZapAmount] = useState(null); - const router = useRouter(); - const { returnImageProxy } = useImageProxy(); - const { width, height } = useResponsiveImageDimensions(); - const { fetchZapsForEvent } = useNostr(); + const [zaps, setZaps] = useState([]); + const [zapAmount, setZapAmount] = useState(null); + const router = useRouter(); + const { returnImageProxy } = useImageProxy(); + const { fetchZapsForEvent } = useNostr(); - useEffect(() => { - const fetchZaps = async () => { - try { - const zaps = await fetchZapsForEvent(course.id); - setZaps(zaps); - } catch (error) { - console.error('Error fetching zaps:', error); - } - }; - fetchZaps(); - }, [fetchZapsForEvent, course]); + useEffect(() => { + const fetchZaps = async () => { + try { + const zaps = await fetchZapsForEvent(course.id); + setZaps(zaps); + } catch (error) { + console.error("Error fetching zaps:", error); + } + }; + fetchZaps(); + }, [fetchZapsForEvent, course]); - useEffect(() => { - if (zaps.length > 0) { - zaps.map((zap) => { - const bolt11Tag = zap.tags.find(tag => tag[0] === 'bolt11'); - const invoice = bolt11Tag ? bolt11Tag[1] : null; - - if (invoice) { - const amount = getSatAmountFromInvoice(invoice); - setZapAmount(zapAmount + amount); - } - }) + useEffect(() => { + if (zaps.length > 0) { + zaps.map((zap) => { + const bolt11Tag = zap.tags.find((tag) => tag[0] === "bolt11"); + const invoice = bolt11Tag ? bolt11Tag[1] : null; + if (invoice) { + const amount = getSatAmountFromInvoice(invoice); + setZapAmount(zapAmount + amount); } - }, [zaps]); + }); + } + }, [zaps]); - return ( -
router.push(`/details/${course.id}`)} className="flex flex-col items-center mx-auto px-4 cursor-pointer mt-8 rounded-md shadow-lg"> -
- resource thumbnail -
-

{course.title}

-

- {course.summary} -

-
-

Published: {formatTimestampToHowLongAgo(course.published_at)}

-

{zapAmount}

-
-
-
+ return ( +
router.push(`/details/${course.id}`)} + className="flex flex-col items-center mx-auto px-4 cursor-pointer mt-8 rounded-md" + > +
+ course thumbnail +
+
+

+ {course.title} +

+

{course.summary}

+
+

+ {formatTimestampToHowLongAgo(course.published_at)} +

+

+ {zapAmount} +

- ); +
+
+ ); }; export default CourseTemplate; \ No newline at end of file diff --git a/src/components/content/carousels/templates/ResourceTemplate.js b/src/components/content/carousels/templates/ResourceTemplate.js index 93d765e..c564e40 100644 --- a/src/components/content/carousels/templates/ResourceTemplate.js +++ b/src/components/content/carousels/templates/ResourceTemplate.js @@ -1,82 +1,74 @@ import React, { useEffect, useState } from "react"; import Image from "next/image"; import { useRouter } from "next/router"; -import useResponsiveImageDimensions from "@/hooks/useResponsiveImageDimensions"; import { formatTimestampToHowLongAgo } from "@/utils/time"; import { useImageProxy } from "@/hooks/useImageProxy"; import { useNostr } from "@/hooks/useNostr"; import { getSatAmountFromInvoice } from "@/utils/lightning"; const ResourceTemplate = (resource) => { - const [zaps, setZaps] = useState([]); - const [zapAmount, setZapAmount] = useState(null); - const router = useRouter(); - const { returnImageProxy } = useImageProxy(); - const { width, height } = useResponsiveImageDimensions(); + const [zaps, setZaps] = useState([]); + const [zapAmount, setZapAmount] = useState(null); + const router = useRouter(); + const { returnImageProxy } = useImageProxy(); + const { fetchZapsForEvent } = useNostr(); - const { fetchZapsForEvent } = useNostr(); + useEffect(() => { + const fetchZaps = async () => { + try { + const zaps = await fetchZapsForEvent(resource.id); + setZaps(zaps); + } catch (error) { + console.error("Error fetching zaps:", error); + } + }; + fetchZaps(); + }, [fetchZapsForEvent, resource]); - useEffect(() => { - const fetchZaps = async () => { - try { - const zaps = await fetchZapsForEvent(resource.id); - setZaps(zaps); - } catch (error) { - console.error('Error fetching zaps:', error); - } - }; - fetchZaps(); - }, [fetchZapsForEvent, resource]); - - useEffect(() => { - if (zaps.length > 0) { - zaps.map((zap) => { - const bolt11Tag = zap.tags.find(tag => tag[0] === 'bolt11'); - const invoice = bolt11Tag ? bolt11Tag[1] : null; - - if (invoice) { - const amount = getSatAmountFromInvoice(invoice); - setZapAmount(zapAmount + amount); - } - }) + useEffect(() => { + if (zaps.length > 0) { + zaps.map((zap) => { + const bolt11Tag = zap.tags.find((tag) => tag[0] === "bolt11"); + const invoice = bolt11Tag ? bolt11Tag[1] : null; + if (invoice) { + const amount = getSatAmountFromInvoice(invoice); + setZapAmount(zapAmount + amount); } - }, [zaps]); + }); + } + }, [zaps]); - return ( -
router.push(`/details/${resource.id}`)} className="flex flex-col items-center mx-auto px-4 cursor-pointer mt-8 rounded-md"> -
- resource thumbnail -
-

{resource.title}

-
-

- {resource.summary} -

-
-
-

Published: {formatTimestampToHowLongAgo(resource.published_at)}

-

{zapAmount}

-
-
-
+ return ( +
router.push(`/details/${resource.id}`)} + className="flex flex-col items-center mx-auto px-4 cursor-pointer mt-8 rounded-md" + > +
+ resource thumbnail +
+
+

+ {resource.title} +

+

{resource.summary}

+
+

+ {formatTimestampToHowLongAgo(resource.published_at)} +

+

+ {zapAmount} +

- ); +
+
+ ); }; export default ResourceTemplate; \ No newline at end of file diff --git a/src/components/content/carousels/templates/WorkshopTemplate.js b/src/components/content/carousels/templates/WorkshopTemplate.js index 89704ce..8b20faf 100644 --- a/src/components/content/carousels/templates/WorkshopTemplate.js +++ b/src/components/content/carousels/templates/WorkshopTemplate.js @@ -1,79 +1,74 @@ -import React, {useEffect, useState} from "react"; +import React, { useEffect, useState } from "react"; import Image from "next/image"; import { useRouter } from "next/router"; -import useResponsiveImageDimensions from "@/hooks/useResponsiveImageDimensions"; import { formatTimestampToHowLongAgo } from "@/utils/time"; import { useImageProxy } from "@/hooks/useImageProxy"; import { useNostr } from "@/hooks/useNostr"; -import {getSatAmountFromInvoice} from "@/utils/lightning"; +import { getSatAmountFromInvoice } from "@/utils/lightning"; const WorkshopTemplate = (workshop) => { - const [zaps, setZaps] = useState([]); - const [zapAmount, setZapAmount] = useState(null); - const router = useRouter(); - const { returnImageProxy } = useImageProxy(); - const { width, height } = useResponsiveImageDimensions(); + const [zaps, setZaps] = useState([]); + const [zapAmount, setZapAmount] = useState(null); + const router = useRouter(); + const { returnImageProxy } = useImageProxy(); + const { fetchZapsForEvent } = useNostr(); - const { fetchZapsForEvent } = useNostr(); + useEffect(() => { + const fetchZaps = async () => { + try { + const zaps = await fetchZapsForEvent(workshop.id); + setZaps(zaps); + } catch (error) { + console.error("Error fetching zaps:", error); + } + }; + fetchZaps(); + }, [fetchZapsForEvent, workshop]); - useEffect(() => { - const fetchZaps = async () => { - try { - const zaps = await fetchZapsForEvent(workshop.id); - setZaps(zaps); - } catch (error) { - console.error('Error fetching zaps:', error); - } - }; - fetchZaps(); - }, [fetchZapsForEvent, workshop]); - - useEffect(() => { - if (zaps.length > 0) { - zaps.map((zap) => { - const bolt11Tag = zap.tags.find(tag => tag[0] === 'bolt11'); - const invoice = bolt11Tag ? bolt11Tag[1] : null; - - if (invoice) { - const amount = getSatAmountFromInvoice(invoice); - setZapAmount(zapAmount + amount); - } - }) + useEffect(() => { + if (zaps.length > 0) { + zaps.map((zap) => { + const bolt11Tag = zap.tags.find((tag) => tag[0] === "bolt11"); + const invoice = bolt11Tag ? bolt11Tag[1] : null; + if (invoice) { + const amount = getSatAmountFromInvoice(invoice); + setZapAmount(zapAmount + amount); } - }, [zaps]); + }); + } + }, [zaps]); - return ( -
router.push(`/details/${workshop.id}`)} className="flex flex-col items-center mx-auto px-4 cursor-pointer mt-8 rounded-md shadow-lg"> -
- workshop thumbnail -
-

{workshop.title}

-

- {workshop.summary} -

-
-

Published: {formatTimestampToHowLongAgo(workshop.published_at)}

-

{zapAmount}

-
-
-
+ return ( +
router.push(`/details/${workshop.id}`)} + className="flex flex-col items-center mx-auto px-4 cursor-pointer mt-8 rounded-md" + > +
+ workshop thumbnail +
+
+

+ {workshop.title} +

+

{workshop.summary}

+
+

+ {formatTimestampToHowLongAgo(workshop.published_at)} +

+

+ {zapAmount} +

- ); +
+
+ ); }; export default WorkshopTemplate; \ No newline at end of file