-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ Added route graphql list all
- Loading branch information
Showing
17 changed files
with
736 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { BrowserRouter, Route, Switch } from "react-router-dom"; | ||
import { ListAllPage } from "./pages/listAll.page"; | ||
import { ProjectManangerPage } from "./pages/project.page"; | ||
|
||
export function Router({ children }) { | ||
return ( | ||
<BrowserRouter> | ||
{children} | ||
<div className="container p4"> | ||
<Switch> | ||
<Route exact path="/" component={ListAllPage} /> | ||
<Route | ||
exact | ||
path="/mananger-project" | ||
component={ProjectManangerPage} | ||
/> | ||
</Switch> | ||
</div> | ||
</BrowserRouter> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from "react"; | ||
|
||
export const LinkCustom = ({ name, href }) => ( | ||
<a href={href} className="card-link"> | ||
{name} | ||
</a> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from "react"; | ||
import { Link } from "react-router-dom"; | ||
|
||
export const Navigation = () => ( | ||
<nav className="navbar navbar-expand-lg navbar-dark bg-dark"> | ||
<div className="container-fluid"> | ||
<Link className="navbar-brand" to="/"> | ||
<img src="https://www.senixcode.dev/static/my-logo-senixcode.svg" alt="" width="30" height="24"></img> | ||
</Link> | ||
<button | ||
className="navbar-toggler" | ||
type="button" | ||
data-bs-toggle="collapse" | ||
data-bs-target="#navbarNavAltMarkup" | ||
aria-controls="navbarNavAltMarkup" | ||
aria-expanded="false" | ||
aria-label="Toggle navigation" | ||
> | ||
<span className="navbar-toggler-icon"></span> | ||
</button> | ||
<div className="collapse navbar-collapse" id="navbarNavAltMarkup"> | ||
<div className="navbar-nav"> | ||
<Link className="nav-link active" aria-current="page" to="/"> | ||
Home | ||
</Link> | ||
<Link className="nav-link" to="/mananger-project"> | ||
Project | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</nav> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from "react"; | ||
import { LinkCustom } from "../atoms/LinkCustom"; | ||
|
||
export const Card = ({ title, subtitle, description, links,language }) => { | ||
return ( | ||
<div className="card" style={{ maxWidth: "16em" }}> | ||
<div className="card-body"> | ||
<Title title={title}/> | ||
<h6 className="card-subtitle mb-2 text-muted">{!language ? subtitle: `${subtitle} - ${language}` }</h6> | ||
<Description description={description} /> | ||
<Links links={links} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const Title = ({ title }) => { | ||
if (!title) return <span></span>; | ||
return <h5 className="card-title">{title}</h5> | ||
}; | ||
|
||
const Description = ({ description }) => { | ||
if (!description) return <span></span>; | ||
return <p className="card-text">{description}</p>; | ||
}; | ||
|
||
const Links = ({ links }) => { | ||
if (!links) return <span></span>; | ||
return ( | ||
<> | ||
{links.map(({ id, name, href }) => ( | ||
<LinkCustom key={id} name={name} href={href} /> | ||
))} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export const fieldLanguage = { | ||
language: "language", | ||
}; | ||
|
||
export const fieldsProjects = { | ||
title: "title", | ||
subtitle: "__typename", | ||
description: "summary", | ||
links: "linksParse", | ||
}; | ||
|
||
export const fieldsAboutMe = { | ||
title: false, | ||
subtitle: "__typename", | ||
description: "name", | ||
links: false, | ||
}; | ||
|
||
export const fieldsTopics = { | ||
title: "name", | ||
subtitle: "__typename", | ||
description: false, | ||
links: false, | ||
}; | ||
|
||
export const fieldsLinks = { | ||
title: "name", | ||
subtitle: "__typename", | ||
description: "href", | ||
links: false, | ||
language: "icon", | ||
}; | ||
export const fieldsRoutes = { | ||
title: "title", | ||
subtitle: "__typename", | ||
description: "path", | ||
links: false, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {gql} from "apollo-boost" | ||
export const PROJECT_FIELDS = gql` | ||
fragment project_data on Project{ | ||
id | ||
title | ||
titleSeo | ||
summary | ||
descriptionParse | ||
topicsParse { | ||
id | ||
name | ||
} | ||
linksParse { | ||
id | ||
name | ||
href | ||
} | ||
language | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { gql } from "apollo-boost"; | ||
export const GET_ABOUTME = gql` | ||
{ | ||
allAboutMe { | ||
id | ||
name | ||
language | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { gql } from "apollo-boost"; | ||
export const GET_LINKS = gql` | ||
{ | ||
links { | ||
id | ||
name | ||
href | ||
icon | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PROJECT_FIELDS } from "../fragments/projectFields"; | ||
import { gql } from "apollo-boost"; | ||
export const GET_PROJECTS = gql` | ||
${PROJECT_FIELDS} | ||
{ | ||
projects { | ||
...project_data | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { gql } from "apollo-boost"; | ||
export const GET_ROUTES = gql` | ||
{ | ||
routes { | ||
id | ||
path | ||
title | ||
description | ||
language | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { gql } from "apollo-boost"; | ||
export const GET_TOPICS = gql` | ||
{ | ||
topics { | ||
id | ||
name | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React from "react"; | ||
import { useQuery } from "@apollo/react-hooks"; | ||
import { GET_PROJECTS } from "../graphql/querys/projectQuery"; | ||
import { GET_ABOUTME } from "../graphql/querys/aboutMeQuery"; | ||
import { Card } from "../componentes/containers/Card"; | ||
import { fieldLanguage, fieldsAboutMe, fieldsLinks, fieldsProjects, fieldsRoutes, fieldsTopics } from "../componentes/helpers/fieldsCardsHome"; | ||
import { GET_TOPICS } from "../graphql/querys/topicsQuery"; | ||
import { GET_LINKS } from "../graphql/querys/linksQuerys"; | ||
import { GET_ROUTES } from "../graphql/querys/routesQuery"; | ||
|
||
|
||
export const ListAllPage = () => { | ||
const { | ||
loading: loadingAboutme, | ||
error: errorAboutme, | ||
data: dataAboutMe, | ||
} = useQuery(GET_ABOUTME); | ||
const { | ||
loading: loadingProjects, | ||
error: errorProjects, | ||
data: dataProjects, | ||
} = useQuery(GET_PROJECTS); | ||
|
||
const { | ||
loading: loadingTopics, | ||
error:errorTopics, | ||
data: dataTopics, | ||
} = useQuery(GET_TOPICS); | ||
|
||
const { | ||
loading: loadingLinks, | ||
error:errorLinks, | ||
data: dataLinks, | ||
} = useQuery(GET_LINKS); | ||
|
||
const { | ||
loading: loadingRoutes, | ||
error:errorRoutes, | ||
data: dataRoutes, | ||
} = useQuery(GET_ROUTES); | ||
|
||
if (loadingAboutme || loadingProjects || loadingTopics || loadingLinks || loadingRoutes) return <p>Loading Message</p>; | ||
if (errorAboutme || errorProjects || errorTopics || errorLinks || errorRoutes) return <p>Error!!</p>; | ||
|
||
|
||
return ( | ||
<> | ||
<Cards | ||
items={dataAboutMe.allAboutMe} | ||
field={{ ...fieldsAboutMe, ...fieldLanguage }} | ||
/> | ||
<Cards | ||
items={dataProjects.projects} | ||
field={{ ...fieldsProjects, ...fieldLanguage }} | ||
/> | ||
<Cards | ||
items={dataTopics.topics} | ||
field={fieldsTopics} | ||
/> | ||
|
||
<Cards | ||
items={dataLinks.links} | ||
field={fieldsLinks} | ||
/> | ||
<Cards | ||
items={dataRoutes.routes} | ||
field={{ ...fieldsRoutes, ...fieldLanguage }} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
const Cards = ({ items, field }) => { | ||
if (!items) return <p>Error items Cards</p>; | ||
return ( | ||
<div className="row py-2"> | ||
{items.map((item) => ( | ||
<div key={item.id} className="p-1"> | ||
<Card | ||
title={field.title ? item[field.title] : false} | ||
subtitle={item[field.subtitle]} | ||
language={field.language ? item[field.language]: false} | ||
description={field.description ? item[field.description] : false} | ||
links={field.links ? item[field.links] : false} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from "react" | ||
|
||
export const ProjectManangerPage = () => ( | ||
<h1>Project Mananger</h1> | ||
) |
Oops, something went wrong.