Skip to content

Commit

Permalink
Disable old points visualization since its deps aren't working
Browse files Browse the repository at this point in the history
  • Loading branch information
Redande committed Jun 14, 2023
1 parent 23227af commit 7272404
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 107 deletions.
136 changes: 68 additions & 68 deletions src/partials/Points/PointsImpl.js
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 {
email
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 {
// email
// 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)
74 changes: 37 additions & 37 deletions src/partials/Points/index.js
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>
// )
// }
// }
4 changes: 2 additions & 2 deletions src/partials/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import RegistrationLink from "./RegistrationLink"
import RegistrationLink2 from "./RegistrationLink2"
import OnlyForCourseVariant from "./OnlyForCourseVariant"
import OnlyForNotLoggedIn from "./OnlyForNotLoggedIn"
import Points from "./Points"
// import Points from "./Points"
import WorkshopSchedule from "./WorkshopSchedule"

const mapping = {
Expand Down Expand Up @@ -108,7 +108,7 @@ const mapping = {
h5: H5,
h6: H6,
hr: Hr,
points: Points,
// points: Points,
}

export default () => {
Expand Down

0 comments on commit 7272404

Please sign in to comment.