update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { InputAdornment, TextField, Tooltip } from '@mui/material';
|
||||
import { Dialog, DialogContent, DialogTitle, InputAdornment, TextField, Tooltip } from '@mui/material';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { Button } from '@mui/material';
|
||||
import { useUserStore } from '../store';
|
||||
@@ -12,6 +12,56 @@ import { FileUpload } from '../module/FileUpload';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Edit } from 'lucide-react';
|
||||
import { toast } from 'react-toastify';
|
||||
import { useAdminStore } from '../admin/store/admin-store';
|
||||
export const CheckUserExistModal = () => {
|
||||
const { t } = useTranslation();
|
||||
const userStore = useUserStore(
|
||||
useShallow((state) => {
|
||||
return {
|
||||
showCheckUserExist: state.showCheckUserExist,
|
||||
setShowCheckUserExist: state.setShowCheckUserExist,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const adminStore = useAdminStore(
|
||||
useShallow((state) => {
|
||||
return {
|
||||
checkUserExist: state.checkUserExist,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const onClose = () => {
|
||||
userStore.setShowCheckUserExist(false);
|
||||
};
|
||||
const [username, setUsername] = useState('@');
|
||||
|
||||
const onCheck = async () => {
|
||||
const res = await adminStore.checkUserExist(username);
|
||||
console.log(res);
|
||||
if (res === false) {
|
||||
toast.info('当前用户名可以修改,点击右上角关注公众号联系客服修改。', {
|
||||
autoClose: 20000,
|
||||
});
|
||||
// toast.success(t('Check success'));
|
||||
} else {
|
||||
toast.error('当前用户名已存在,请更换其他用户名。');
|
||||
}
|
||||
};
|
||||
return (
|
||||
<Dialog open={userStore.showCheckUserExist} onClose={onClose}>
|
||||
<DialogTitle>{t('Tips')}</DialogTitle>
|
||||
<DialogContent>
|
||||
<div className='flex flex-col pt-4 gap-6 w-[400px]'>
|
||||
<div className='text-sm text-secondary'>{t('Check username introduction')}</div>
|
||||
<TextField label='username' value={username} onChange={(e) => setUsername(e.target.value)} />
|
||||
<Button variant='contained' color='primary' onClick={onCheck}>
|
||||
{t('Submit')}
|
||||
</Button>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export const Profile = () => {
|
||||
const { t } = useTranslation();
|
||||
@@ -32,6 +82,7 @@ export const Profile = () => {
|
||||
updateData: state.updateData,
|
||||
setFormData: state.setFormData,
|
||||
updateSelf: state.updateSelf,
|
||||
setShowCheckUserExist: state.setShowCheckUserExist,
|
||||
};
|
||||
}),
|
||||
);
|
||||
@@ -104,9 +155,7 @@ export const Profile = () => {
|
||||
className='w-4 h-4 cursor-pointer text-primary'
|
||||
onClick={() => {
|
||||
console.log('onClick edit');
|
||||
toast.info('联系客服修改,因为名称和上传文件绑定了。', {
|
||||
autoClose: 20000,
|
||||
});
|
||||
userStore.setShowCheckUserExist(true);
|
||||
}}
|
||||
/>
|
||||
</InputAdornment>
|
||||
@@ -153,6 +202,7 @@ export const Profile = () => {
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<CheckUserExistModal />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
Reference in New Issue
Block a user