diff --git a/src/components/profile/profile-new.tsx b/src/components/profile/profile-new.tsx
new file mode 100644
index 0000000..bd2a5e8
--- /dev/null
+++ b/src/components/profile/profile-new.tsx
@@ -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 (
+
+ );
+};
+
+export default ProfileNew;
diff --git a/src/pages/profiles.tsx b/src/pages/profiles.tsx
index 299658a..3f75eb0 100644
--- a/src/pages/profiles.tsx
+++ b/src/pages/profiles.tsx
@@ -10,9 +10,10 @@ import {
} from "../services/cmds";
import { getProxies, updateProxy } from "../services/api";
import noop from "../utils/noop";
-import Notice from "../components/notice";
-import BasePage from "../components/base-page";
-import ProfileItem from "../components/profile-item";
+import Notice from "../components/base/base-notice";
+import BasePage from "../components/base/base-page";
+import ProfileItem from "../components/profile/profile-item";
+import ProfileNew from "../components/profile/profile-new";
const ProfilePage = () => {
const [url, setUrl] = useState("");
@@ -96,13 +97,15 @@ const ProfilePage = () => {
};
const lockNewRef = useRef(false);
- const onNew = async () => {
+ const [dialogOpen, setDialogOpen] = useState(false);
+ const onNew = async (name: string, desc: string) => {
if (lockNewRef.current) return;
lockNewRef.current = true;
try {
- await newProfile("New Profile", "no desc");
+ await newProfile(name, desc);
mutate("getProfiles");
+ setDialogOpen(false);
} catch (err: any) {
err && Notice.error(err.toString());
} finally {
@@ -131,7 +134,7 @@ const ProfilePage = () => {
>
Import
-