2019-09-12 15:51:45 +02:00
|
|
|
import * as React from 'react';
|
2022-06-05 11:40:43 +02:00
|
|
|
import I18n from 'i18n-js';
|
2019-09-12 15:51:45 +02:00
|
|
|
|
|
|
|
|
import IPostStatus from '../../interfaces/IPostStatus';
|
|
|
|
|
|
2019-09-24 12:57:32 +02:00
|
|
|
const NO_POST_STATUS_VALUE = 'none';
|
|
|
|
|
|
2019-09-12 15:51:45 +02:00
|
|
|
interface Props {
|
|
|
|
|
postStatuses: Array<IPostStatus>;
|
|
|
|
|
selectedPostStatusId: number;
|
|
|
|
|
|
|
|
|
|
handleChange(
|
|
|
|
|
newPostStatusId: number,
|
|
|
|
|
): void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const PostStatusSelect = ({
|
|
|
|
|
postStatuses,
|
|
|
|
|
selectedPostStatusId,
|
|
|
|
|
handleChange,
|
|
|
|
|
}: Props) => (
|
2019-09-21 12:54:57 +02:00
|
|
|
<select
|
2019-09-24 12:57:32 +02:00
|
|
|
value={selectedPostStatusId || NO_POST_STATUS_VALUE}
|
2019-09-21 12:54:57 +02:00
|
|
|
onChange={
|
2019-09-26 11:00:32 +02:00
|
|
|
(e: React.FormEvent) => (
|
2019-09-21 12:54:57 +02:00
|
|
|
handleChange(parseInt((e.target as HTMLSelectElement).value))
|
|
|
|
|
)}
|
|
|
|
|
id="selectPickerStatus"
|
|
|
|
|
className="selectPicker"
|
|
|
|
|
>
|
|
|
|
|
<optgroup label="Post statuses">
|
2019-09-14 16:05:54 +02:00
|
|
|
{postStatuses.map((postStatus, i) => (
|
|
|
|
|
<option value={postStatus.id} key={i}>
|
|
|
|
|
{postStatus.name}
|
|
|
|
|
</option>
|
|
|
|
|
))}
|
2019-09-21 12:54:57 +02:00
|
|
|
</optgroup>
|
|
|
|
|
<optgroup label="No post status">
|
2022-06-05 11:40:43 +02:00
|
|
|
<option value={NO_POST_STATUS_VALUE}>{I18n.t('post.post_status_select.no_post_status')}</option>
|
2019-09-21 12:54:57 +02:00
|
|
|
</optgroup>
|
|
|
|
|
</select>
|
2019-09-12 15:51:45 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export default PostStatusSelect;
|