forked from EGCETSII/decide_django_2
-
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.
Merge pull request EGCETSII#57 from Full-Tortuga/feature/EGCETSII#20-…
…voting-form-census-selector EGCETSII#20-feat: add census selector and improvements to voting form
- Loading branch information
Showing
8 changed files
with
110 additions
and
30 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
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
56 changes: 56 additions & 0 deletions
56
decide/administration/frontend/src/components/templates/votings/censusInput.tsx
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,56 @@ | ||
import React from "react"; | ||
import { Controller } from "react-hook-form"; | ||
import { Refresh } from "@mui/icons-material"; | ||
import { FormLabel } from "@mui/material"; | ||
|
||
import { userApi } from "api"; | ||
import { userType } from "types"; | ||
|
||
import { IconButton } from "components/01-atoms"; | ||
import { UserTable } from ".."; | ||
|
||
const Component = (props: { control: any }) => { | ||
const [refetch, setRefetch] = React.useState(false); | ||
const [users, setUsers] = React.useState<userType.User[]>([]); | ||
|
||
const refetchUsers = () => { | ||
setRefetch(!refetch); | ||
}; | ||
|
||
React.useEffect(() => { | ||
userApi | ||
.getUsers() | ||
.then((response) => { | ||
console.log(response); | ||
setUsers(response.data); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
}, [refetch]); | ||
|
||
return ( | ||
<Controller | ||
name="census" | ||
control={props.control} | ||
render={({ field, fieldState }) => ( | ||
<> | ||
<FormLabel>{"Census".toLowerCase()}</FormLabel> | ||
<UserTable | ||
setSelected={(selection: userType.User[]) => | ||
field.onChange(selection.map((u) => u.id)) | ||
} | ||
users={users} | ||
/> | ||
<IconButton | ||
onClick={refetchUsers} | ||
icon={<Refresh />} | ||
title="Refetch" | ||
/> | ||
</> | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
export default Component; |
4 changes: 3 additions & 1 deletion
4
decide/administration/frontend/src/components/templates/votings/index.ts
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,5 +1,7 @@ | ||
import QuestionInput from "./questionInput"; | ||
import CensusInput from "./censusInput"; | ||
|
||
import VotingTable from "./votingTable"; | ||
import VotingForm from "./votingForm"; | ||
|
||
export { VotingForm, VotingTable, QuestionInput }; | ||
export { VotingForm, VotingTable, QuestionInput, CensusInput }; |
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