Loading...
;
+ }
+
+ // Render error state
+ if (error) {
+ return
+ {/* Search input */}
+
+
+ setSearchQuery(e.target.value)}
+ className="pl-10 p-2 border rounded w-full"
+ />
+
+
+ {/* Projects List */}
+
+ {projects
+ .filter(project => project.Title.toLowerCase().includes(searchQuery.toLowerCase()))
+ .map((project) => (
+
+
{project.Title}
+
+
+
+
+
+ ))}
+
+
+ {/* Edit Modal */}
+ {isModalOpen && selectedProject && (
+
+
+
Edit Project
+
+
+
+
+
+
+ )}
+
+ {/* Delete Confirmation Modal */}
+ {showDeleteConfirm && (
+
+
+
Confirm Delete
+
+ Are you sure you want to delete "{projectToDelete?.Title}"?
+ This action cannot be undone.
+
+
+
+
+
+
+
+ )}
+
+ >
+ );
+}
\ No newline at end of file
diff --git a/src/lib/firebase/firebase.js b/src/lib/firebase/firebase.js
new file mode 100644
index 0000000..f012c34
--- /dev/null
+++ b/src/lib/firebase/firebase.js
@@ -0,0 +1,25 @@
+// Import the functions you need from the SDKs you need
+import { initializeApp } from "firebase/app";
+import { getFirestore } from "firebase/firestore";
+import { getStorage } from "firebase/storage";
+// TODO: Add SDKs for Firebase products that you want to use
+// https://firebase.google.com/docs/web/setup#available-libraries
+
+// Your web app's Firebase configuration
+// For Firebase JS SDK v7.20.0 and later, measurementId is optional
+const firebaseConfig = {
+ apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
+ authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
+ projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
+ storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
+ messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
+ appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
+ measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
+};
+
+// Initialize Firebase
+const app = initializeApp(firebaseConfig);
+const db = getFirestore(app);
+const storage = getStorage(app);
+
+export { db, storage};
\ No newline at end of file
diff --git a/src/lib/firebase/firebaseOperations.tsx b/src/lib/firebase/firebaseOperations.tsx
new file mode 100644
index 0000000..ca34da7
--- /dev/null
+++ b/src/lib/firebase/firebaseOperations.tsx
@@ -0,0 +1,63 @@
+import { db } from '@/lib/firebase/firebase';
+import { collection, getDocs, addDoc, updateDoc, deleteDoc, doc } from 'firebase/firestore';
+
+export interface Project {
+ id: string; //ID of the project NOT A COLUMN IN THE DATABASE
+ Youtube: string;
+ Description: string;
+ Parts: {
+ RAM: string;
+ Cooling: string;
+ Case: string;
+ Motherboard: string;
+ PSU: string;
+ GPU: string;
+ Storage: string;
+ CPU: string;
+ };
+ Title: string;
+ Photos: string;
+ Image: string;
+ Builders: string[]; // An array of builder names or identifiers
+}
+
+
+// READ Operation
+export const getAllProjects = async () => {
+ const querySnapshot = await getDocs(collection(db, "Projects"));
+ return querySnapshot.docs.map(doc => ({
+ id: doc.id,
+ ...doc.data(),
+ })) as Project[];
+};
+
+// CREATE Operation
+export const addProject = async (projectData: Project) => {
+ await addDoc(collection(db, "Projects"), projectData);
+};
+
+//ADD entry to the users database
+async function addData() {
+ try {
+ const docRef = await addDoc(collection(db, "Projects"), {
+ name: "Claudio Sciotto",
+ email: "claudio@example.com",
+ age: 22
+ });
+ console.log("Document written with ID: ", docRef.id);
+ } catch (e) {
+ console.error("Error adding document: ", e);
+ }
+}
+
+// // UPDATE Operation
+// export const updateProject = async (id, updatedData) => {
+// const projectDoc = doc(db, "Projects", id);
+// await updateDoc(projectDoc, updatedData);
+// };
+
+// // DELETE Operation
+// export const deleteProject = async (id) => {
+// const projectDoc = doc(db, "Projects", id);
+// await deleteDoc(projectDoc);
+// };
diff --git a/src/types/project.ts b/src/types/project.ts
new file mode 100644
index 0000000..9871a46
--- /dev/null
+++ b/src/types/project.ts
@@ -0,0 +1,25 @@
+export interface Parts {
+ RAM: string;
+ Cooling: string;
+ Case: string;
+ Motherboard: string;
+ PSU: string;
+ GPU: string;
+ Storage: string;
+ CPU: string;
+ }
+
+ export interface ProjectFormData {
+ Youtube: string;
+ Description: string;
+ Parts: Parts;
+ Title: string;
+ Photos: string;
+ Image: string;
+ Builders: string[];
+ }
+
+ export interface Project extends ProjectFormData {
+ id: string;
+ }
+