mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-12 11:46:40 +00:00
usersModalEntry component added
This commit is contained in:
parent
8fa46cded5
commit
a74584c86f
2 changed files with 44 additions and 24 deletions
|
|
@ -6,6 +6,7 @@ import { FilterBar } from "./FilterBar";
|
||||||
import { HttpResponse } from "../types/HttpResponse";
|
import { HttpResponse } from "../types/HttpResponse";
|
||||||
import { get } from "../utils/http";
|
import { get } from "../utils/http";
|
||||||
import { Constants } from "../utils/Constants";
|
import { Constants } from "../utils/Constants";
|
||||||
|
import { UsersModalEntry } from "./UsersModalEntry";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
|
|
@ -15,12 +16,13 @@ interface IProps {
|
||||||
|
|
||||||
export const UsersModal: FC<IProps> = ({ show, handleClose, users }) => {
|
export const UsersModal: FC<IProps> = ({ show, handleClose, users }) => {
|
||||||
const [filterText, setFilterText] = useState<string>("");
|
const [filterText, setFilterText] = useState<string>("");
|
||||||
|
const [allUsers, setAllUsers] = useState<User[]>([]);
|
||||||
|
const [isChecked, setIsChecked] = useState(true);
|
||||||
const handleChange: (e: ChangeEvent<HTMLInputElement>) => void = (
|
const handleChange: (e: ChangeEvent<HTMLInputElement>) => void = (
|
||||||
e: ChangeEvent<HTMLInputElement>
|
e: ChangeEvent<HTMLInputElement>
|
||||||
) => {
|
) => {
|
||||||
setFilterText(e.target.value);
|
setFilterText(e.target.value);
|
||||||
};
|
};
|
||||||
const [allUsers, setAllUsers] = useState();
|
|
||||||
|
|
||||||
async function httpGet(): Promise<void> {
|
async function httpGet(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
|
@ -28,8 +30,7 @@ export const UsersModal: FC<IProps> = ({ show, handleClose, users }) => {
|
||||||
`${Constants.usersURI}`
|
`${Constants.usersURI}`
|
||||||
);
|
);
|
||||||
if (response.parsedBody !== undefined) {
|
if (response.parsedBody !== undefined) {
|
||||||
setAllUsers(response.parsedBody);
|
setAllUsers((response.parsedBody as unknown) as User[]);
|
||||||
// setIsLoading(false);
|
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// setHasError(true);
|
// setHasError(true);
|
||||||
|
|
@ -72,28 +73,16 @@ export const UsersModal: FC<IProps> = ({ show, handleClose, users }) => {
|
||||||
{/* <div className="code">{allUsers}</div> */}
|
{/* <div className="code">{allUsers}</div> */}
|
||||||
<form>
|
<form>
|
||||||
<ul>
|
<ul>
|
||||||
{users.map((u: User) => (
|
{allUsers.map((u: User) => (
|
||||||
<li key={u.id}>
|
<li key={u.id}>
|
||||||
<div className="row">
|
{console.log(isChecked)}
|
||||||
<input
|
<UsersModalEntry
|
||||||
id={u.id}
|
user={u}
|
||||||
type="checkbox"
|
isChecked={isChecked}
|
||||||
name="active"
|
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
||||||
value="true"
|
setIsChecked(!isChecked);
|
||||||
onChange={() => false}
|
}}
|
||||||
// checked
|
/>
|
||||||
/>
|
|
||||||
<span>
|
|
||||||
{u.fullName}
|
|
||||||
<img
|
|
||||||
className="circle"
|
|
||||||
src={u.picture}
|
|
||||||
width="32vh"
|
|
||||||
height="32vh"
|
|
||||||
alt={u.fullName}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
31
client/src/components/UsersModalEntry.tsx
Normal file
31
client/src/components/UsersModalEntry.tsx
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
import React, { FC, ChangeEvent } from "react";
|
||||||
|
import { User } from "../types/User";
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
isChecked: boolean;
|
||||||
|
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const UsersModalEntry: FC<IProps> = ({ user, isChecked, onChange }) => {
|
||||||
|
return (
|
||||||
|
<div className="row">
|
||||||
|
<input
|
||||||
|
id={user.id}
|
||||||
|
type="checkbox"
|
||||||
|
onChange={onChange}
|
||||||
|
checked={isChecked}
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
|
{user.fullName}
|
||||||
|
<img
|
||||||
|
className="circle"
|
||||||
|
src={user.picture}
|
||||||
|
width="32vh"
|
||||||
|
height="32vh"
|
||||||
|
alt={user.fullName}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue