-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathProjectDetails.jsx
More file actions
46 lines (40 loc) · 1.88 KB
/
ProjectDetails.jsx
File metadata and controls
46 lines (40 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import ProjectFetchingError from 'src/components/molecules/ErrorComponent/ProjectFetchingError';
import { useParams } from 'react-router-dom';
import { ListGroup } from 'react-bootstrap';
import { useProject } from "../../../lib/hooks/project";
import Loader from "../../molecules/Loader/Loader";
import { ProjectCard, CardHeader, CardBody, ListGroupItem, ListGroupItemLabel } from "./styled";
const ProjectDetails = () => {
const { projectId } = useParams();
const { project, loading, error } = useProject({ projectId });
const isProjectIdNull = project.id === undefined;
console.log(isProjectIdNull)
console.log(project.id)
return (
<>
{loading && (
<Loader />
)}
{!loading && error && (
<ProjectFetchingError errorMessage={error.message} />
)}
{!loading && !error && isProjectIdNull && (
<ProjectFetchingError errorMessage='404! No Project Has Benn Found' />
)}
{!loading && !error && !isProjectIdNull && (
<ProjectCard>
<CardHeader>Project Details</CardHeader>
<CardBody>
<ListGroup className="list-group-flush">
<ListGroupItem><ListGroupItemLabel>ID: </ListGroupItemLabel>{project.id}</ListGroupItem>
<ListGroupItem><ListGroupItemLabel>Name: </ListGroupItemLabel>{project.name}</ListGroupItem>
<ListGroupItem><ListGroupItemLabel>Description: </ListGroupItemLabel>{project.description}</ListGroupItem>
<ListGroupItem><ListGroupItemLabel>Created-At: </ListGroupItemLabel>{project.createdAt}</ListGroupItem>
</ListGroup>
</CardBody>
</ProjectCard>
)}
</>
);
};
export default ProjectDetails;