taskcafe/web/src/Projects/index.tsx

56 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-04-10 04:40:22 +02:00
import React, { useState } from 'react';
import styled from 'styled-components/macro';
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 = () => {
const { loading, data } = useGetProjectsQuery();
2020-04-10 04:40:22 +02:00
console.log(loading, data);
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-04-20 05:02:55 +02:00
<ProjectGrid>
{projects.map(project => (
<ProjectLink key={project.projectID} to={`/projects/${project.projectID}`}>
<ProjectGridItem project={{ ...project, 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;