2020-04-10 04:40:22 +02:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
import styled from 'styled-components/macro';
|
2020-05-27 02:53:31 +02:00
|
|
|
import GlobalTopNavbar from 'App/TopNavbar';
|
2020-04-10 05:27:57 +02:00
|
|
|
import { useGetProjectsQuery } from 'shared/generated/graphql';
|
2020-04-10 04:40:22 +02:00
|
|
|
|
|
|
|
import ProjectGridItem from 'shared/components/ProjectGridItem';
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import Navbar from 'App/Navbar';
|
|
|
|
|
|
|
|
const MainContent = styled.div`
|
|
|
|
padding: 0 0 50px 80px;
|
|
|
|
height: 100%;
|
|
|
|
background: #262c49;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const ProjectGrid = styled.div`
|
|
|
|
width: 60%;
|
2020-04-20 05:02:55 +02:00
|
|
|
max-width: 780px;
|
2020-04-10 04:40:22 +02:00
|
|
|
margin: 25px auto;
|
|
|
|
display: flex;
|
2020-04-20 05:02:55 +02:00
|
|
|
flex-wrap: wrap;
|
2020-04-10 04:40:22 +02:00
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
`;
|
2020-04-20 05:02:55 +02:00
|
|
|
|
|
|
|
const ProjectLink = styled(Link)`
|
|
|
|
flex: 1 0 33%;
|
|
|
|
margin-bottom: 20px;
|
2020-04-10 04:40:22 +02:00
|
|
|
`;
|
2020-04-20 05:02:55 +02:00
|
|
|
|
2020-04-10 04:40:22 +02:00
|
|
|
const Projects = () => {
|
2020-04-10 05:27:57 +02:00
|
|
|
const { loading, data } = useGetProjectsQuery();
|
2020-04-10 04:40:22 +02:00
|
|
|
if (loading) {
|
2020-04-10 18:31:29 +02:00
|
|
|
return (
|
|
|
|
<>
|
2020-04-20 05:02:55 +02:00
|
|
|
<span>loading</span>
|
2020-04-10 18:31:29 +02:00
|
|
|
</>
|
|
|
|
);
|
2020-04-10 04:40:22 +02:00
|
|
|
}
|
|
|
|
if (data) {
|
2020-04-20 05:02:55 +02:00
|
|
|
const { projects } = data;
|
2020-04-10 04:40:22 +02:00
|
|
|
return (
|
2020-05-27 02:53:31 +02:00
|
|
|
<>
|
2020-05-31 07:15:10 +02:00
|
|
|
<GlobalTopNavbar onSaveProjectName={() => {}} name={null} />
|
2020-05-27 02:53:31 +02:00
|
|
|
<ProjectGrid>
|
|
|
|
{projects.map(project => (
|
|
|
|
<ProjectLink key={project.id} to={`/projects/${project.id}`}>
|
|
|
|
<ProjectGridItem
|
|
|
|
project={{ ...project, projectID: project.id, teamTitle: project.team.name, taskGroups: [] }}
|
|
|
|
/>
|
|
|
|
</ProjectLink>
|
|
|
|
))}
|
|
|
|
</ProjectGrid>
|
|
|
|
</>
|
2020-04-10 04:40:22 +02:00
|
|
|
);
|
|
|
|
}
|
2020-04-20 05:02:55 +02:00
|
|
|
return <div>Error!</div>;
|
2020-04-10 04:40:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Projects;
|