@@ -104,92 +104,7 @@ export const AddProviderButton: FC<{
104104 </ div >
105105 ) ;
106106} ;
107- export const ApiModal : FC < {
108- identifier : string ;
109- name : string ;
110- update ?: ( ) => void ;
111- close ?: ( ) => void ;
112- } > = ( props ) => {
113- const { update, name, close : closePopup } = props ;
114- const fetch = useFetch ( ) ;
115- const router = useRouter ( ) ;
116- const modal = useModals ( ) ;
117- const methods = useForm ( {
118- mode : 'onChange' ,
119- resolver,
120- } ) ;
121- const close = useCallback ( ( ) => {
122- if ( closePopup ) {
123- return closePopup ( ) ;
124- }
125- modal . closeAll ( ) ;
126- } , [ ] ) ;
127- const submit = useCallback ( async ( data : FieldValues ) => {
128- const add = await fetch (
129- `/integrations/article/${ props . identifier } /connect` ,
130- {
131- method : 'POST' ,
132- body : JSON . stringify ( {
133- api : data . api ,
134- } ) ,
135- }
136- ) ;
137- if ( add . ok ) {
138- if ( closePopup ) {
139- closePopup ( ) ;
140- } else {
141- modal . closeAll ( ) ;
142- }
143- router . refresh ( ) ;
144- if ( update ) update ( ) ;
145- return ;
146- }
147- methods . setError ( 'api' , {
148- message : t ( 'invalid_api_key' , 'Invalid API key' ) ,
149- } ) ;
150- } , [ ] ) ;
151-
152- const t = useT ( ) ;
153107
154- return (
155- < div className = "rounded-[4px] border border-customColor6 bg-sixth px-[16px] pb-[16px] relative" >
156- < TopTitle title = { `Add API key for ${ name } ` } />
157- < button
158- onClick = { close }
159- className = "outline-none absolute end-[20px] top-[20px] mantine-UnstyledButton-root mantine-ActionIcon-root hover:bg-tableBorder cursor-pointer mantine-Modal-close mantine-1dcetaa"
160- type = "button"
161- >
162- < svg
163- viewBox = "0 0 15 15"
164- fill = "none"
165- xmlns = "http://www.w3.org/2000/svg"
166- width = "16"
167- height = "16"
168- >
169- < path
170- d = "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z"
171- fill = "currentColor"
172- fillRule = "evenodd"
173- clipRule = "evenodd"
174- > </ path >
175- </ svg >
176- </ button >
177- < FormProvider { ...methods } >
178- < form
179- className = "gap-[8px] flex flex-col"
180- onSubmit = { methods . handleSubmit ( submit ) }
181- >
182- < div className = "pt-[10px]" >
183- < Input label = "API Key" name = "api" />
184- </ div >
185- < div >
186- < Button type = "submit" > { t ( 'add_platform' , 'Add platform' ) } </ Button >
187- </ div >
188- </ form >
189- </ FormProvider >
190- </ div >
191- ) ;
192- } ;
193108export const UrlModal : FC < {
194109 gotoUrl ( url : string ) : void ;
195110} > = ( props ) => {
0 commit comments