Skip to content

Commit 8148ee0

Browse files
author
Roshan Jossy
authored
Merge pull request #11 from firstcontributions/profile
add user details
2 parents 4493d79 + c3f1c3b commit 8148ee0

22 files changed

+576
-134
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"relay": "relay-compiler"
1010
},
1111
"dependencies": {
12+
"@react-icons/all-files": "^4.1.0",
1213
"next": "12.0.10",
1314
"node-fetch": "^3.2.0",
1415
"react": "17.0.2",

schema/schema.graphql

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ type BadgeEdge {
4545
cursor: String!
4646
}
4747

48+
type GitContributionStats {
49+
issues: Int!
50+
pullRequests: Int!
51+
}
52+
53+
input GitContributionStatsInput {
54+
issues: Int!
55+
pullRequests: Int!
56+
}
57+
4858
type Issue implements Node {
4959
body: String!
5060
commentCount: Int!
@@ -68,27 +78,47 @@ type IssueEdge {
6878
cursor: String!
6979
}
7080

81+
type Reputation {
82+
value: Float!
83+
}
84+
85+
input ReputationInput {
86+
value: Float!
87+
}
88+
7189
type User implements Node {
90+
avatar: String!
7291
badges(first: Int, last: Int, after: String, before: String): BadgesConnection!
92+
bio: String!
93+
gitContributionStats: GitContributionStats!
7394
handle: String!
7495
id: ID!
7596
issuesFromLastRepo(first: Int, last: Int, after: String, before: String): IssuesConnection!
7697
issuesFromOtherRecentRepos(first: Int, last: Int, after: String, before: String): IssuesConnection!
7798
name: String!
7899
relevantIssues(first: Int, last: Int, after: String, before: String): IssuesConnection!
100+
reputation: Reputation!
79101
timeCreated: Time!
80102
timeUpdated: Time!
81103
}
82104

83-
input CreateUserInput {
105+
input UserInput {
106+
avatar: String!
107+
bio: String!
108+
gitContributionStats: GitContributionStatsInput!
84109
handle: String!
85-
name: String!
110+
name: String!
111+
reputation: ReputationInput!
86112
}
87-
88113
input UpdateUserInput {
89-
name: String!
114+
id: ID!
115+
bio: String
116+
gitContributionStats: GitContributionStatsInput
117+
name: String
118+
reputation: ReputationInput
90119
}
91120

92121
type Mutation {
93-
createUser(user: CreateUserInput!): User!
122+
createUser(user:UserInput!): User!
123+
updateUser(user: UpdateUserInput!): User!
94124
}

src/components/Badge.tsx

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/components/Layout.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React, { ReactNode } from "react";
2+
3+
type LayoutProps = {
4+
sidebarContentLeft: ReactNode
5+
children: ReactNode
6+
sidebarContentRight: ReactNode
7+
}
8+
9+
export default function Layout ({sidebarContentLeft, children, sidebarContentRight}: LayoutProps) {
10+
return (
11+
<div className="mx-auto bg-gray-100 p-4 px-20">
12+
<div className="grid grid-cols-9 gap-10">
13+
<aside className="col-span-2">
14+
{sidebarContentLeft}
15+
</aside>
16+
<main className="col-span-5">
17+
{children}
18+
</main>
19+
<aside className="col-span-2">
20+
{sidebarContentRight}
21+
</aside>
22+
</div>
23+
<div>
24+
</div>
25+
</div>
26+
)
27+
}

src/components/Login.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Button from "./Button";
2+
import Card from "./Card";
3+
4+
const Login = () => (
5+
<Card>
6+
<a href={encodeURI("http://api.firstcontributions.com/v1/auth/redirect?origin=http://app.firstcontributions.com")}>
7+
<Button>
8+
Login with github
9+
</Button>
10+
</a>
11+
</Card>
12+
)
13+
14+
export default Login

src/components/UserDetails.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { graphql, useFragment } from "react-relay"
2+
import CircularProgress from './CircularProgress'
3+
import { DiAndroid } from '@react-icons/all-files/di/DiAndroid'
4+
5+
const Badge = ({badge}: any) => {
6+
const data = useFragment(
7+
graphql`
8+
fragment Badge_node on Badge {
9+
displayName
10+
progressPercentageToNextLevel
11+
}
12+
`, badge
13+
)
14+
15+
return (
16+
<>
17+
<h4>{data.displayName}</h4>
18+
<DiAndroid className="w-10 h-10 text-green-600 "/>
19+
</>
20+
)
21+
}
22+
23+
export default Badge

src/components/BadgeList.tsx renamed to src/components/UserDetails/Badges/BadgeList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useFragment, graphql, usePaginationFragment } from "react-relay"
2-
import { Badge_node$data } from "../queries/__generated__/Badge_node.graphql"
2+
import { Badge_node$data } from "../../../queries/__generated__/Badge_node.graphql"
33
import Badge from "./Badge"
44

55
const BadgeList = ({user}: any) => {

src/components/UserDetails/Bio.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { useState } from "react";
2+
import { graphql, useFragment, useMutation } from "react-relay";
3+
4+
5+
const Bio = ({user}) => {
6+
7+
const data = useFragment(
8+
graphql`
9+
fragment Bio_user on User {
10+
id
11+
bio
12+
}
13+
`, user
14+
);
15+
16+
const [bio, setBio] = useState(data.bio);
17+
18+
const [commitMutation, isMutationInFlight] = useMutation(
19+
graphql`
20+
mutation BioUpdateMutation($input: UpdateUserInput!) {
21+
updateUser(user:$input) {
22+
id
23+
bio
24+
}
25+
}
26+
`
27+
);
28+
const onChange = (evt) => setBio(evt.target.textContent);
29+
const onSubmit = () => {
30+
console.log(bio);
31+
commitMutation({
32+
variables: {
33+
input: {id: data.id, bio: bio},
34+
},
35+
})
36+
}
37+
38+
return (
39+
<p contentEditable={true} onInput={onChange} onBlur={onSubmit}>
40+
{data.bio}
41+
</p>
42+
)
43+
}
44+
45+
46+
export default Bio

0 commit comments

Comments
 (0)