2023-04-23 08:26:39 -05:00
// Copyright (C) 2022-present Daniel31x13 <daniel31x13@gmail.com>
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
2023-02-24 11:32:28 -06:00
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
import { faChevronRight } from "@fortawesome/free-solid-svg-icons" ;
2023-03-05 15:03:20 -06:00
import Link from "next/link" ;
2023-05-14 10:41:08 -05:00
import { ExtendedCollection } from "@/types/global" ;
import useLinkStore from "@/store/links" ;
2023-02-24 11:32:28 -06:00
2023-05-14 10:41:08 -05:00
export default function ( { collection } : { collection : ExtendedCollection } ) {
const { links } = useLinkStore ( ) ;
2023-02-24 11:32:28 -06:00
const formattedDate = new Date ( collection . createdAt ) . toLocaleString ( "en-US" , {
year : "numeric" ,
month : "short" ,
day : "numeric" ,
} ) ;
return (
2023-03-05 15:03:20 -06:00
< Link href = { ` /collections/ ${ collection . id } ` } >
2023-05-14 10:41:08 -05:00
< div className = "p-5 bg-gray-100 min-h-[10rem] w-72 rounded-md border-sky-100 border-solid border flex flex-col gap-2 justify-between cursor-pointer hover:bg-gray-50 duration-100" >
2023-04-25 07:39:46 -05:00
< div >
2023-05-15 13:29:51 -05:00
< div className = "flex justify-between text-sky-600 items-center" >
2023-05-14 10:41:08 -05:00
< p className = "text-lg w-max font-bold" > { collection . name } < / p >
2023-04-25 07:39:46 -05:00
< FontAwesomeIcon
icon = { faChevronRight }
className = "w-3 h-3 text-gray-500"
/ >
< / div >
2023-05-14 10:41:08 -05:00
< p className = "text-sky-400" > { collection . description } < / p >
< / div >
< div className = "text-sky-400 flex gap-1 flex-wrap" >
< p > Members : < / p >
{ collection . members . map ( ( e , i ) = > {
return (
< p
className = "text-sky-500 font-semibold"
title = { e . user . email }
key = { i }
>
{ e . user . name }
< / p >
) ;
} ) }
< / div >
< div className = "flex gap-2 items-baseline" >
< p className = "text-sky-300 font-bold text-sm" > { formattedDate } < / p >
< p className = "text-sky-500 font-bold" >
{ links . filter ( ( e ) = > e . collectionId === collection . id ) . length } Links
2023-04-25 07:39:46 -05:00
< / p >
2023-03-05 15:03:20 -06:00
< / div >
2023-02-24 11:32:28 -06:00
< / div >
2023-03-05 15:03:20 -06:00
< / Link >
2023-02-24 11:32:28 -06:00
) ;
}