11"use client" ;
22
3+ import { EyeClosedIcon , EyeOpenIcon } from "@radix-ui/react-icons" ;
4+
35import { Button } from "@missingstudio/ui/button" ;
46import { Input } from "@missingstudio/ui/input" ;
57import { Loader } from "lucide-react" ;
@@ -14,7 +16,7 @@ import { toast } from "sonner";
1416import * as z from "zod" ;
1517
1618import { Label } from "@missingstudio/ui/label" ;
17- import { useEffect } from "react" ;
19+ import { HTMLInputTypeAttribute , useEffect , useState } from "react" ;
1820import ProvidersIcon from "~/public/providers-icon.svg" ;
1921import ProvidersImg from "~/public/providers-image.png" ;
2022import Star from "~/public/star.svg" ;
@@ -37,6 +39,8 @@ const formSchema = z.object({
3739type FormValues = z . infer < typeof formSchema > ;
3840
3941export default function SingleProvider ( ) {
42+ const [ authInputType , setAuthInputType ] =
43+ useState < HTMLInputTypeAttribute > ( "password" ) ;
4044 const params = useParams < { providerId : string } > ( ) ;
4145 const { config, provider } = useProviderFetch ( params . providerId ) ;
4246
@@ -181,18 +185,34 @@ export default function SingleProvider() {
181185 { Object . keys ( headersProperties ) . map ( ( hp : string ) => {
182186 const { title, description } = headersProperties [ hp ] ;
183187 return (
184- < div key = "hp" >
188+ < div key = "hp" className = "relative" >
185189 < Label > { title } </ Label >
186190 < Controller
187191 key = { hp }
188192 render = { ( { field : { value, onChange } } ) => (
189- < Input
190- className = "col-span-2"
191- // @ts -ignore
192- value = { value }
193- onChange = { onChange }
194- placeholder = { description }
195- />
193+ < >
194+ < Input
195+ className = "col-span-2"
196+ type = { authInputType }
197+ // @ts -ignore
198+ value = { value }
199+ onChange = { onChange }
200+ placeholder = { description }
201+ />
202+ { authInputType == "password" ? (
203+ < EyeOpenIcon
204+ className = "absolute bottom-3 right-2 bg-white p-[2px] w-4 cursor-pointer"
205+ onClick = { ( ) => setAuthInputType ( "text" ) }
206+ />
207+ ) : (
208+ < EyeClosedIcon
209+ className = "absolute bottom-3 right-2 bg-white p-[2px] w-4 cursor-pointer"
210+ onClick = { ( ) =>
211+ setAuthInputType ( "password" )
212+ }
213+ />
214+ ) }
215+ </ >
196216 ) }
197217 // @ts -ignore
198218 name = { `config.headers.${ hp } ` }
0 commit comments