From 1c3ae5c4bc0153c8400c91d8cf751bda9f10753c Mon Sep 17 00:00:00 2001 From: GyDi Date: Wed, 15 Dec 2021 01:54:06 +0800 Subject: [PATCH] feat: update rule page --- src/pages/rules.tsx | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/pages/rules.tsx b/src/pages/rules.tsx index 6d6046728f..60f6853446 100644 --- a/src/pages/rules.tsx +++ b/src/pages/rules.tsx @@ -1,14 +1,28 @@ import { useState } from "react"; -import { invoke } from "@tauri-apps/api"; -import { Box, Button, Grid, TextField, Typography } from "@mui/material"; +import { + Box, + Button, + Grid, + Slide, + Snackbar, + TextField, + Typography, +} from "@mui/material"; +import { importProfile } from "../services/command"; const RulesPage = () => { const [url, setUrl] = useState(""); + const [message, setMessage] = useState(""); + const [disabled, setDisabled] = useState(false); - const onClick = async () => { + const onClick = () => { if (!url) return; - const data = await invoke("cmd_import_profile", { url }); - console.log(data); + setUrl(""); + setDisabled(true); + importProfile(url) + .then(() => setMessage("Successfully import profile.")) + .catch(() => setMessage("Failed to import profile.")) + .finally(() => setDisabled(false)); }; return ( @@ -26,17 +40,32 @@ const RulesPage = () => { setUrl(e.target.value)} /> - + + setMessage("")} + message={message} + TransitionComponent={(p) => } + /> ); };