diff --git a/pages/CollectionDetailPage.js b/pages/CollectionDetailPage.js
new file mode 100644
index 0000000..7534dd6
--- /dev/null
+++ b/pages/CollectionDetailPage.js
@@ -0,0 +1,43 @@
+import React, { useState } from "react";
+import { useRouter } from "next/router";
+import { Box, Button, TextField, Typography } from "@mui/material";
+
+const CollectionDetailPage = ({ collection }) => {
+ const [newConcept, setNewConcept] = useState("");
+ const [concepts, setConcepts] = useState(collection.concepts || []);
+
+ const handleAddConcept = () => {
+ if (newConcept) {
+ setConcepts((prev) => [...prev, newConcept]);
+ setNewConcept("");
+ }
+ };
+
+ return (
+
+ {collection.name}
+ Concepts:
+
+ {concepts.length > 0 ? (
+
+ {concepts.map((concept, index) => (
+ - {concept}
+ ))}
+
+ ) : (
+ No concepts available.
+ )}
+
+ setNewConcept(e.target.value)}
+ />
+
+
+ );
+};
+
+export default CollectionDetailPage;
diff --git a/pages/collection/[id].js b/pages/collection/[id].js
new file mode 100644
index 0000000..51c2644
--- /dev/null
+++ b/pages/collection/[id].js
@@ -0,0 +1,33 @@
+import { useRouter } from "next/router";
+import { useEffect, useState } from "react";
+import { Box, Typography } from "@mui/material";
+
+const CollectionDetails = () => {
+ const router = useRouter();
+ const { id } = router.query;
+ const [collection, setCollection] = useState(null);
+
+ useEffect(() => {
+ if (id) {
+ // Fetch collection details based on the ID
+ fetch(`/api/collections/${id}`)
+ .then((res) => res.json())
+ .then((data) => setCollection(data))
+ .catch((err) => console.error(err));
+ }
+ }, [id]);
+
+ if (!collection) return Loading...;
+
+ return (
+
+ {collection.name}
+ Owner: {collection.owner}
+ Collection Type: {collection.collectionType}
+ Created At: {new Date(collection.createdAt).toLocaleString()}
+ Concepts: {collection.concepts.join(', ')}
+
+ );
+};
+
+export default CollectionDetails;
diff --git a/pages/createCollections.js b/pages/createCollections.js
new file mode 100644
index 0000000..0937740
--- /dev/null
+++ b/pages/createCollections.js
@@ -0,0 +1,166 @@
+import React, { useState } from "react";
+import {
+ Box,
+ Button,
+ TextField,
+ Dialog,
+ DialogActions,
+ DialogContent,
+ DialogTitle,
+ Typography,
+} from "@mui/material";
+
+const CreateCollectionModal = ({ onCollectionCreated }) => {
+ const [open, setOpen] = useState(false);
+ const [collectionDetails, setCollectionDetails] = useState({
+ id: "",
+ short_code: "",
+ short_name: "",
+ full_name: "",
+ owner: "",
+ description: "",
+ collection_type: "",
+ custom_validation_schema: "",
+ canonical_url: "",
+ });
+
+ const handleOpen = () => {
+ setCollectionDetails({
+ id: "",
+ short_code: "",
+ short_name: "",
+ full_name: "",
+ owner: "",
+ description: "",
+ collection_type: "",
+ custom_validation_schema: "",
+ canonical_url: "",
+ });
+ setOpen(true);
+ };
+
+ const handleClose = () => setOpen(false);
+
+ const handleSubmit = async () => {
+ if (!collectionDetails.short_code || !collectionDetails.full_name || !collectionDetails.owner) {
+ alert("Short Code, Full Name, and Owner are required!");
+ return;
+ }
+
+ try {
+ const response = await fetch('/api/collections', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(collectionDetails),
+ });
+
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
+ }
+
+ const createdCollection = await response.json();
+ onCollectionCreated(createdCollection);
+ handleClose();
+ } catch (error) {
+ console.error("Error creating collection:", error);
+ alert("Failed to create collection.");
+ }
+ };
+
+ return (
+
+
+
+
+
+ );
+};
+
+export default CreateCollectionModal;
diff --git a/pages/index.js b/pages/index.js
index f025028..77aa0ce 100755
--- a/pages/index.js
+++ b/pages/index.js
@@ -31,6 +31,8 @@ import { useRouter } from "next/router";
import Footer from "@/components/footer";
import VerifyEmail from "@/pages/auth/verifyEmail";
import { redirect } from "next/navigation";
+import CreateCollectionModal from "./createCollections";
+
const inter = Inter({ subsets: ["latin"] });
export const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL;
export default function Home() {
@@ -99,6 +101,20 @@ export default function Home() {
fetchDomains();
fetchCollections();
}, []);
+
+ const handleCollectionCreated = (newCollection) => {
+ setCollections((prevCollections) => [
+ ...prevCollections,
+ {
+ id: newCollection.id,
+ name: newCollection.full_name,
+ owner: newCollection.owner,
+ collection_type: newCollection.collection_type,
+ created_at: new Date().toISOString(),
+ },
+ ]);
+ };
+
return (
<>
@@ -376,11 +392,16 @@ export default function Home() {
+
Collections
+
+
@@ -397,16 +418,11 @@ export default function Home() {
- {collections.map((coll, index) => (
+ {collections.map((coll) => (
{
- router.push(coll.url);
+ key={coll.id}
+ onClick={() => {
+ router.push(`/collection/${coll.id}`);
}}
>
{coll.id}
@@ -414,7 +430,9 @@ export default function Home() {
{coll.owner}
{coll.collection_type}
- {new Date(coll.created_at).toLocaleString()}
+ {coll.created_at
+ ? new Date(coll.created_at).toLocaleString()
+ : new Date().toLocaleString()}
))}