2024-08-21 22:03:49 -05:00
|
|
|
import React, {useEffect} from "react";
|
2024-04-24 12:57:46 -05:00
|
|
|
import Image from "next/image";
|
|
|
|
import { useImageProxy } from "@/hooks/useImageProxy";
|
|
|
|
import { formatUnixTimestamp } from "@/utils/time";
|
2024-09-13 18:52:33 -05:00
|
|
|
import { Tag } from "primereact/tag";
|
2024-09-10 15:44:08 -05:00
|
|
|
import GenericButton from "@/components/buttons/GenericButton";
|
2024-04-24 12:57:46 -05:00
|
|
|
|
2024-08-18 14:45:51 -05:00
|
|
|
const ContentDropdownItem = ({ content, onSelect }) => {
|
2024-04-24 12:57:46 -05:00
|
|
|
const { returnImageProxy } = useImageProxy();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="w-full border-t-2 border-gray-700 py-4">
|
|
|
|
<div className="flex flex-row gap-4 p-2">
|
|
|
|
<Image
|
|
|
|
alt="content thumbnail"
|
2024-08-21 22:03:49 -05:00
|
|
|
src={returnImageProxy(content?.image)}
|
2024-04-24 12:57:46 -05:00
|
|
|
width={50}
|
|
|
|
height={50}
|
|
|
|
className="w-[100px] h-[100px] object-cover object-center border-round"
|
|
|
|
/>
|
|
|
|
<div className="flex-1 max-w-[80vw]">
|
2024-09-13 18:52:33 -05:00
|
|
|
<div className="text-lg text-900 font-bold">{content.title || content.name}</div>
|
2024-09-15 13:27:37 -05:00
|
|
|
<div className="w-full text-sm text-600 text-wrap line-clamp-2">{content.summary || content.description && (
|
|
|
|
<div className="text-xl mt-4">
|
|
|
|
{content.summary.split('\n').map((line, index) => (
|
|
|
|
<p key={index}>{line}</p>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2024-09-13 18:52:33 -05:00
|
|
|
{content.price && <div className="text-sm pt-6 text-gray-500">Price: {content.price}</div>}
|
|
|
|
{content?.topics?.length > 0 && (
|
|
|
|
<div className="text-sm pt-6 text-gray-500">
|
|
|
|
{content.topics.map((topic) => (
|
|
|
|
<Tag key={topic} value={topic} size="small" className="mr-2 text-[#f8f8ff]" />
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)}
|
2024-08-18 14:45:51 -05:00
|
|
|
<div className="text-sm pt-6 text-gray-500">
|
2024-09-13 18:52:33 -05:00
|
|
|
{(content.published_at || content.created_at) ? `Published: ${formatUnixTimestamp(content.published_at || content.created_at)}` : "not yet published"}
|
2024-08-18 14:45:51 -05:00
|
|
|
</div>
|
2024-04-24 12:57:46 -05:00
|
|
|
</div>
|
|
|
|
<div className="flex flex-col justify-end">
|
2024-09-13 18:52:33 -05:00
|
|
|
<GenericButton outlined size="small" label="Select" onClick={() => onSelect(content)} className="py-2" />
|
2024-04-24 12:57:46 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ContentDropdownItem;
|