11import { zodResolver } from "@hookform/resolvers/zod" ;
22import { PlusIcon } from "lucide-react" ;
3- import { useEffect , useState } from "react" ;
3+ import { useState } from "react" ;
44import { useForm , FormProvider } from "react-hook-form" ;
55import { useTranslation } from "react-i18next" ;
66import { toast } from "react-toastify" ;
@@ -33,19 +33,13 @@ const FormSchema = z.object({
3333 token : stringOrUndefined ,
3434 number : stringOrUndefined ,
3535 businessId : stringOrUndefined ,
36- integration : z . enum ( [
37- "WHATSAPP-BUSINESS" ,
38- "WHATSAPP-BAILEYS" ,
39- "META-FACEBOOK" ,
40- "META-INSTAGRAM" ,
41- "EVOLUTION" ,
42- ] ) ,
36+ integration : z . enum ( [ "WHATSAPP-BUSINESS" , "WHATSAPP-BAILEYS" , "EVOLUTION" ] ) ,
4337} ) ;
4438
4539function NewInstance ( { resetTable } : { resetTable : ( ) => void } ) {
4640 const { t } = useTranslation ( ) ;
4741 const [ open , setOpen ] = useState ( false ) ;
48- const [ options , setOptions ] = useState ( [
42+ const options = [
4943 {
5044 value : "WHATSAPP-BAILEYS" ,
5145 label : t ( "instance.form.integration.baileys" ) ,
@@ -58,7 +52,8 @@ function NewInstance({ resetTable }: { resetTable: () => void }) {
5852 value : "EVOLUTION" ,
5953 label : t ( "instance.form.integration.evolution" ) ,
6054 } ,
61- ] ) ;
55+ ] ;
56+
6257 const form = useForm < z . infer < typeof FormSchema > > ( {
6358 resolver : zodResolver ( FormSchema ) ,
6459 defaultValues : {
@@ -70,27 +65,6 @@ function NewInstance({ resetTable }: { resetTable: () => void }) {
7065 } ,
7166 } ) ;
7267
73- const facebookLogin =
74- localStorage . getItem ( "facebookUserToken" ) &&
75- localStorage . getItem ( "facebookConfigId" ) &&
76- localStorage . getItem ( "facebookAppId" ) ;
77-
78- useEffect ( ( ) => {
79- if ( facebookLogin ) {
80- setOptions ( [
81- ...options ,
82- {
83- value : "META-FACEBOOK" ,
84- label : t ( "instance.form.integration.facebook" ) ,
85- } ,
86- {
87- value : "META-INSTAGRAM" ,
88- label : t ( "instance.form.integration.instagram" ) ,
89- } ,
90- ] ) ;
91- }
92- } , [ facebookLogin ] ) ;
93-
9468 const integrationSelected = form . watch ( "integration" ) ;
9569
9670 const onSubmit = async ( data : z . infer < typeof FormSchema > ) => {
0 commit comments