Skip to content

Commit

Permalink
ADD better text on edits
Browse files Browse the repository at this point in the history
  • Loading branch information
dolf321 committed Aug 25, 2023
1 parent fa63577 commit b9b79bc
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions web/src/components/forums/Publisher/Publisher.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@ import {useStyles} from './Publisher.styles';
import RichTextEditor from '../Editor/RichTextEditor';
import {useSnackbar} from 'notistack';

const modes = {
'post': {
title: 'Create A New Post',
title_placeholder: 'Put Title Here',
submit: 'Post',
},
'edit_post': {
title: 'Edit Post',
title_placeholder: 'Put Title Here',
submit: 'Update',
},
'comment': {
title: 'Create A New Comment',
title_placeholder: '',
submit: 'Comment',
},
'edit_comment': {
title: 'Edit Comment',
title_placeholder: '',
submit: 'Update',
},
};

export default function Publisher({
mode = 'post',
setOpen,
Expand All @@ -24,7 +47,7 @@ export default function Publisher({
const [isAnonymous, setIsAnonymous] = useState(anonymous);
const {enqueueSnackbar} = useSnackbar();

const isPost = mode === 'post';
const isPost = mode === 'post' || mode==='edit_post';

const validatePost = () => {
if (title && content) {
Expand Down Expand Up @@ -52,7 +75,7 @@ export default function Publisher({
{isPost &&
<DialogTitle className={classes.titleContainer}>
<Box display="flex" alignItems="center">
<Box flexGrow={1}>{isPost ? 'Create A New Post' : 'Create A New Comment'}</Box>
<Box flexGrow={1}>{modes[mode].title}</Box>
<IconButton onClick={() => setOpen(false)}>
<CloseIcon/>
</IconButton>
Expand All @@ -62,7 +85,7 @@ export default function Publisher({
<DialogContent sx={{padding: 0}}>
{isPost &&
<Input inputProps={{className: classes.inputTitle}} disableUnderline={true} fullWidth
value={title} onChange={(e) => setTitle(e.target.value)} placeholder={'Put Title Here'}/>
value={title} onChange={(e) => setTitle(e.target.value)} placeholder={modes[mode].title_placeholder}/>
}
{isPost ?
<RichTextEditor setContent={setContent} content={initialContent} /> :
Expand All @@ -84,7 +107,7 @@ export default function Publisher({
className={classes.submit}
onClick={validatePost}
>
{isPost ? 'Post' : 'Comment'}
{modes[mode].submit}
</Button>
</Box>
);
Expand Down

0 comments on commit b9b79bc

Please sign in to comment.