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

feat: disallow adding proposals by regp

parent 05654387
Branches
No related tags found
No related merge requests found
Pipeline #2067 passed
......@@ -10,7 +10,7 @@ import ErrorMessage from "components/ErrorMessage";
import MarkdownEditor from "components/mde/MarkdownEditor";
import { useActionState } from "hooks";
const AddPostForm = ({ className }) => {
const AddPostForm = ({ className, canAddProposal }) => {
const cardRef = useRef();
const editorRef = useRef();
const [expanded, setExpanded] = useState(false);
......@@ -34,16 +34,24 @@ const AddPostForm = ({ className }) => {
setExpanded(false);
}, [setExpanded]);
const onWrite = useCallback(() => {
const onWrite = useCallback(
(evt) => {
setShowAddConfirm(false);
if (!expanded) {
setExpanded(true);
setTimeout(() => {
if (editorRef.current && editorRef.current.finalRefs.textarea.current) {
if (
editorRef.current &&
editorRef.current.finalRefs.textarea.current
) {
editorRef.current.finalRefs.textarea.current.focus();
}
}, 0);
}
}, [setExpanded, expanded]);
},
[setExpanded, expanded, setShowAddConfirm]
);
const hideAddConfirm = useCallback(() => {
setShowAddConfirm(false);
......@@ -88,7 +96,7 @@ const AddPostForm = ({ className }) => {
className,
"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,
}
);
......@@ -146,6 +154,7 @@ const AddPostForm = ({ className }) => {
]}
/>
{canAddProposal && (
<div
className="form-field"
onChange={(evt) => setType(evt.target.value)}
......@@ -179,6 +188,7 @@ const AddPostForm = ({ className }) => {
</div>
</div>
</div>
)}
{type === "procedure-proposal" && (
<p className="alert alert--light text-sm">
......
......@@ -330,7 +330,7 @@ const Home = () => {
)}
{programEntry.discussionOpened &&
isAuthenticated &&
!user.isBanned && <AddPostForm className="mb-8" />}
!user.isBanned && <AddPostForm className="mb-8" canAddProposal={user.role === "member" || user.role === "chairman"} />}
<PostsContainer
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