[e6c2521] | 1 | import React, { useEffect } from "react";
|
---|
| 2 | import { useState } from "react";
|
---|
| 3 | import Navigation from "../Components/Layout/Navbar/Navigation";
|
---|
| 4 | import { Row, Col, Container, Button, Modal } from "react-bootstrap";
|
---|
| 5 | import { IoBusinessSharp } from "react-icons/io5";
|
---|
| 6 | import RegisterBusinessForm from "../Components/Forms/RegisterBusinessForm";
|
---|
| 7 | import useGet from "../Components/Hooks/useGet";
|
---|
[07f4e8b] | 8 | import {Navigate, useNavigate} from "react-router-dom";
|
---|
| 9 | import {useAuth} from "../Components/Context/AuthContext";
|
---|
[e6c2521] | 10 |
|
---|
| 11 | const NoBusinessRegisteredError = (props) => {
|
---|
| 12 | const [show, setShow] = useState(false);
|
---|
| 13 | const [changed, setChanged] = useState(0);
|
---|
[07f4e8b] | 14 | const Auth = useAuth();
|
---|
| 15 | const isLoggedIn = Auth.userIsAuthenticated();
|
---|
[0f5aa27] | 16 | const userId = Auth.getUser().userId
|
---|
[e6c2521] | 17 | const [registered, setRegistered] = useState(false);
|
---|
| 18 | let checked = false;
|
---|
| 19 | const navigator = useNavigate()
|
---|
| 20 |
|
---|
| 21 | const handleClose = () => setShow(false);
|
---|
| 22 | const handleShow = (e) => {
|
---|
| 23 | e.preventDefault();
|
---|
| 24 | setShow(true);
|
---|
| 25 | };
|
---|
| 26 |
|
---|
| 27 | const { data: firma, isLoading: firmaIsLoading, getData: getFirmi} = useGet("/business/" + userId + "/unapproved", changed)
|
---|
[0f5aa27] | 28 | const { data, isLoading, getData} = useGet("/" + userId + "/hasBusiness")
|
---|
| 29 |
|
---|
[e6c2521] | 30 |
|
---|
| 31 | useEffect(() => {
|
---|
| 32 |
|
---|
| 33 | console.log(firma)
|
---|
| 34 | setRegistered(() => {
|
---|
| 35 | return firma !== null && firma.length > 0
|
---|
| 36 | })
|
---|
| 37 |
|
---|
| 38 | }, [firmaIsLoading])
|
---|
| 39 |
|
---|
| 40 | // useEffect(() => {
|
---|
| 41 |
|
---|
| 42 | // setRegistered(() => {
|
---|
| 43 | // console.log(data)
|
---|
| 44 | // return data !== null && data
|
---|
| 45 | // })
|
---|
| 46 |
|
---|
| 47 | // }, [isLoading])
|
---|
| 48 |
|
---|
| 49 |
|
---|
[07f4e8b] | 50 | if(!isLoggedIn)
|
---|
| 51 | {
|
---|
| 52 | return <Navigate to={'/login'}/>
|
---|
| 53 | }
|
---|
[e6c2521] | 54 |
|
---|
[0f5aa27] | 55 | !isLoading && data && navigator("/resources/hotel")
|
---|
[e6c2521] | 56 |
|
---|
| 57 |
|
---|
| 58 | return (
|
---|
| 59 | <>
|
---|
| 60 | <Navigation></Navigation>
|
---|
| 61 | {!registered && (
|
---|
| 62 | <Container>
|
---|
| 63 | <Row className="mt-5 mb-3">
|
---|
| 64 | <Col>
|
---|
| 65 | <h3 style={{ color: "#159895" }}>
|
---|
| 66 | За да менаџирате со Вашите ресурси мора да имате регистрирано
|
---|
| 67 | фирма одобрена од администраторот!
|
---|
| 68 | </h3>
|
---|
| 69 | </Col>
|
---|
| 70 | </Row>
|
---|
| 71 | <Row>
|
---|
| 72 | <Col>
|
---|
| 73 | <Button
|
---|
| 74 | type="button"
|
---|
| 75 | onClick={handleShow}
|
---|
| 76 | style={{
|
---|
| 77 | backgroundColor: "#159895",
|
---|
| 78 | border: "2px solid white",
|
---|
| 79 | }}
|
---|
| 80 | size="lg"
|
---|
| 81 | >
|
---|
| 82 | <span className="ikona my-1" color="white">
|
---|
| 83 | <IoBusinessSharp style={{ color: "white" }} />
|
---|
| 84 | </span>
|
---|
| 85 | <span className="ikona mx-3">Регистрирај фирма</span>
|
---|
| 86 | </Button>
|
---|
| 87 | </Col>
|
---|
| 88 | </Row>
|
---|
| 89 | </Container>
|
---|
| 90 | )}
|
---|
| 91 | {registered && (
|
---|
| 92 | <>
|
---|
| 93 | <Container>
|
---|
| 94 | <Row className="mt-5">
|
---|
| 95 | <Col className="mb-5">
|
---|
| 96 | <h3 className="mb-5" style={{ color: "#159895" }}>
|
---|
| 97 | {" "}
|
---|
| 98 | За да менаџирате со Вашите ресурси мора да имате регистрирано
|
---|
| 99 | фирма одобрена од администраторот!
|
---|
| 100 | </h3>
|
---|
| 101 | <h4 style={{ color: "#159895" }}>
|
---|
| 102 | Тековни неодобрени регистрации
|
---|
| 103 | </h4>
|
---|
| 104 | </Col>
|
---|
| 105 | </Row>
|
---|
| 106 | <Row>
|
---|
| 107 | <Container className="w-75">
|
---|
| 108 | <table className="table table-hover">
|
---|
| 109 | <thead>
|
---|
| 110 | <tr>
|
---|
| 111 | <th scope="col">Ред. бр.</th>
|
---|
| 112 | <th scope="col">Име на фирма</th>
|
---|
| 113 | <th scope="col">Адреса</th>
|
---|
| 114 | <th scope="col">Даночен број</th>
|
---|
| 115 | <th scope="col">Одговорно лице</th>
|
---|
| 116 | </tr>
|
---|
| 117 | </thead>
|
---|
| 118 | <tbody>
|
---|
| 119 | {!firmaIsLoading && firma.map((f, i) => { return <tr key={f.businessId}>
|
---|
| 120 | <th scope="row">{i + 1}</th>
|
---|
| 121 | <td>{f.name}</td>
|
---|
| 122 | <td>{f.address}</td>
|
---|
| 123 | <td>{f.edbs}</td>
|
---|
| 124 | <td>{f.user.name + " " + f.user.surname}</td>
|
---|
| 125 | </tr>})}
|
---|
| 126 | </tbody>
|
---|
| 127 | </table>
|
---|
| 128 | </Container>
|
---|
| 129 | </Row>
|
---|
| 130 | </Container>
|
---|
| 131 | </>
|
---|
| 132 | )}
|
---|
| 133 |
|
---|
| 134 | <Modal show={show} onHide={handleClose}>
|
---|
| 135 | <Modal.Header closeButton>
|
---|
| 136 | <Modal.Title style={{ color: "#159895" }}>
|
---|
| 137 | Регистрација на фирма
|
---|
| 138 | </Modal.Title>
|
---|
| 139 | </Modal.Header>
|
---|
| 140 | <Modal.Body>
|
---|
| 141 | <RegisterBusinessForm hide={handleClose} edit={setChanged}></RegisterBusinessForm>
|
---|
| 142 | </Modal.Body>
|
---|
| 143 | </Modal>
|
---|
| 144 | </>
|
---|
| 145 | );
|
---|
| 146 | };
|
---|
| 147 |
|
---|
| 148 | export default NoBusinessRegisteredError;
|
---|