MCPcopy Create free account
hub / github.com/Bitbox-Connect/Bitbox / AnswerForm

Function AnswerForm

client/src/component/DiscussionForum.jsx:106–135  ·  view source on GitHub ↗
({ questionId })

Source from the content-addressed store, hash-verified

104
105 // Function to render the Answer Form
106 const AnswerForm = ({ questionId }) => {
107 const [answer, setAnswer] = useState('');
108
109 const handleSubmit = (e) => {
110 e.preventDefault();
111 if (answer.trim()) {
112 addAnswer(questionId, answer);
113 setAnswer('');
114 }
115 };
116
117 return (
118 <form onSubmit={handleSubmit} className={`p-4 rounded-md shadow-md mt-4 ${props.mode === 'dark' ? 'bg-gray-700' : 'bg-white'}`}>
119 <textarea
120 value={answer}
121 onChange={(e) => setAnswer(e.target.value)}
122 placeholder="Write your answer..."
123 className={`w-full p-4 border rounded-md ${props.mode === 'dark' ? 'bg-gray-900 text-white' : 'bg-gray-100 text-gray-800'
124 } focus:outline-none focus:ring-2 ${props.mode === 'dark' ? 'focus:ring-gray-400' : 'focus:ring-gray-500'} transition-all`}
125 />
126 <button
127 type="submit"
128 className={`mt-4 px-6 py-2 rounded-md ${props.mode === 'dark' ? 'bg-gray-600 text-white hover:bg-gray-500' : 'bg-gray-800 text-white hover:bg-gray-600'
129 } focus:outline-none focus:ring-2 ${props.mode === 'dark' ? 'focus:ring-gray-400' : 'focus:ring-gray-500'} transition-colors`}
130 >
131 Submit Answer
132 </button>
133 </form>
134 );
135 };
136
137 AnswerForm.propTypes = {
138 questionId: PropTypes.string.isRequired,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected