diff --git a/client/src/components/fakestackoverflow.tsx b/client/src/components/fakestackoverflow.tsx index 8701b23..efde8aa 100644 --- a/client/src/components/fakestackoverflow.tsx +++ b/client/src/components/fakestackoverflow.tsx @@ -17,6 +17,7 @@ import UsersListPage from './main/usersListPage'; import ProfileSettings from './profileSettings'; import AllGamesPage from './main/games/allGamesPage'; import GamePage from './main/games/gamePage'; +import AllCommunitiesPage from './main/communities/allCommunitiesPage'; const ProtectedRoute = ({ user, @@ -66,6 +67,7 @@ const FakeStackOverflow = ({ socket }: { socket: FakeSOSocket | null }) => { } /> } /> } /> + } /> } diff --git a/client/src/components/main/communities/addCommunityForm/index.css b/client/src/components/main/communities/addCommunityForm/index.css new file mode 100644 index 0000000..5b80768 --- /dev/null +++ b/client/src/components/main/communities/addCommunityForm/index.css @@ -0,0 +1,79 @@ +.add-community-form { + background: #ffffff; + border: 1px solid #e0e0e0; + padding: 20px; + border-radius: 12px; + max-width: 400px; + margin: 20px auto; + } + + .add-community-form h2 { + font-size: 1.5rem; + margin-bottom: 1rem; + text-align: center; + } + + .add-community-form label { + display: block; + margin-bottom: 0.5rem; + font-weight: bold; + } + + .add-community-form input, + .add-community-form textarea { + width: 100%; + padding: 8px 10px; + margin-bottom: 1rem; + border: 1px solid #ccc; + border-radius: 8px; + font-size: 1rem; + } + + .add-community-form textarea { + resize: vertical; + min-height: 80px; + } + + .add-community-form .form-actions { + display: flex; + justify-content: space-between; + gap: 10px; + } + + .add-community-form button { + flex: 1; + padding: 10px; + border: none; + border-radius: 8px; + font-size: 1rem; + cursor: pointer; + } + + .add-community-form .visibility-checkbox { + display: flex; + align-items: center; + gap: 10px; + } + + .add-community-form .visibility-checkbox label { + margin-bottom: 0; + font-weight: normal; + display: flex; + align-items: center; + } + + + .add-community-form button.submit { + background-color: #4caf50 !important; + color: white !important; + } + + .add-community-form button.cancel { + background-color: #f44336 !important; + color: white !important; + } + + .add-community-form button:hover { + opacity: 0.9; + } + \ No newline at end of file diff --git a/client/src/components/main/communities/addCommunityForm/index.tsx b/client/src/components/main/communities/addCommunityForm/index.tsx new file mode 100644 index 0000000..a40311d --- /dev/null +++ b/client/src/components/main/communities/addCommunityForm/index.tsx @@ -0,0 +1,85 @@ +import React, { useState } from 'react'; +import './index.css'; + +interface AddCommunityFormProps { + onSubmit: (data: { name: string; description: string; visibility: 'public' | 'private' }) => void; + onCancel: () => void; + errorMessage: string; + setErrorMessage: React.Dispatch>; +} + +const AddCommunityForm: React.FC = ({ + onSubmit, + onCancel, + errorMessage, + setErrorMessage, +}) => { + const [formData, setFormData] = useState({ + name: '', + description: '', + visibility: 'public' as 'public' | 'private', + }); + + const handleChange = (e: React.ChangeEvent) => { + const { name, value } = e.target; + setFormData(prev => ({ ...prev, [name]: value })); + }; + + const handleCheckboxChange = (e: React.ChangeEvent) => { + setFormData(prev => ({ + ...prev, + visibility: e.target.checked ? 'private' : 'public', + })); + }; + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + + if (errorMessage) { + setErrorMessage(''); + } + + onSubmit(formData); + setFormData({ name: '', description: '', visibility: 'public' }); + }; + return ( +
+ + {errorMessage &&
{errorMessage}
} +