-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from usual2970/feat/settings
Feat/settings
- Loading branch information
Showing
16 changed files
with
591 additions
and
387 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Deployment } from "@/domain/deployment"; | ||
import { CircleCheck, CircleX } from "lucide-react"; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipProvider, | ||
TooltipTrigger, | ||
} from "../ui/tooltip"; | ||
|
||
type DeployStateProps = { | ||
deployment: Deployment; | ||
}; | ||
|
||
const DeployState = ({ deployment }: DeployStateProps) => { | ||
// 获取指定阶段的错误信息 | ||
const error = (state: "check" | "apply" | "deploy") => { | ||
if (!deployment.log[state]) { | ||
return ""; | ||
} | ||
return deployment.log[state][deployment.log[state].length - 1].error; | ||
}; | ||
|
||
return ( | ||
<> | ||
{deployment.phase === "deploy" && deployment.phaseSuccess ? ( | ||
<CircleCheck size={16} className="text-green-700" /> | ||
) : ( | ||
<> | ||
{error(deployment.phase).length ? ( | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild className="cursor-pointer"> | ||
<CircleX size={16} className="text-red-700" /> | ||
</TooltipTrigger> | ||
<TooltipContent className="max-w-[35em]"> | ||
{error(deployment.phase)} | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
) : ( | ||
<CircleX size={16} className="text-red-700" /> | ||
)} | ||
</> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default DeployState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const version = "Certimate v0.1.8"; | ||
export const version = "Certimate v0.1.9"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { Button } from "@/components/ui/button"; | ||
import { | ||
Form, | ||
FormControl, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "@/components/ui/form"; | ||
import { Input } from "@/components/ui/input"; | ||
import { useToast } from "@/components/ui/use-toast"; | ||
import { getErrMessage } from "@/lib/error"; | ||
import { getPb } from "@/repository/api"; | ||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { useState } from "react"; | ||
import { useForm } from "react-hook-form"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
import { z } from "zod"; | ||
|
||
const formSchema = z.object({ | ||
email: z.string().email("请输入正确的邮箱"), | ||
}); | ||
|
||
const Account = () => { | ||
const { toast } = useToast(); | ||
const navigate = useNavigate(); | ||
|
||
const [changed, setChanged] = useState(false); | ||
|
||
const form = useForm<z.infer<typeof formSchema>>({ | ||
resolver: zodResolver(formSchema), | ||
defaultValues: { | ||
email: getPb().authStore.model?.email, | ||
}, | ||
}); | ||
|
||
const onSubmit = async (values: z.infer<typeof formSchema>) => { | ||
try { | ||
await getPb().admins.update(getPb().authStore.model?.id, { | ||
email: values.email, | ||
}); | ||
|
||
getPb().authStore.clear(); | ||
toast({ | ||
title: "修改账户邮箱功", | ||
description: "请重新登录", | ||
}); | ||
setTimeout(() => { | ||
navigate("/login"); | ||
}, 500); | ||
} catch (e) { | ||
const message = getErrMessage(e); | ||
toast({ | ||
title: "修改账户邮箱失败", | ||
description: message, | ||
variant: "destructive", | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className="w-full md:max-w-[35em]"> | ||
<Form {...form}> | ||
<form | ||
onSubmit={form.handleSubmit(onSubmit)} | ||
className="space-y-8 dark:text-stone-200" | ||
> | ||
<FormField | ||
control={form.control} | ||
name="email" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>邮箱</FormLabel> | ||
<FormControl> | ||
<Input | ||
placeholder="请输入邮箱" | ||
{...field} | ||
type="email" | ||
onChange={(e) => { | ||
setChanged(true); | ||
form.setValue("email", e.target.value); | ||
}} | ||
/> | ||
</FormControl> | ||
|
||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<div className="flex justify-end"> | ||
{changed ? ( | ||
<Button type="submit">确认修改</Button> | ||
) : ( | ||
<Button type="submit" disabled variant={"secondary"}> | ||
确认修改 | ||
</Button> | ||
)} | ||
</div> | ||
</form> | ||
</Form> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Account; |
Oops, something went wrong.