mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
feat: new profile able to edit name and desc
This commit is contained in:
64
src/components/profile/profile-new.tsx
Normal file
64
src/components/profile/profile-new.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
import { useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
TextField,
|
||||
} from "@mui/material";
|
||||
import Notice from "../base/base-notice";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
onSubmit: (name: string, desc: string) => void;
|
||||
}
|
||||
|
||||
const ProfileNew = (props: Props) => {
|
||||
const { open, onClose, onSubmit } = props;
|
||||
const [name, setName] = useState("");
|
||||
const [desc, setDesc] = useState("");
|
||||
|
||||
const onCreate = () => {
|
||||
if (!name.trim()) {
|
||||
Notice.error("`Name` should not be null");
|
||||
return;
|
||||
}
|
||||
onSubmit(name, desc);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onClose={onClose}>
|
||||
<DialogTitle>Create Profile</DialogTitle>
|
||||
<DialogContent sx={{ width: 320, pb: 0.5 }}>
|
||||
<TextField
|
||||
autoFocus
|
||||
fullWidth
|
||||
label="Name"
|
||||
margin="dense"
|
||||
variant="outlined"
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
fullWidth
|
||||
label="Descriptions"
|
||||
margin="normal"
|
||||
variant="outlined"
|
||||
value={desc}
|
||||
onChange={(e) => setDesc(e.target.value)}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ px: 2, pb: 2 }}>
|
||||
<Button onClick={onClose}>Cancel</Button>
|
||||
<Button onClick={onCreate} variant="contained">
|
||||
Create
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProfileNew;
|
||||
Reference in New Issue
Block a user