-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
you can now add users to the github organization from your admin
- Loading branch information
1 parent
5f568f4
commit 6a67828
Showing
5 changed files
with
129 additions
and
4 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,95 @@ | ||
import React, { useState } from 'react'; | ||
import { | ||
Dialog, | ||
Button, | ||
DialogTitle, | ||
DialogActions, | ||
DialogContent, | ||
} from '@material-ui/core'; | ||
import { AsyncAutocomplete } from 'app/components/Autocomplete'; | ||
import bc from 'app/services/breathecode'; | ||
|
||
const defaultProps = { | ||
cohortQuery: {}, | ||
cohorUserQuery: {}, | ||
hint: null, | ||
onClose: null, | ||
open: true, | ||
}; | ||
|
||
export const PickCohortUserModal = ({ | ||
defaultCohort=null, | ||
defaultCohortUser=null, | ||
cohortQuery, | ||
cohorUserQuery, | ||
hint, | ||
onClose, | ||
open | ||
}) => { | ||
|
||
const [cohort, setCohort] = useState(defaultCohort) | ||
const [cohortUser, setCohortUser] = useState(defaultCohortUser) | ||
const [ error, setError ] = useState(null) | ||
|
||
return ( | ||
<> | ||
<Dialog | ||
open={open} | ||
onClose={() => onClose(false)} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description" | ||
fullWidth="md" | ||
> | ||
<DialogTitle className="ml-2" id="alert-dialog-title"> | ||
Find a cohort and user | ||
</DialogTitle> | ||
<DialogContent> | ||
<AsyncAutocomplete | ||
defaultValue={defaultCohort} | ||
width="100%" | ||
onChange={(x) => setCohort(x)} | ||
label="Search for active or prework cohorts" | ||
value={cohort} | ||
getOptionLabel={(option) => `${option.name} (${option.stage})`} | ||
asyncSearch={async (searchTerm) => { | ||
const resp = await bc.admissions().getAllCohorts({ ...cohortQuery, like: searchTerm }) | ||
if(resp.ok) return resp.data | ||
else setError("Error fetching cohorts") | ||
}} | ||
/> | ||
{cohort && <AsyncAutocomplete | ||
key={cohort.slug} | ||
defaultValue={defaultCohortUser} | ||
width="100%" | ||
onChange={(x) => setCohortUser(x)} | ||
label={`Search user in cohort ${cohort.name}`} | ||
value={cohortUser} | ||
debounced={false} | ||
getOptionLabel={(option) => `${option.user.first_name} ${option.user.last_name} - ${option.user.email}`} | ||
asyncSearch={async (searchTerm) => { | ||
let q = { ...cohorUserQuery, cohorts: cohort.slug }; | ||
if(searchTerm) q.like = searchTerm; | ||
|
||
const resp = await bc.admissions().getAllUserCohorts(q) | ||
if(resp.ok) return resp.data | ||
else setError("Error fetching cohort users") | ||
}} | ||
/>} | ||
{hint && <p className="my-2">{hint}</p>} | ||
</DialogContent> | ||
<DialogActions> | ||
<Button | ||
color="primary" tma | ||
variant="contained" | ||
autoFocus | ||
onClick={() => onClose(cohortUser)} | ||
> | ||
Select Cohort User | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
</> | ||
) | ||
} | ||
|
||
PickCohortUserModal.defaultProps = defaultProps; |
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
6a67828
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
academy – ./
academy-git-master-geeksacademy.vercel.app
academy-geeksacademy.vercel.app
staff.breatheco.de
admin.4geeks.com
admin.breatheco.de
dev.admin.breatheco.de