From d5abdaef7d89f4b38a80197ba0bc481d61d020ac Mon Sep 17 00:00:00 2001 From: hdjoumdjeu Date: Sat, 18 Jan 2025 21:05:21 -0600 Subject: [PATCH 1/2] pull latest update --- src/views/ShareAProject.jsx | 475 +++++++++++++++++++++--------------- 1 file changed, 280 insertions(+), 195 deletions(-) diff --git a/src/views/ShareAProject.jsx b/src/views/ShareAProject.jsx index 4ccc624..f7eadb5 100644 --- a/src/views/ShareAProject.jsx +++ b/src/views/ShareAProject.jsx @@ -1,205 +1,290 @@ -import React, { useState } from 'react' +import React, { useState } from "react"; import "../styles/ShareAProject.css"; -import { Input, CheckboxGroup, Fieldset, Textarea, Button } from "@chakra-ui/react" -import { Field } from "../components/ui/field" -import { Checkbox } from "../components/ui/checkbox" -import { Toaster, toaster } from "../components/ui/toaster" +import { + Input, + CheckboxGroup, + Fieldset, + Textarea, + Button, +} from "@chakra-ui/react"; +import { Field } from "../components/ui/field"; +import { Checkbox } from "../components/ui/checkbox"; +import { Toaster, toaster } from "../components/ui/toaster"; const ShareAProject = () => { + const [newProject, setNewProject] = useState({ + title: "", + githubURL: "", + description: "", + frameworks: [], + liveDemoURL: "", + comments: "", + date: "", + }); - const [newProject, setNewProject] = useState({ - title: '', - githubURL: '', - description: '', - frameworks: [], - liveDemoURL: '', - comments: '', - date: '' + const handleSubmit = async (e) => { + e.preventDefault(); + + try { + const response = await fetch("http://localhost:8001/addproject", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + ...newProject, + date: new Date().toISOString(), + }), }); - - const handleSubmit = async (e) => { - e.preventDefault(); - - try { - const response = await fetch('http://localhost:8001/projects', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - ...newProject, - date: new Date().toISOString() - }), - }); - - if (response.ok) { - toaster.create({ - title: 'Project submitted succesfully!', - type: 'success', - duration: 4000, - action: { - label: "x", - } - }) - setNewProject({ - title: '', - githubURL: '', - description: '', - frameworks: [], - liveDemoURL: '', - comments: '', - date: '', - }); - } else { - console.error('Failed to submit project'); - } - } catch (error) { - toaster.create({ - title: `Error submitting project: ${error.message}`, - type: 'error', - duration: 4000, - action: { - label: "x", - } - }); - } - }; - - const handleCheckboxChange = (value) => { - setNewProject((prev) => ({ - ...prev, - frameworks: prev.frameworks.includes(value) - ? prev.frameworks.filter((framework) => framework !== value) - : [...prev.frameworks, value], - })); - }; + console.log(newProject); + if (response.ok) { + toaster.create({ + title: "Project submitted succesfully!", + type: "success", + duration: 4000, + action: { + label: "x", + }, + }); + setNewProject({ + title: "", + githubURL: "", + description: "", + frameworks: [], + liveDemoURL: "", + comments: "", + date: "", + }); + } else { + console.error("Failed to submit project"); + } + } catch (error) { + toaster.create({ + title: `Error submitting project: ${error.message}`, + type: "error", + duration: 4000, + action: { + label: "x", + }, + }); + } + }; + + const handleCheckboxChange = (value) => { + setNewProject((prev) => ({ + ...prev, + frameworks: prev.frameworks.includes(value) + ? prev.frameworks.filter((framework) => framework !== value) + : [...prev.frameworks, value], + })); + }; - return( -
-
-
-

Share Your Project

-
-

Start Your - Journey with Us

-
-

Submit your project and take the next step in your learning journey with us. Whether you're looking to refine your skills or showcase your progress, we're here to guide you through each stage, helping you turn your ideas into impactful solutions.

-
- thumbs-up -
+ return ( + +
+
+

Share Your Project

+
+

Start Your Journey with Us

+
+

+ Submit your project and take the next step in your learning + journey with us. Whether you're looking to refine your skills or + showcase your progress, we're here to guide you through each + stage, helping you turn your ideas into impactful solutions. +

- -
-

Share Your Project

- Project Title} required - errorText="This field is required"> - setNewProject({ ...newProject, title: e.target.value })} - /> - - Description} required helperText="Max 500 characters."> -