2019-09-02 14:32:57 +02:00
|
|
|
import * as React from 'react';
|
2022-06-05 11:40:43 +02:00
|
|
|
import I18n from 'i18n-js';
|
2019-09-02 14:32:57 +02:00
|
|
|
|
2022-06-08 10:20:36 +02:00
|
|
|
import Button from '../common/Button';
|
2024-07-12 20:38:46 +02:00
|
|
|
import { SmallMutedText } from '../common/CustomTexts';
|
2024-12-20 14:06:48 +01:00
|
|
|
import { MarkdownIcon } from '../common/Icons';
|
2019-09-16 12:22:30 +02:00
|
|
|
|
2019-09-02 14:32:57 +02:00
|
|
|
interface Props {
|
|
|
|
|
title: string;
|
|
|
|
|
description: string;
|
|
|
|
|
handleTitleChange(title: string): void;
|
|
|
|
|
handleDescriptionChange(description: string): void;
|
2024-07-12 20:38:46 +02:00
|
|
|
|
2019-09-02 14:32:57 +02:00
|
|
|
handleSubmit(e: object): void;
|
2024-07-12 20:38:46 +02:00
|
|
|
|
|
|
|
|
dnf1: string;
|
|
|
|
|
dnf2: string;
|
|
|
|
|
handleDnf1Change(dnf1: string): void;
|
|
|
|
|
handleDnf2Change(dnf2: string): void;
|
|
|
|
|
|
|
|
|
|
currentUserFullName: string;
|
|
|
|
|
isSubmissionAnonymous: boolean;
|
2019-09-02 14:32:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NewPostForm = ({
|
|
|
|
|
title,
|
|
|
|
|
description,
|
|
|
|
|
handleTitleChange,
|
|
|
|
|
handleDescriptionChange,
|
2024-07-12 20:38:46 +02:00
|
|
|
|
2019-09-02 14:32:57 +02:00
|
|
|
handleSubmit,
|
2024-07-12 20:38:46 +02:00
|
|
|
|
|
|
|
|
dnf1,
|
|
|
|
|
dnf2,
|
|
|
|
|
handleDnf1Change,
|
|
|
|
|
handleDnf2Change,
|
|
|
|
|
|
|
|
|
|
currentUserFullName,
|
|
|
|
|
isSubmissionAnonymous,
|
2019-09-02 14:32:57 +02:00
|
|
|
}: Props) => (
|
|
|
|
|
<div className="newPostForm">
|
|
|
|
|
<form>
|
|
|
|
|
<div className="form-group">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={title}
|
|
|
|
|
onChange={e => handleTitleChange(e.target.value)}
|
2024-01-24 18:37:54 +01:00
|
|
|
maxLength={128}
|
2024-07-12 20:38:46 +02:00
|
|
|
placeholder={I18n.t('board.new_post.title')}
|
2019-09-02 14:32:57 +02:00
|
|
|
|
|
|
|
|
id="postTitle"
|
|
|
|
|
className="form-control"
|
|
|
|
|
|
|
|
|
|
autoFocus
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-07-12 20:38:46 +02:00
|
|
|
|
|
|
|
|
{ /* Honeypot field 1 */ }
|
|
|
|
|
<div className="form-group form-group-dnf">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={dnf1}
|
|
|
|
|
onChange={e => handleDnf1Change(e.target.value)}
|
|
|
|
|
maxLength={128}
|
|
|
|
|
placeholder="email"
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
|
|
|
|
|
id="email"
|
|
|
|
|
className="form-control"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{ /* Honeypot field 2 */ }
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={dnf2}
|
|
|
|
|
onChange={e => handleDnf2Change(e.target.value)}
|
|
|
|
|
maxLength={128}
|
|
|
|
|
placeholder="name"
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
tabIndex={-1}
|
|
|
|
|
|
|
|
|
|
id="name"
|
|
|
|
|
className="form-control"
|
|
|
|
|
/>
|
|
|
|
|
|
2019-09-02 14:32:57 +02:00
|
|
|
<div className="form-group">
|
|
|
|
|
<textarea
|
|
|
|
|
value={description}
|
|
|
|
|
onChange={e => handleDescriptionChange(e.target.value)}
|
|
|
|
|
rows={3}
|
2024-07-12 20:38:46 +02:00
|
|
|
placeholder={I18n.t('board.new_post.description')}
|
2019-09-02 14:32:57 +02:00
|
|
|
|
|
|
|
|
className="form-control"
|
|
|
|
|
id="postDescription"
|
|
|
|
|
></textarea>
|
2024-12-20 14:06:48 +01:00
|
|
|
<div style={{position: 'relative', width: 0, height: 0}}>
|
|
|
|
|
<MarkdownIcon style={{position: 'absolute', left: '6px', top: '-28px'}} />
|
|
|
|
|
</div>
|
2019-09-02 14:32:57 +02:00
|
|
|
</div>
|
2024-07-12 20:38:46 +02:00
|
|
|
|
2019-09-16 12:22:30 +02:00
|
|
|
<Button onClick={e => handleSubmit(e)} className="submitBtn d-block mx-auto">
|
2022-06-05 11:40:43 +02:00
|
|
|
{I18n.t('board.new_post.submit_button')}
|
2019-09-16 12:22:30 +02:00
|
|
|
</Button>
|
2024-07-12 20:38:46 +02:00
|
|
|
|
|
|
|
|
<SmallMutedText>
|
|
|
|
|
{
|
|
|
|
|
isSubmissionAnonymous ?
|
|
|
|
|
I18n.t('board.new_post.anonymous_submission_help')
|
|
|
|
|
:
|
|
|
|
|
I18n.t('board.new_post.non_anonymous_submission_help', { name: currentUserFullName })
|
|
|
|
|
}
|
|
|
|
|
</SmallMutedText>
|
2019-09-02 14:32:57 +02:00
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export default NewPostForm;
|