diff --git a/package-lock.json b/package-lock.json index e138f15..372ee9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -404,9 +404,9 @@ } }, "node_modules/@types/node": { - "version": "20.10.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.4.tgz", - "integrity": "sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg==", + "version": "20.10.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz", + "integrity": "sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==", "dependencies": { "undici-types": "~5.26.4" } @@ -995,9 +995,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.614", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.614.tgz", - "integrity": "sha512-X4ze/9Sc3QWs6h92yerwqv7aB/uU8vCjZcrMjA8N9R1pjMFRe44dLsck5FzLilOYvcXuDn93B+bpGYyufc70gQ==", + "version": "1.4.615", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.615.tgz", + "integrity": "sha512-/bKPPcgZVUziECqDc+0HkT87+0zhaWSZHNXqF8FLd2lQcptpmUFwoCSWjCdOng9Gdq+afKArPdEg/0ZW461Eng==", "dev": true }, "node_modules/encodeurl": { @@ -1145,9 +1145,9 @@ } }, "node_modules/fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz", + "integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==", "dependencies": { "reusify": "^1.0.4" } @@ -5630,9 +5630,9 @@ } }, "node_modules/tailwindcss": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.6.tgz", - "integrity": "sha512-AKjF7qbbLvLaPieoKeTjG1+FyNZT6KaJMJPFeQyLfIp7l82ggH1fbHJSsYIvnbTFQOlkh+gBYpyby5GT1LIdLw==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.0.tgz", + "integrity": "sha512-VigzymniH77knD1dryXbyxR+ePHihHociZbXnLZHUyzf2MMs2ZVqlUrZ3FvpXP8pno9JzmILt1sZPD19M3IxtA==", "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", diff --git a/src/components/PMApi/PMApi.js b/src/components/PMApi/PMApi.js index 61c04f4..6fcdcc8 100644 --- a/src/components/PMApi/PMApi.js +++ b/src/components/PMApi/PMApi.js @@ -1,7 +1,7 @@ import axios from "axios"; class PMApi { constructor(authToken) { - this.baseUrl = process.env.API_URL; + this.baseUrl = `${process.env.API_URL}`; this.basePagelength=100; axios.defaults.headers.common["Authorization"] = `Bearer ${authToken}`; } @@ -49,15 +49,27 @@ class PMApi { projImg ) { try { - const { data } = await axios.post(`${this.baseUrl}/posts`, { - projectName: projName, - description: projDesc, - creatorUserID: projMakerId, - contact: projContact, - tags: projTags, - technologies: projTech, - images: projImg, - }); + console.log(projImg) + let formData=new FormData(); + for (let i=0;i { - var formData = new FormData(); - - for (let i = 0; i < project.images.length; i++) { - formData.append("files", project.images[i]); - } - formData.append("projectName", project.projectName); - formData.append("creatorUserID", project.creatorUserID); - - const apiOptions = { - method: "POST", - url: `${process.env.API_URL}/images`, - headers: { - Authorization: `Bearer ${localStorage.getItem("authorisation_token")}`, - "Content-Type": "multipart/form-data", - }, - data: formData, - }; - axios.request(apiOptions).then(function (res) { - if (res.status == 200) { - const imageURLs = res.data.imageURL; - - api - .createPost( - project.projectName, - project.description, - project.creatorUserID, - project.contact, - project.tags, - project.technologies, - imageURLs - ) - .then((res) => { - if (res != -1 && res.insertedProjectWithID !== "") { - router.push(`Project?id=${res.insertedProjectWithID}`); - } - }); - } - }); - }; + // Process and Send Data const handleSubmission = async (event) => { @@ -128,8 +88,21 @@ export default function CreateProject() { images: projectImages, contact: event.target.projectContact.value, }; + api.createPost( + project.projectName, + project.description, + project.creatorUserID, + project.contact, + project.tags, + project.technologies, + project.images + ) + .then((res) => { + if (res != -1 && res.insertedProjectWithID !== "") { + router.push(`Project?id=${res.insertedProjectWithID}`); + } + }); - await createImageURL(project); } }; @@ -197,10 +170,10 @@ export default function CreateProject() {

- Tags + Technologies

- Add tags to help users find your project! + Let users know what Programming Language/Framework you use!

setTagQuery(e.target.value)} /> @@ -274,18 +247,18 @@ export default function CreateProject() {

- Technologies + Tags

- Let users know what Programming Language/Framework you use! + Add tags to help users find your project!

diff --git a/src/pages/Home.js b/src/pages/Home.js index 1bfe048..52e6774 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -147,6 +147,7 @@ export const getServerSideProps = withPageAuthRequired({ let posts = [] let memusers = [] + try { // Get All Posts await api.getPosts().then(function (rawPosts) { @@ -183,4 +184,4 @@ export const getServerSideProps = withPageAuthRequired({ } } }, -}); \ No newline at end of file +}); diff --git a/src/pages/Load.js b/src/pages/Load.js index b35c0f7..2d08b04 100644 --- a/src/pages/Load.js +++ b/src/pages/Load.js @@ -84,4 +84,4 @@ export default function Load() { ) } -export const getServerSideProps = withPageAuthRequired(); \ No newline at end of file +export const getServerSideProps = withPageAuthRequired();