mirror of https://github.com/msgbyte/tailchat
feat(admin): 增加用户详情页,并增加重置密码功能
parent
90a30c7e98
commit
8a8be0b085
@ -0,0 +1,45 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Button, ButtonProps, Confirm } from 'react-admin';
|
||||||
|
|
||||||
|
interface Props extends Pick<ButtonProps, 'label'> {
|
||||||
|
component?: React.ComponentType<ButtonProps>;
|
||||||
|
confirmTitle?: string;
|
||||||
|
confirmContent?: string;
|
||||||
|
onConfirm?: () => void;
|
||||||
|
}
|
||||||
|
export const ButtonWithConfirm: React.FC<Props> = React.memo((props) => {
|
||||||
|
const {
|
||||||
|
component: ButtonComponent = Button,
|
||||||
|
confirmTitle = '确认要进行该操作么?',
|
||||||
|
confirmContent = '该操作不可撤回',
|
||||||
|
} = props;
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ButtonComponent
|
||||||
|
onClick={(e) => {
|
||||||
|
setOpen(true);
|
||||||
|
}}
|
||||||
|
label={props.label}
|
||||||
|
/>
|
||||||
|
<Confirm
|
||||||
|
isOpen={open}
|
||||||
|
loading={loading}
|
||||||
|
title={confirmTitle}
|
||||||
|
content={confirmContent}
|
||||||
|
onConfirm={() => {
|
||||||
|
setLoading(true);
|
||||||
|
props.onConfirm?.();
|
||||||
|
setLoading(false);
|
||||||
|
setOpen(false);
|
||||||
|
}}
|
||||||
|
onClose={() => {
|
||||||
|
setOpen(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
ButtonWithConfirm.displayName = 'ButtonWithConfirm';
|
@ -0,0 +1,17 @@
|
|||||||
|
import { styled, alpha } from '@mui/material';
|
||||||
|
import { Button } from 'react-admin';
|
||||||
|
|
||||||
|
export const DangerButton = styled(Button, {
|
||||||
|
name: 'DangerBtn',
|
||||||
|
overridesResolver: (props, styles) => styles.root,
|
||||||
|
})(({ theme }) => ({
|
||||||
|
color: theme.palette.error.main,
|
||||||
|
'&:hover': {
|
||||||
|
backgroundColor: alpha(theme.palette.error.main, 0.12),
|
||||||
|
// Reset on mouse devices
|
||||||
|
'@media (hover: none)': {
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
DangerButton.displayName = 'DangerButton';
|
Loading…
Reference in New Issue