small changes
This commit is contained in:
parent
4bfb08a52e
commit
e715756cbe
|
@ -18,12 +18,17 @@ export default function ({ collection }: { collection: Collection }) {
|
||||||
return (
|
return (
|
||||||
<Link href={`/collections/${collection.id}`}>
|
<Link href={`/collections/${collection.id}`}>
|
||||||
<div className="p-5 bg-gray-100 h-40 w-60 rounded-md border-sky-100 border-solid border flex flex-col justify-between cursor-pointer hover:bg-gray-50 duration-100">
|
<div className="p-5 bg-gray-100 h-40 w-60 rounded-md border-sky-100 border-solid border flex flex-col justify-between cursor-pointer hover:bg-gray-50 duration-100">
|
||||||
<div className="flex justify-between text-sky-900 items-center">
|
<div>
|
||||||
<p className="text-lg w-max">{collection.name}</p>
|
<div className="flex justify-between text-sky-900 items-center">
|
||||||
<FontAwesomeIcon
|
<p className="text-lg w-max">{collection.name}</p>
|
||||||
icon={faChevronRight}
|
<FontAwesomeIcon
|
||||||
className="w-3 h-3 text-gray-500"
|
icon={faChevronRight}
|
||||||
/>
|
className="w-3 h-3 text-gray-500"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p className="text-sm font-bold text-gray-500">
|
||||||
|
{collection.description}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm text-sky-300 font-bold">{formattedDate}</p>
|
<p className="text-sm text-sky-300 font-bold">{formattedDate}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -42,7 +42,7 @@ export default function AddCollection({ toggleCollectionModal }: Props) {
|
||||||
}
|
}
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="e.g. Example Collection"
|
placeholder="e.g. Example Collection"
|
||||||
className="w-96 rounded-md p-3 border-sky-100 border-solid border text-sm outline-none focus:border-sky-500 duration-100"
|
className="w-56 sm:w-96 rounded-md p-3 border-sky-100 border-solid border text-sm outline-none focus:border-sky-500 duration-100"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ export default function AddCollection({ toggleCollectionModal }: Props) {
|
||||||
}
|
}
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Collection description (Optional)"
|
placeholder="Collection description (Optional)"
|
||||||
className="w-96 rounded-md p-3 border-sky-100 border-solid border text-sm outline-none focus:border-sky-500 duration-100"
|
className="w-56 sm:w-96 rounded-md p-3 border-sky-100 border-solid border text-sm outline-none focus:border-sky-500 duration-100"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { Collection } from "@prisma/client";
|
||||||
import { existsSync, mkdirSync } from "fs";
|
import { existsSync, mkdirSync } from "fs";
|
||||||
|
|
||||||
export default async function (collection: Collection, userId: number) {
|
export default async function (collection: Collection, userId: number) {
|
||||||
if (!collection)
|
if (!collection || collection.name.trim() === "")
|
||||||
return {
|
return {
|
||||||
response: "Please enter a valid collection.",
|
response: "Please enter a valid collection.",
|
||||||
status: 400,
|
status: 400,
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
import Dropdown from "@/components/Dropdown";
|
import Dropdown from "@/components/Dropdown";
|
||||||
import LinkList from "@/components/LinkList";
|
import LinkList from "@/components/LinkList";
|
||||||
|
import Modal from "@/components/Modal";
|
||||||
|
import AddLink from "@/components/Modal/AddLink";
|
||||||
import useCollectionStore from "@/store/collections";
|
import useCollectionStore from "@/store/collections";
|
||||||
import useLinkStore from "@/store/links";
|
import useLinkStore from "@/store/links";
|
||||||
import { ExtendedLink } from "@/types/global";
|
import { ExtendedLink } from "@/types/global";
|
||||||
|
@ -27,10 +29,15 @@ export default function () {
|
||||||
const { collections } = useCollectionStore();
|
const { collections } = useCollectionStore();
|
||||||
|
|
||||||
const [expandDropdown, setExpandDropdown] = useState(false);
|
const [expandDropdown, setExpandDropdown] = useState(false);
|
||||||
|
const [linkModal, setLinkModal] = useState(false);
|
||||||
const [activeCollection, setActiveCollection] = useState<Collection>();
|
const [activeCollection, setActiveCollection] = useState<Collection>();
|
||||||
const [linksByCollection, setLinksByCollection] =
|
const [linksByCollection, setLinksByCollection] =
|
||||||
useState<ExtendedLink[]>(links);
|
useState<ExtendedLink[]>(links);
|
||||||
|
|
||||||
|
const toggleLinkModal = () => {
|
||||||
|
setLinkModal(!linkModal);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLinksByCollection(
|
setLinksByCollection(
|
||||||
links.filter((e) => e.collection.id === Number(router.query.id))
|
links.filter((e) => e.collection.id === Number(router.query.id))
|
||||||
|
@ -67,6 +74,10 @@ export default function () {
|
||||||
{
|
{
|
||||||
name: "Add Link Here",
|
name: "Add Link Here",
|
||||||
icon: <FontAwesomeIcon icon={faAdd} />,
|
icon: <FontAwesomeIcon icon={faAdd} />,
|
||||||
|
onClick: () => {
|
||||||
|
toggleLinkModal();
|
||||||
|
setExpandDropdown(false);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Edit Collection",
|
name: "Edit Collection",
|
||||||
|
@ -84,6 +95,12 @@ export default function () {
|
||||||
className="absolute top-7 left-0 z-10 w-44"
|
className="absolute top-7 left-0 z-10 w-44"
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
{linkModal ? (
|
||||||
|
<Modal toggleModal={toggleLinkModal}>
|
||||||
|
<AddLink toggleLinkModal={toggleLinkModal} />
|
||||||
|
</Modal>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{linksByCollection.map((e, i) => {
|
{linksByCollection.map((e, i) => {
|
||||||
|
|
|
@ -4,7 +4,12 @@
|
||||||
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import useCollectionStore from "@/store/collections";
|
import useCollectionStore from "@/store/collections";
|
||||||
import { faAdd, faBox, faEllipsis } from "@fortawesome/free-solid-svg-icons";
|
import {
|
||||||
|
faAdd,
|
||||||
|
faBox,
|
||||||
|
faEllipsis,
|
||||||
|
faPlus,
|
||||||
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import CollectionCard from "@/components/CollectionCard";
|
import CollectionCard from "@/components/CollectionCard";
|
||||||
import Dropdown from "@/components/Dropdown";
|
import Dropdown from "@/components/Dropdown";
|
||||||
|
@ -18,7 +23,7 @@ export default function () {
|
||||||
|
|
||||||
const [linkModal, setLinkModal] = useState(false);
|
const [linkModal, setLinkModal] = useState(false);
|
||||||
|
|
||||||
const toggleLinkModal = () => {
|
const toggleCollectionModal = () => {
|
||||||
setLinkModal(!linkModal);
|
setLinkModal(!linkModal);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,7 +54,7 @@ export default function () {
|
||||||
name: "New",
|
name: "New",
|
||||||
icon: <FontAwesomeIcon icon={faAdd} />,
|
icon: <FontAwesomeIcon icon={faAdd} />,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
toggleLinkModal();
|
toggleCollectionModal();
|
||||||
setExpandDropdown(false);
|
setExpandDropdown(false);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -64,8 +69,8 @@ export default function () {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{linkModal ? (
|
{linkModal ? (
|
||||||
<Modal toggleModal={toggleLinkModal}>
|
<Modal toggleModal={toggleCollectionModal}>
|
||||||
<AddCollection toggleCollectionModal={toggleLinkModal} />
|
<AddCollection toggleCollectionModal={toggleCollectionModal} />
|
||||||
</Modal>
|
</Modal>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
@ -73,6 +78,14 @@ export default function () {
|
||||||
{collections.map((e, i) => {
|
{collections.map((e, i) => {
|
||||||
return <CollectionCard key={i} collection={e} />;
|
return <CollectionCard key={i} collection={e} />;
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
<div
|
||||||
|
className="p-5 bg-gray-100 h-40 w-60 rounded-md border-sky-100 border-solid border flex flex-col gap-4 justify-center items-center cursor-pointer hover:bg-gray-50 duration-100"
|
||||||
|
onClick={toggleCollectionModal}
|
||||||
|
>
|
||||||
|
<p className="text-sky-900">New Collection</p>
|
||||||
|
<FontAwesomeIcon icon={faPlus} className="w-8 h-8 text-sky-500" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -35,6 +35,8 @@ const useCollectionStore = create<CollectionStore>()((set) => ({
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
if (response.ok)
|
if (response.ok)
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
collections: [...state.collections, data.response],
|
collections: [...state.collections, data.response],
|
||||||
|
|
Ŝarĝante…
Reference in New Issue