Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 4a7bae81

Přidáno uživatelem Jaroslav Hrubý před asi 2 roky(ů)

Documents upload implemented, connected to REST API

Zobrazit rozdíly:

webapp/pages/documents/admin/index.tsx
8 8
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9 9
import { LoggedUserContext } from '../../../contexts/LoggedUserContext';
10 10
import { MainLayout } from '../../../layouts/MainLayout';
11
import AddDocumentModal from '../../../components/modals/AddDocumentModal';
11 12

  
12 13
function AdminDocumentPage() {
13 14
    const redirecting = useUnauthRedirect('/login');
14 15
    const { logout, role } = useContext(LoggedUserContext);
16
    const [visible, setVisible] = React.useState(false);
15 17
    const router = useRouter();
16 18

  
17 19
    useEffect(() => {
......
21 23
    }, [logout, redirecting, role, router]);
22 24

  
23 25
    const showModal = () => {
24
        // TODO show AddDocument component
26
        setVisible(true);
27
    };
28

  
29
    const hideModal = () => {
30
        setVisible(false);
25 31
    };
26 32

  
27 33
    return redirecting || role !== 'ADMINISTRATOR' ? null : (
......
32 38
            <Button type={'primary'} onClick={showModal}>
33 39
                Nahrát dokument
34 40
            </Button>
41
            {visible && <AddDocumentModal onCancel={hideModal} />}
35 42
        </MainLayout>
36 43
    );
37 44
}

Také k dispozici: Unified diff