From c7dfdc9d29b326ed5a672f2af7af21dd72996427 Mon Sep 17 00:00:00 2001 From: himansig7 Date: Thu, 5 Dec 2024 17:29:54 -0800 Subject: [PATCH 1/2] Update MakePostButton.jsx --- .../src/home_components/MakePostButton.jsx | 152 +++++++++++++++++- 1 file changed, 151 insertions(+), 1 deletion(-) diff --git a/frontend/src/home_components/MakePostButton.jsx b/frontend/src/home_components/MakePostButton.jsx index e0b2769..40d8b2b 100644 --- a/frontend/src/home_components/MakePostButton.jsx +++ b/frontend/src/home_components/MakePostButton.jsx @@ -78,7 +78,7 @@ const MakePostButton = ({ setPosts, courses }) => { mb={4} > - + {options.items.map((item) => ( @@ -104,3 +104,153 @@ const MakePostButton = ({ setPosts, courses }) => { }; export default MakePostButton; + +// import React, { useState } from 'react'; +// import { Box, Button, Input, Textarea, createListCollection } from '@chakra-ui/react'; +// import { +// SelectContent, +// SelectItem, +// SelectLabel, +// SelectRoot, +// SelectTrigger, +// SelectValueText, +// Tag, +// } from "../components/ui/select"; +// import axios from 'axios'; + +// const MakePostButton = ({ setPosts, courses }) => { +// const [showCreatePost, setShowCreatePost] = useState(false); +// const [title, setTitle] = useState(''); +// const [description, setDescription] = useState(''); +// const [tags, setTags] = useState([]); +// const [tagInput, setTagInput] = useState(''); +// const [selectedTags, setSelectedTags] = useState([]); // Line 16 + +// const [selectedOption, setSelectedOption] = useState(""); // Track selected option +// const options = createListCollection({ +// items: courses.map(course => ({ label: course, value: course })), // Line 18 +// }); + +// const tagOptions = createListCollection({ +// items: [ +// { label: "Homework", value: "homework" }, +// { label: "Exam", value: "exam" }, +// { label: "Project", value: "project" }, +// ], +// }); + +// const handleCreatePost = async () => { +// try { +// const response = await axios.post('http://localhost:5000/api/posts', { +// title, +// description, +// tags: selectedTags, +// }); + +// // Update the posts in HomePage +// setPosts((prevPosts) => [response.data, ...prevPosts]); + +// // Clear the form and hide the creation area +// setTitle(''); +// setDescription(''); +// setTags([]); +// setTagInput(''); +// setSelectedTags([]); +// setShowCreatePost(false); +// } catch (error) { +// console.error("Error creating post:", error); +// } +// }; + +// return ( +// +// {/* Toggle Button */} +// + +// {/* Post Creation Form */} +// {showCreatePost && ( +// +// setTitle(e.target.value)} +// mb={4} +// /> +//