Skip to content

Commit

Permalink
feat: add toast notifications for settings dialog ✨🎨
Browse files Browse the repository at this point in the history
  • Loading branch information
kareemmahlees committed Sep 19, 2024
1 parent 268d921 commit 0631a12
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { zodResolver } from "@hookform/resolvers/zod"
import { FileJson2 } from "lucide-react"
import type { PropsWithChildren } from "react"
import { useForm } from "react-hook-form"
import { toast } from "sonner"
import z from "zod"

const formSchema = z.object({
Expand All @@ -40,7 +41,19 @@ const SettingsTab = () => {
})

const onSubmit = async (data: z.infer<typeof formSchema>) => {
await commands.writeIntoSettingsFile(data)
const result = await commands.writeIntoSettingsFile(data)
if (result.status === "error") {
return toast.error("Failed to update settings.", {
description: result.error.details
})
}
return toast.success("Successfully updated settings", {
description: "A hard refresh is required",
action: {
label: "Refresh",
onClick: () => location.reload()
}
})
}

return (
Expand Down

0 comments on commit 0631a12

Please sign in to comment.