大佬教程收集整理的这篇文章主要介绍了填充有关更新模态反应的用户详细信息,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
function UserSetTings(props) {
const handleClose = () => {
setModalisOpen(false);
};
const handleChange1 = (event,newvalue) => {
SETVALue(newvalue);
};
const [modalisOpen,setModalisOpen] = useState(false);
const [userdetails,setUserdetails] = useState({});
const [users,setUsers] = useState([]);
const [userID,setUserID] = useState(0);
const [state,setState] = React.useState({
ID: '',username: '',password: '',email: '',first_name: '',last_name: '',image: '',});
const handleChange = (E) => {
const value = e.target.value;
setState({
...state,[e.target.name]: value,});
};
const handleUserCreateupdate = (ID) => {
setUserID(ID);
setState(userdetails);
setModalisOpen(true);
};
const submitHandler = (E) => {
e.preventDefault();
const newUser = {
ID: state.ID,username: state.username,password: state.password,email: state.email,first_name: state.first_name,last_name: state.last_name,image: state.image,};
const res = createupdateUser(newUser).then((res) => {
if (status === 201) {
}
});
return res;
};
useEffect(() => {
userLisTing().then((res) => {
setIsLoading(true);
if (res.status === 200) {
setUsers(res.data);
setIsLoading(false);
}
});
},[]);
useEffect(() => {
fetchUserDetails(userID).then((res) => {
if (res.status === 200) {
setUserdetails(res.data);
console.log(res.data)
}
});
},[userID]);
const body = (
<div style={modalStylE} classname={Classes.paper}>
<a classname="text-priMary">
<b>New User</b>
</a>
<form onsubmit={submitHandler}>
<div class="form-group">
<input
type="text"
class="form-control"
name="username"
placeholder="Username"
value={state.usernamE}
onChange={handleChangE}></input>
</div>
<div class="form-group">
<input
type="text"
class="form-control"
name="first_name"
placeholder="first name"
value={state.first_name}
onChange={handleChangE}></input>
</div>
<div class="form-group">
<input
type="text"
class="form-control"
name="last_name"
placeholder="last name"
value={state.last_name}
onChange={handleChangE}></input>
</div>
<div class="form-group">
<input
type="text"
class="form-control"
name="email"
placeholder="Email"
value={state.email}
onChange={handleChangE}></input>
</div>
<div class="form-group">
<input
type="password"
class="form-control"
name="password"
placeholder="password"
value={state.passworD}
onChange={handleChangE}
required
valIDate={[
required({
message: 'password is required.',}),]}
></input>
</div>
<div class="form-group">
<SELEct class="form-control" placeholder="Permisions">
<option>admin</option>
<option>Staff</option>
<option>User</option>
</SELEct>
</div>
<div class="form-group">
<input
type="file"
class="form-control-file"
name="image"
placeholder="Image"
value={state.imagE}
onChange={handleChangE}></input>
</div>
<button
type="submit"
class="btn btn-priMary"
onClick={() => window.LOCATIOn.reload(false)}>
{' '}
submit{' '}
</button>
<button onClick={handleClosE} color="secondary" size="large">
Cancel
</button>
</form>
</div>
);
return (
<>
<div>
<Modal
open={modalisOpen}
onClose={handleClosE}
disableBACkdropClick
aria-labelledby="simple-modal-title"
aria-describedby="simple-modal-description">
{Body}
</Modal>
<div>
<table>
{users.length > 0 ? (
users.map((user,indeX) => {
return (
<tableBody>
<tableRow>
<tableCell data-label="name">
<FormControlLabel
color="priMary"
control={<checkBox name="checkedC" />}
/>
</tableCell>
<tableCell data-label="Date">
{user.ID}
</tableCell>
<tableCell data-label="Referance">
{user.usernamE}
</tableCell>
<tableCell
data-label="amount"
classname="amount">
{user.email}
</tableCell>
<tableCell data-label="Status">
<span classname="pending">
{user.is_active ? 'ACTIVE' : 'PENDING'}
</span>
</tableCell>
<tableCell
data-label="Action"
classname="d-flex align-items-center">
<Iconbutton
aria-label="close"
size="small"
color="priMary"
href="JavaScript:voID(0);"
onClick={() =>
handleUserCreateupdate(user.ID)
}>
<Icon.Edit3 />
</Iconbutton>
</tableCell>
</tableRow>
</tableBody>
);
})
) : (
<tableSkeleton />
)}
</table>
<div/>
以上是大佬教程为你收集整理的填充有关更新模态反应的用户详细信息全部内容,希望文章能够帮你解决填充有关更新模态反应的用户详细信息所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。