Skip to content
Snippets Groups Projects
Commit dca1560c authored by xaralis's avatar xaralis
Browse files

feat: disallow adding proposals by regp

parent 05654387
No related branches found
No related tags found
No related merge requests found
Pipeline #2067 passed
...@@ -10,7 +10,7 @@ import ErrorMessage from "components/ErrorMessage"; ...@@ -10,7 +10,7 @@ import ErrorMessage from "components/ErrorMessage";
import MarkdownEditor from "components/mde/MarkdownEditor"; import MarkdownEditor from "components/mde/MarkdownEditor";
import { useActionState } from "hooks"; import { useActionState } from "hooks";
const AddPostForm = ({ className }) => { const AddPostForm = ({ className, canAddProposal }) => {
const cardRef = useRef(); const cardRef = useRef();
const editorRef = useRef(); const editorRef = useRef();
const [expanded, setExpanded] = useState(false); const [expanded, setExpanded] = useState(false);
...@@ -34,16 +34,24 @@ const AddPostForm = ({ className }) => { ...@@ -34,16 +34,24 @@ const AddPostForm = ({ className }) => {
setExpanded(false); setExpanded(false);
}, [setExpanded]); }, [setExpanded]);
const onWrite = useCallback(() => { const onWrite = useCallback(
(evt) => {
setShowAddConfirm(false);
if (!expanded) { if (!expanded) {
setExpanded(true); setExpanded(true);
setTimeout(() => { setTimeout(() => {
if (editorRef.current && editorRef.current.finalRefs.textarea.current) { if (
editorRef.current &&
editorRef.current.finalRefs.textarea.current
) {
editorRef.current.finalRefs.textarea.current.focus(); editorRef.current.finalRefs.textarea.current.focus();
} }
}, 0); }, 0);
} }
}, [setExpanded, expanded]); },
[setExpanded, expanded, setShowAddConfirm]
);
const hideAddConfirm = useCallback(() => { const hideAddConfirm = useCallback(() => {
setShowAddConfirm(false); setShowAddConfirm(false);
...@@ -88,7 +96,7 @@ const AddPostForm = ({ className }) => { ...@@ -88,7 +96,7 @@ const AddPostForm = ({ className }) => {
className, className,
"hover:elevation-16 transition duration-500", "hover:elevation-16 transition duration-500",
{ {
"elevation-4 cursor-text": !expanded, "elevation-4 cursor-text": !expanded && !showAddConfirm,
"lg:elevation-16 container-padding--zero lg:container-padding--auto": expanded, "lg:elevation-16 container-padding--zero lg:container-padding--auto": expanded,
} }
); );
...@@ -146,6 +154,7 @@ const AddPostForm = ({ className }) => { ...@@ -146,6 +154,7 @@ const AddPostForm = ({ className }) => {
]} ]}
/> />
{canAddProposal && (
<div <div
className="form-field" className="form-field"
onChange={(evt) => setType(evt.target.value)} onChange={(evt) => setType(evt.target.value)}
...@@ -179,6 +188,7 @@ const AddPostForm = ({ className }) => { ...@@ -179,6 +188,7 @@ const AddPostForm = ({ className }) => {
</div> </div>
</div> </div>
</div> </div>
)}
{type === "procedure-proposal" && ( {type === "procedure-proposal" && (
<p className="alert alert--light text-sm"> <p className="alert alert--light text-sm">
......
...@@ -330,7 +330,7 @@ const Home = () => { ...@@ -330,7 +330,7 @@ const Home = () => {
)} )}
{programEntry.discussionOpened && {programEntry.discussionOpened &&
isAuthenticated && isAuthenticated &&
!user.isBanned && <AddPostForm className="mb-8" />} !user.isBanned && <AddPostForm className="mb-8" canAddProposal={user.role === "member" || user.role === "chairman"} />}
<PostsContainer <PostsContainer
className="container-padding--zero lg:container-padding--auto" className="container-padding--zero lg:container-padding--auto"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment