50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import React, { useState } from 'react';
|
|
|
|
interface CreateProposalFormProps {
|
|
onSubmit: (data: { title: string; description: string }) => void;
|
|
}
|
|
|
|
export const CreateProposalForm: React.FC<CreateProposalFormProps> = ({ onSubmit }) => {
|
|
const [title, setTitle] = useState('');
|
|
const [description, setDescription] = useState('');
|
|
|
|
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
|
e.preventDefault();
|
|
onSubmit({ title, description });
|
|
setTitle('');
|
|
setDescription('');
|
|
};
|
|
|
|
return (
|
|
<form onSubmit={handleSubmit} className="space-y-4">
|
|
<div>
|
|
<label htmlFor="title" className="block text-sm font-medium text-gray-700">Title</label>
|
|
<input
|
|
type="text"
|
|
id="title"
|
|
value={title}
|
|
onChange={(e) => setTitle(e.target.value)}
|
|
required
|
|
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50"
|
|
/>
|
|
</div>
|
|
<div>
|
|
<label htmlFor="description" className="block text-sm font-medium text-gray-700">Description</label>
|
|
<textarea
|
|
id="description"
|
|
value={description}
|
|
onChange={(e) => setDescription(e.target.value)}
|
|
required
|
|
rows={4}
|
|
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50"
|
|
></textarea>
|
|
</div>
|
|
<button
|
|
type="submit"
|
|
className="w-full bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600 transition-colors"
|
|
>
|
|
Create Proposal
|
|
</button>
|
|
</form>
|
|
);
|
|
}; |