Skip to content

Commit

Permalink
Merge pull request #75 from stevebrownlee/develop
Browse files Browse the repository at this point in the history
Prompt new learner to provide first and last name if it wasn't added to Github profile
  • Loading branch information
stevebrownlee authored Jul 8, 2024
2 parents 34700a2 + 3b0c551 commit 0c486de
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 105 deletions.
4 changes: 0 additions & 4 deletions src/components/StudentViews.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { LearningGoals } from "./info/Goals"
import { Repos } from "./info/Repos"
import { ServerAssessment } from "./info/ServerSideRequirements"
import { StudentDashboard } from "./dashboard/student/StudentDashboard.js"
import { RulesOfEngagment } from "./info/RulesOfEngagment.js"

export const StudentViews = () => {
return <>
Expand All @@ -24,9 +23,6 @@ export const StudentViews = () => {
<Route exact path="/repos">
<Repos />
</Route>
<Route exact path="/roe">
<RulesOfEngagment />
</Route>
<Route exact path="/goals">
<LearningGoals />
</Route>
Expand Down
1 change: 0 additions & 1 deletion src/components/auth/Callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export const Callback = () => {
<div className="moon"></div>
<div className="up"></div>
</div>

</article>
)
}
1 change: 0 additions & 1 deletion src/components/auth/simpleAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const simpleAuth = () => {
localStorage.setItem("activeCohort", activeCohort)
} catch (error) {
localStorage.setItem("activeCohort", null)

}
})
}
Expand Down
15 changes: 15 additions & 0 deletions src/components/dashboard/Dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@
.dashboard--overview {
display: block;
}

.info {
margin-bottom: 1rem;
}

.info__body--cohort {
display: flex;
justify-content: space-around;
Expand All @@ -97,12 +99,15 @@
.studentassessments {
flex-direction: column;
}

.info__body--cohort {
display: block;
}

.studentAccounts {
display: block;
}

.studentAccount__header {
margin-block-start: 1rem;
margin-top: 1rem;
Expand Down Expand Up @@ -349,3 +354,13 @@
.shortcut__description {
padding: 0 0 0 1.5rem;
}

.fullCenter {
margin: 0;
padding: 10rem 0 0 0;
height: 100%;
display: flex;
flex-direction: column;
justify-content: start;
align-items: center;
}
57 changes: 54 additions & 3 deletions src/components/dashboard/student/StudentDashboard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useContext, useEffect, useState } from "react"
import { Flex, Text, Button, TextField, TextFieldInput } from '@radix-ui/themes'
import { useHistory } from "react-router-dom"

import simpleAuth from "../../auth/simpleAuth"
import Settings from "../../Settings"
import { fetchIt } from "../../utils/Fetch"
Expand All @@ -14,7 +16,8 @@ export const StudentDashboard = () => {
const { getCurrentUser, getProfile } = simpleAuth()
const [user, setUser] = useState({})
// eslint-disable-next-line
const [briggs, setBriggs] = useState("")
const [firstName, setFirstName] = useState("")
const [lastName, setLastName] = useState("")

const history = useHistory()

Expand All @@ -24,10 +27,58 @@ export const StudentDashboard = () => {
})
}, [])

return <main>
<article className="dashboard--overview">
const saveName = () => {
// Perform a PUT request with the fetchIt function to the /profile route
fetchIt(`${Settings.apiHost}/profile/change`, {
method: "PUT",
body: JSON.stringify({ firstName, lastName })
}).then(() => {
getProfile(null, null, null, mimic).then(() => {
setUser(getCurrentUser())
})
})
}

const checkGithubInfo = () => {
if (!user.profile) {
return <article className="fullCenter">Loading...</article>
}
if (user.profile?.github_org_status !== "active") {
return <article className="fullCenter">
<h2>You need to accept the invitation to join your cohort's GitHub organization</h2>
<div>Click the button below to visit Github. Accept the invitation, and then come back to this tab and refresh.</div>
<Button style={{ marginTop: "2rem" }}>
<a style={{ color: "white", textDecoration: "none" }} href={user.profile?.current_cohort?.github_org} target="_blank">Accept Now</a>
</Button>
</article>
}

const name = user.profile?.name?.replace(/\s/g, '');
if (name.length === 0) {
return <article className="fullCenter">
<h2>Missing your first and last name</h2>
<div>It looks like you did not enter your name in your Github profile. Please provide your name below.</div>
<Flex direction="row" gap="3" mt="4">
<label>
<Text as="div" size="2" mb="1" weight="bold"> First Name </Text>
<TextFieldInput size="2" value={firstName} onChange={e => setFirstName(e.target.value)}></TextFieldInput>
</label>
<label>
<Text as="div" size="2" mb="1" weight="bold"> Last Name </Text>
<TextFieldInput size="2" value={lastName} onChange={e => setLastName(e.target.value)}></TextFieldInput>
</label>
</Flex>
<Button mt="2" onClick={saveName}> Save </Button>
</article>
}

return <article className="dashboard--overview">
<CohortInfo profile={user.profile} />
<StudentInfo profile={user.profile} />
</article>
}

return <main>
{checkGithubInfo()}
</main>
}
9 changes: 5 additions & 4 deletions src/components/dashboard/student/StudentInfo.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React, { useRef, useEffect, useState } from "react"
import { useHistory } from "react-router-dom"
import { AssessmentRow } from "./AssessmentRow"
import { CapstoneRow } from "./CapstoneRow"
import { Badge, Button, Dialog, TextArea, Text, Flex, Checkbox } from '@radix-ui/themes'
import { FilePlusIcon, Pencil1Icon } from '@radix-ui/react-icons'
import { Toast, deleteAllToasts } from "toaster-js"

import Settings from "../../Settings.js"
import { fetchIt } from "../../utils/Fetch.js"
import { AssessmentRow } from "./AssessmentRow"
import { CapstoneRow } from "./CapstoneRow"


export const StudentInfo = ({ profile }) => {

Expand Down Expand Up @@ -125,10 +126,10 @@ export const StudentInfo = ({ profile }) => {
<h3 className="studentAccount__header">Book Self-Assessments</h3>
</section>
<p>
You are done with the core projects in a book and need the link from an instructor to start your self-assessment project.
You are done with the core projects in a book and are ready for the self-assessment.
</p>
<section>
<Button color="iris" onClick={createAssessmentRepo}> Ready for Self-Assessment </Button>
<Button color="iris" onClick={createAssessmentRepo}>Start Self-Assessment</Button>
</section>
<p>
When you have completed the project code, completed the Vocabulary &amp; Understanding questions, and pushed your repository to Github, click the button below to notify your coaches.
Expand Down
89 changes: 0 additions & 89 deletions src/components/info/RulesOfEngagment.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/nav/StudentNavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ export const StudentNavBar = () => {
<li className="navbar__item">
{makeLink("/goals", "Core Skills")}
</li>
<li className="navbar__item">
{makeLink("/roe", "Rules of Engagement")}
</li>
{
isAuthenticated()
? <li className="navbar__item navbar__logout">
Expand Down

0 comments on commit 0c486de

Please sign in to comment.