diff --git a/src/components/Layout.vue b/src/components/Layout.vue index fdfc54b..6254103 100644 --- a/src/components/Layout.vue +++ b/src/components/Layout.vue @@ -9,8 +9,10 @@ import TopBar from "@/components/TopBar.vue";
-
-
+
+

{{ $route.meta.title }}

@@ -23,6 +25,13 @@ import TopBar from "@/components/TopBar.vue"; Back
+ + + Post Project +
diff --git a/src/main.ts b/src/main.ts index 60a3b0d..fa65ebf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -34,6 +34,14 @@ const router = createRouter({ title: "Registration", }, }, + { + path: "/projects/new", + component: () => import("./views/NewProject.vue"), + meta: { + title: "Post Project", + showBack: true, + }, + }, { path: "/projects/:id", component: () => import("./views/Project.vue"), diff --git a/src/projects.ts b/src/projects.ts index cb22b8e..ed400ae 100644 --- a/src/projects.ts +++ b/src/projects.ts @@ -1,9 +1,10 @@ -import { collection, doc, getDocs, setDoc } from "firebase/firestore"; +import { addDoc, collection, doc, getDocs, setDoc } from "firebase/firestore"; import { defineStore } from "pinia"; import { ref } from "vue"; import { firestore } from "./firebase"; import { Project } from "./types"; +import { ProjectCreationFormData } from "./views/NewProject.vue"; export const useProjectStore = defineStore("projects", () => { const projects = ref([]); @@ -58,9 +59,33 @@ export const useProjectStore = defineStore("projects", () => { }); } + function addProject(values: ProjectCreationFormData, userUid: string) { + const projectCollection = collection(firestore, "projects"); + addDoc(projectCollection, { + title: values.title, + description: values.description, + textContent: values.content, + links: values.links, + tags: values.tags, + projectId: "", + userId: userUid, + images: [], + upvotes: [], + createdAt: new Date(), + logo: "", + }) + .then(() => { + refetch(); + }) + .catch((error) => { + console.error("Error writing document: ", error); + }); + } + return { projects, refetch, upvoteProject, + addProject, }; }); diff --git a/src/style.css b/src/style.css index b22e2b2..e1b43e2 100644 --- a/src/style.css +++ b/src/style.css @@ -29,10 +29,13 @@ @apply block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6; } .button { - @apply flex w-full justify-center rounded-md px-3 py-1.5 text-sm font-semibold leading-6 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600; + @apply flex justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-semibold leading-6 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600; &.primary { @apply bg-indigo-600 text-white shadow-sm hover:bg-indigo-500; } + &.secondary { + @apply bg-white text-indigo-600 shadow-sm hover:bg-indigo-50 hover:text-indigo-900; + } &.outlined { @apply border-2 border-indigo-600 text-indigo-600 shadow-sm hover:bg-indigo-100; } diff --git a/src/views/Login.vue b/src/views/Login.vue index a6248c3..54449e0 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -125,9 +125,9 @@ watch(
- + - + Register
diff --git a/src/views/NewProject.vue b/src/views/NewProject.vue new file mode 100644 index 0000000..00c04ae --- /dev/null +++ b/src/views/NewProject.vue @@ -0,0 +1,217 @@ + + + diff --git a/src/views/Registration.vue b/src/views/Registration.vue index 50d4e16..b4479be 100644 --- a/src/views/Registration.vue +++ b/src/views/Registration.vue @@ -152,9 +152,9 @@ watch(
- + - + Sign In