forked from rage/java-programming
-
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.
Disable old points visualization since its deps aren't working
- Loading branch information
Showing
3 changed files
with
107 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,76 @@ | ||
import React from "react" | ||
import withSimpleErrorBoundary from "../../util/withSimpleErrorBoundary" | ||
import CourseSettings from "../../../course-settings" | ||
// import React from "react" | ||
// import withSimpleErrorBoundary from "../../util/withSimpleErrorBoundary" | ||
// import CourseSettings from "../../../course-settings" | ||
|
||
import { useQuery } from "@apollo/client/react" | ||
import { gql } from "apollo-boost" | ||
import { Button } from "@material-ui/core" | ||
import OverallPoints from "./OverallPoints" | ||
// import { useQuery } from "@apollo/client/react" | ||
// import { gql } from "apollo-boost" | ||
// import { Button } from "@material-ui/core" | ||
// import OverallPoints from "./OverallPoints" | ||
|
||
const PROGRESS = gql` | ||
{ | ||
currentUser { | ||
progress(course_id: "59314cb4-a9ca-43c9-b9a7-58c19325b44c") { | ||
course { | ||
id | ||
name | ||
} | ||
user_course_progress { | ||
id | ||
progress | ||
} | ||
user_course_service_progresses { | ||
id | ||
progress | ||
service { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
` | ||
// const PROGRESS = gql` | ||
// { | ||
// currentUser { | ||
// progress(course_id: "59314cb4-a9ca-43c9-b9a7-58c19325b44c") { | ||
// course { | ||
// id | ||
// name | ||
// } | ||
// user_course_progress { | ||
// id | ||
// progress | ||
// } | ||
// user_course_service_progresses { | ||
// id | ||
// progress | ||
// service { | ||
// id | ||
// name | ||
// } | ||
// } | ||
// } | ||
// } | ||
// } | ||
// ` | ||
|
||
const Points = (props) => { | ||
const course = props.course || CourseSettings.default.slug | ||
const { data, loading, error, refetch } = useQuery(PROGRESS) | ||
// const Points = (props) => { | ||
// const course = props.course || CourseSettings.default.slug | ||
// const { data, loading, error, refetch } = useQuery(PROGRESS) | ||
|
||
if (loading) { | ||
return <>Loading...</> | ||
} | ||
// if (loading) { | ||
// return <>Loading...</> | ||
// } | ||
|
||
if (error) { | ||
return <>Error while fetching progress: {error}</> | ||
} | ||
// if (error) { | ||
// return <>Error while fetching progress: {error}</> | ||
// } | ||
|
||
if (!data || !data.currentUser) { | ||
return ( | ||
<> | ||
<Button | ||
onClick={() => { | ||
refetch() | ||
}} | ||
> | ||
Refresh | ||
</Button> | ||
<p>Please log in to see your points.</p> | ||
</> | ||
) | ||
} | ||
// if (!data || !data.currentUser) { | ||
// return ( | ||
// <> | ||
// <Button | ||
// onClick={() => { | ||
// refetch() | ||
// }} | ||
// > | ||
// Refresh | ||
// </Button> | ||
// <p>Please log in to see your points.</p> | ||
// </> | ||
// ) | ||
// } | ||
|
||
const points = data.currentUser.progress.user_course_progress.progress[0] | ||
const courseName = data.currentUser.progress.course.name | ||
return ( | ||
<> | ||
<OverallPoints | ||
refetch={refetch} | ||
courseName={courseName} | ||
progress={data.currentUser.progress} | ||
/> | ||
</> | ||
) | ||
} | ||
// const points = data.currentUser.progress.user_course_progress.progress[0] | ||
// const courseName = data.currentUser.progress.course.name | ||
// return ( | ||
// <> | ||
// <OverallPoints | ||
// refetch={refetch} | ||
// courseName={courseName} | ||
// progress={data.currentUser.progress} | ||
// /> | ||
// </> | ||
// ) | ||
// } | ||
|
||
export default withSimpleErrorBoundary(Points) | ||
// export default withSimpleErrorBoundary(Points) |
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 |
---|---|---|
@@ -1,38 +1,38 @@ | ||
import React from "react" | ||
import PointsImpl from "./PointsImpl" | ||
import ApolloClient from "apollo-boost" | ||
import { ApolloProvider } from "@apollo/client/react" | ||
import { accessToken } from "../../services/moocfi" | ||
// import React from "react" | ||
// import PointsImpl from "./PointsImpl" | ||
// import ApolloClient from "apollo-boost" | ||
// import { ApolloProvider } from "@apollo/client/react" | ||
// import { accessToken } from "../../services/moocfi" | ||
|
||
export default class Points extends React.Component { | ||
state = { | ||
render: false, | ||
} | ||
componentDidMount() { | ||
this.setState({ render: true }) | ||
} | ||
render() { | ||
if (!this.state.render) { | ||
return <div>Loading...</div> | ||
} | ||
const apolloClient = new ApolloClient({ | ||
uri: "https://www.mooc.fi/api", | ||
request: async (operation) => { | ||
const token = accessToken() | ||
if (!token) { | ||
return | ||
} | ||
operation.setContext({ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}) | ||
}, | ||
}) | ||
return ( | ||
<ApolloProvider client={apolloClient}> | ||
<PointsImpl />{" "} | ||
</ApolloProvider> | ||
) | ||
} | ||
} | ||
// export default class Points extends React.Component { | ||
// state = { | ||
// render: false, | ||
// } | ||
// componentDidMount() { | ||
// this.setState({ render: true }) | ||
// } | ||
// render() { | ||
// if (!this.state.render) { | ||
// return <div>Loading...</div> | ||
// } | ||
// const apolloClient = new ApolloClient({ | ||
// uri: "https://www.mooc.fi/api", | ||
// request: async (operation) => { | ||
// const token = accessToken() | ||
// if (!token) { | ||
// return | ||
// } | ||
// operation.setContext({ | ||
// headers: { | ||
// Authorization: `Bearer ${token}`, | ||
// }, | ||
// }) | ||
// }, | ||
// }) | ||
// return ( | ||
// <ApolloProvider client={apolloClient}> | ||
// <PointsImpl />{" "} | ||
// </ApolloProvider> | ||
// ) | ||
// } | ||
// } |
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