Add subscribe in comments and registration

[MAILPOET-2677]
This commit is contained in:
Amine Ben hammou
2020-03-11 17:07:00 +01:00
committed by Veljko V
parent ecffd118af
commit 57e881dff5
7 changed files with 83 additions and 6 deletions

View File

@@ -3,12 +3,15 @@ import $ from 'jquery';
import 'select2';
type Props = {
id: string
id?: string
value: string[]
placeholder?: string
setValue: (x: string[]) => any
}
export default ({ id, value, setValue }: Props) => {
export default ({
id, value, placeholder, setValue,
}: Props) => {
React.useLayoutEffect(() => {
const idSelector = `#${id}`;
$(idSelector).select2();
@@ -19,7 +22,7 @@ export default ({ id, value, setValue }: Props) => {
}, [id, setValue]);
const segments: any[] = (window as any).mailpoet_segments;
return (
<select id={id} defaultValue={value} multiple>
<select id={id} data-placeholder={placeholder} defaultValue={value} multiple>
{segments.map((seg) => (
<option key={seg.id} value={seg.id}>
{`${seg.name} (${seg.subscribers})`}