2023-03-22 18:11:54 -05:00
|
|
|
import useCollectionStore from "@/store/collections";
|
2023-04-25 07:39:46 -05:00
|
|
|
import {
|
|
|
|
faEllipsis,
|
2023-07-13 17:19:49 -05:00
|
|
|
faFolder,
|
2023-04-25 07:39:46 -05:00
|
|
|
faPlus,
|
|
|
|
} from "@fortawesome/free-solid-svg-icons";
|
2023-03-28 02:31:50 -05:00
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
2023-02-24 11:32:28 -06:00
|
|
|
import CollectionCard from "@/components/CollectionCard";
|
2023-06-13 23:40:23 -05:00
|
|
|
import { useState } from "react";
|
2023-05-14 10:41:08 -05:00
|
|
|
import MainLayout from "@/layouts/MainLayout";
|
2023-05-26 23:29:45 -05:00
|
|
|
import { useSession } from "next-auth/react";
|
2023-06-13 23:40:23 -05:00
|
|
|
import SortDropdown from "@/components/SortDropdown";
|
|
|
|
import { Sort } from "@/types/global";
|
|
|
|
import useSort from "@/hooks/useSort";
|
2023-12-01 16:44:34 -06:00
|
|
|
import NewCollectionModal from "@/components/ModalContent/NewCollectionModal";
|
2023-02-24 11:32:28 -06:00
|
|
|
|
2023-06-09 17:31:14 -05:00
|
|
|
export default function Collections() {
|
2023-03-22 18:11:54 -05:00
|
|
|
const { collections } = useCollectionStore();
|
2023-04-23 08:26:39 -05:00
|
|
|
const [expandDropdown, setExpandDropdown] = useState(false);
|
2023-06-14 17:34:54 -05:00
|
|
|
const [sortBy, setSortBy] = useState<Sort>(Sort.DateNewestFirst);
|
2023-05-15 15:45:06 -05:00
|
|
|
const [sortedCollections, setSortedCollections] = useState(collections);
|
2023-04-23 08:26:39 -05:00
|
|
|
|
2023-10-24 16:03:33 -05:00
|
|
|
const { data } = useSession();
|
2023-05-26 23:29:45 -05:00
|
|
|
|
2023-06-13 23:40:23 -05:00
|
|
|
useSort({ sortBy, setData: setSortedCollections, data: collections });
|
2023-05-15 15:45:06 -05:00
|
|
|
|
2023-12-01 11:01:56 -06:00
|
|
|
const [newCollectionModal, setNewCollectionModal] = useState(false);
|
2023-11-28 23:46:31 -06:00
|
|
|
|
2023-02-24 11:32:28 -06:00
|
|
|
return (
|
2023-05-14 10:41:08 -05:00
|
|
|
<MainLayout>
|
2023-04-30 15:54:40 -05:00
|
|
|
<div className="p-5">
|
2023-10-24 16:03:33 -05:00
|
|
|
<div className="flex gap-3 justify-between mb-5">
|
|
|
|
<div className="flex gap-3">
|
|
|
|
<div className="flex items-center gap-3">
|
2023-05-31 21:43:42 -05:00
|
|
|
<FontAwesomeIcon
|
2023-07-13 17:19:49 -05:00
|
|
|
icon={faFolder}
|
2023-11-24 08:39:38 -06:00
|
|
|
className="sm:w-10 sm:h-10 w-6 h-6 text-primary drop-shadow"
|
2023-05-31 21:43:42 -05:00
|
|
|
/>
|
2023-10-24 16:03:33 -05:00
|
|
|
<div>
|
2023-11-24 07:39:55 -06:00
|
|
|
<p className="text-3xl capitalize font-thin">
|
2023-10-24 16:03:33 -05:00
|
|
|
Your Collections
|
|
|
|
</p>
|
|
|
|
|
2023-11-24 07:39:55 -06:00
|
|
|
<p>Collections you own</p>
|
2023-10-24 16:03:33 -05:00
|
|
|
</div>
|
2023-05-14 10:41:08 -05:00
|
|
|
</div>
|
2023-03-28 02:31:50 -05:00
|
|
|
</div>
|
2023-05-14 10:41:08 -05:00
|
|
|
|
2023-10-24 16:03:33 -05:00
|
|
|
<div className="relative mt-2">
|
2023-11-29 14:17:51 -06:00
|
|
|
<SortDropdown sortBy={sortBy} setSort={setSortBy} />
|
2023-04-30 15:54:40 -05:00
|
|
|
</div>
|
2023-03-28 02:31:50 -05:00
|
|
|
</div>
|
2023-05-14 10:41:08 -05:00
|
|
|
|
2023-07-18 11:28:58 -05:00
|
|
|
<div className="grid xl:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-5">
|
2023-10-24 16:03:33 -05:00
|
|
|
{sortedCollections
|
2023-10-24 16:11:25 -05:00
|
|
|
.filter((e) => e.ownerId === data?.user.id)
|
2023-10-24 16:03:33 -05:00
|
|
|
.map((e, i) => {
|
|
|
|
return <CollectionCard key={i} collection={e} />;
|
|
|
|
})}
|
2023-04-23 08:26:39 -05:00
|
|
|
|
2023-04-30 15:54:40 -05:00
|
|
|
<div
|
2023-11-29 08:41:24 -06:00
|
|
|
className="card card-compact shadow-md hover:shadow-none duration-200 border border-neutral-content p-5 bg-base-200 self-stretch min-h-[12rem] rounded-2xl cursor-pointer flex flex-col gap-4 justify-center items-center group btn"
|
2023-12-01 11:01:56 -06:00
|
|
|
onClick={() => setNewCollectionModal(true)}
|
2023-04-30 15:54:40 -05:00
|
|
|
>
|
2023-11-24 07:39:55 -06:00
|
|
|
<p className="group-hover:opacity-0 duration-100">New Collection</p>
|
2023-05-25 09:17:20 -05:00
|
|
|
<FontAwesomeIcon
|
|
|
|
icon={faPlus}
|
2023-11-24 08:39:38 -06:00
|
|
|
className="w-8 h-8 text-primary group-hover:w-12 group-hover:h-12 group-hover:-mt-10 duration-100"
|
2023-05-25 09:17:20 -05:00
|
|
|
/>
|
2023-04-30 15:54:40 -05:00
|
|
|
</div>
|
2023-04-25 07:39:46 -05:00
|
|
|
</div>
|
2023-10-24 16:03:33 -05:00
|
|
|
|
|
|
|
{sortedCollections.filter((e) => e.ownerId !== data?.user.id)[0] ? (
|
|
|
|
<>
|
|
|
|
<div className="flex items-center gap-3 my-5">
|
|
|
|
<FontAwesomeIcon
|
|
|
|
icon={faFolder}
|
2023-11-24 08:39:38 -06:00
|
|
|
className="sm:w-10 sm:h-10 w-6 h-6 text-primary drop-shadow"
|
2023-10-24 16:03:33 -05:00
|
|
|
/>
|
|
|
|
<div>
|
2023-11-24 07:39:55 -06:00
|
|
|
<p className="text-3xl capitalize font-thin">
|
2023-10-24 16:03:33 -05:00
|
|
|
Other Collections
|
|
|
|
</p>
|
|
|
|
|
2023-11-24 07:39:55 -06:00
|
|
|
<p>Shared collections you're a member of</p>
|
2023-10-24 16:03:33 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="grid xl:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-5">
|
|
|
|
{sortedCollections
|
|
|
|
.filter((e) => e.ownerId !== data?.user.id)
|
|
|
|
.map((e, i) => {
|
|
|
|
return <CollectionCard key={i} collection={e} />;
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
) : undefined}
|
2023-03-28 02:31:50 -05:00
|
|
|
</div>
|
2023-12-01 16:42:45 -06:00
|
|
|
{newCollectionModal ? (
|
|
|
|
<NewCollectionModal onClose={() => setNewCollectionModal(false)} />
|
|
|
|
) : undefined}
|
2023-05-14 10:41:08 -05:00
|
|
|
</MainLayout>
|
2023-02-24 11:32:28 -06:00
|
|
|
);
|
|
|
|
}
|