22
33import { authClient } from '@databuddy/auth/client' ;
44import { zodResolver } from '@hookform/resolvers/zod' ;
5- import type { TRPCError } from '@trpc/server' ;
65import { LoaderCircle } from 'lucide-react' ;
76import { useEffect , useRef } from 'react' ;
87import { useForm } from 'react-hook-form' ;
98import { toast } from 'sonner' ;
10- import z from 'zod/v4 ' ;
9+ import * as z from 'zod' ;
1110import { Button } from '@/components/ui/button' ;
1211import {
1312 Dialog ,
@@ -53,9 +52,7 @@ export function WebsiteDialog({
5352 open,
5453 onOpenChange,
5554 website,
56- onSave = ( ) => {
57- // Do nothing
58- } ,
55+ onSave = ( ) => { } ,
5956} : WebsiteDialogProps ) {
6057 const isEditing = ! ! website ;
6158 const { data : activeOrganization } = authClient . useActiveOrganization ( ) ;
@@ -80,7 +77,7 @@ export function WebsiteDialog({
8077 }
8178 } , [ website , form ] ) ;
8279
83- const handleSubmit = form . handleSubmit ( ( formData ) => {
80+ const handleSubmit = form . handleSubmit ( async ( formData ) => {
8481 const submissionData : CreateWebsiteData = {
8582 name : formData . name ,
8683 domain : formData . domain ,
@@ -99,9 +96,9 @@ export function WebsiteDialog({
9996 onOpenChange ( false ) ;
10097 return `Website ${ isEditing ? 'updated' : 'created' } successfully!` ;
10198 } ,
102- error : ( err : TRPCError ) => {
99+ error : ( err : any ) => {
103100 const message =
104- err . code === 'CONFLICT'
101+ err . data ?. code === 'CONFLICT'
105102 ? 'A website with this domain already exists.'
106103 : `Failed to ${ isEditing ? 'update' : 'create' } website.` ;
107104 return message ;
@@ -167,9 +164,7 @@ export function WebsiteDialog({
167164 ) {
168165 try {
169166 domain = new URL ( domain ) . hostname ;
170- } catch {
171- // Do nothing
172- }
167+ } catch { }
173168 }
174169 field . onChange ( domain . replace ( / ^ w w w \. / , '' ) ) ;
175170 } }
0 commit comments