// @flow
import { Link } from 'react-router-dom';
import { Component } from 'react';
import Button from 'app/components/Button';
import styles from './AnnouncementInLine.css';
import type { ID } from 'app/models';

type Props = {
  placeholder?: string,
  event?: ID,
  meeting?: ID,
  group?: ID,
  createAnnouncement: (CreateAnnouncement) => Promise<*>,
  handleSubmit: (Function) => void,
  actionGrant: boolean,
  hidden?: boolean,
  button?: boolean,
  className?: string,
};

class AnnouncementInLine extends Component<Props> {
  render() {
    const { actionGrant, event, meeting, group } = this.props;

    return (
      <div>
        {actionGrant && (event || meeting || group) && (
          <div>
            <Link to={'/announcements'} state={{ event, meeting }}>
              <Button className={styles.announcementButton}>
                Ny kunngjøring
              </Button>
            </Link>
          </div>
        )}
      </div>
    );
  }
}

export default AnnouncementInLine;

@@ -47,43 +47,8 @@
 m';%0A
-import %7B Component %7D from 'react';%0A
 impo
@@ -176,352 +176,189 @@
 s';%0A
-%0Atype Props = %7B%0A  placeholder?: string,%0A  event?: ID,%0A  meeting?: ID,%0A  group?: ID,%0A  createAnnouncement: (CreateAnnouncement) =%3E Promise%3C*%3E,%0A  handleSubmit: (Function) =%3E void,%0A  actionGrant: boolean,%0A  hidden?: boolean,%0A  button?: boolean,%0A  className?: string,%0A%7D;%0A%0Aclass AnnouncementInLine extends Component%3CProps%3E %7B%0A  render() %7B%0A  
+import %7B useSelector %7D from 'react-redux';%0A%0Atype Props = %7B%0A  event?: ID,%0A  meeting?: ID,%0A  group?: ID,%0A%7D;%0A%0Aconst AnnouncementInLine = (%7B event, meeting, group %7D: Props) =%3E %7B%0A
   const
- %7B
  act
@@ -369,51 +369,65 @@
 rant
-, event, meeting, group %7D = this.props
+ = useSelector((state) =%3E state.allowed.announcements)
 ;%0A%0A
-  
   re
@@ -433,34 +433,30 @@
 eturn (%0A    
-  
 %3Cdiv%3E%0A
-  
       %7Bactio
@@ -506,18 +506,16 @@
         
-  
 %3Cdiv%3E%0A  
@@ -526,20 +526,56 @@
     
-  
 %3CLink
- to=%7B
+%0A            to=%7B%7B%0A              pathname: 
 '/an
@@ -590,17 +590,31 @@
 nts'
-%7D
+,%0A             
  state
-=%7B
+: 
 %7B ev
@@ -629,15 +629,46 @@
 ting
+, group %7D,%0A           
  %7D%7D
-%3E
 %0A  
+        %3E%0A
     
@@ -736,18 +736,16 @@
         
-  
 Ny kunng
@@ -763,18 +763,16 @@
         
-  
 %3C/Button
@@ -787,18 +787,16 @@
     
- 
- 
 %3C/Link%3E%0A
     
@@ -791,18 +791,16 @@
 %3C/Link%3E%0A
-  
         
@@ -816,15 +816,11 @@
     
-  
 )%7D%0A
-  
     
@@ -830,20 +830,15 @@
 iv%3E%0A
-  
   );%0A
-  %7D%0A
 %7D
+;
 %0A%0Aex

fix AnnouncementInLine (flow++)