From eb7da996a7c2d617d276f296cac07a6fd5648664 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 27 Oct 2024 12:03:14 +0000 Subject: ui: Redesign the settings page and move it to its own layout --- .../dashboard/settings/ChangePassword.tsx | 133 --------------------- 1 file changed, 133 deletions(-) delete mode 100644 apps/web/components/dashboard/settings/ChangePassword.tsx (limited to 'apps/web/components/dashboard/settings/ChangePassword.tsx') diff --git a/apps/web/components/dashboard/settings/ChangePassword.tsx b/apps/web/components/dashboard/settings/ChangePassword.tsx deleted file mode 100644 index aa27f223..00000000 --- a/apps/web/components/dashboard/settings/ChangePassword.tsx +++ /dev/null @@ -1,133 +0,0 @@ -"use client"; - -import type { z } from "zod"; -import { ActionButton } from "@/components/ui/action-button"; -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; -import { Input } from "@/components/ui/input"; -import { toast } from "@/components/ui/use-toast"; -import { api } from "@/lib/trpc"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { useForm } from "react-hook-form"; - -import { zChangePasswordSchema } from "@hoarder/shared/types/users"; - -export function ChangePassword() { - const form = useForm>({ - resolver: zodResolver(zChangePasswordSchema), - defaultValues: { - currentPassword: "", - newPassword: "", - newPasswordConfirm: "", - }, - }); - - const mutator = api.users.changePassword.useMutation({ - onSuccess: () => { - toast({ description: "Password changed successfully" }); - form.reset(); - }, - onError: (e) => { - if (e.data?.code == "UNAUTHORIZED") { - toast({ - description: "Your current password is incorrect", - variant: "destructive", - }); - } else { - toast({ description: "Something went wrong", variant: "destructive" }); - } - }, - }); - - async function onSubmit(value: z.infer) { - mutator.mutate({ - currentPassword: value.currentPassword, - newPassword: value.newPassword, - }); - } - - return ( -
-
- Change Password -
-
- - { - return ( - - Current Password - - - - - - ); - }} - /> - { - return ( - - New Password - - - - - - ); - }} - /> - { - return ( - - Confirm New Password - - - - - - ); - }} - /> - - Save - - - -
- ); -} -- cgit v1.2.3-70-g09d2