import React from 'react'; import Input from '@/_ui/Input'; import Oauth from './Oauth'; const OpenapiAuth = ({ username, password, bearer_token, optionchanged, authObject, api_keys, access_token_url, client_id, client_secret, client_auth, custom_auth_params, custom_query_params, add_token_to, header_prefix, grant_type, scopes, auth_url, auth_type, access_token_custom_headers, }) => { const apiKeyChanges = (key, value) => { const apiKeys = api_keys ?? []; const updatedKeys = apiKeys.map((item) => { if (Array.isArray(authObject)) { if (item.parentKey === authObject[0].key) { item.fields.map((field) => { if (field.key === key) { field.value = value; } return field; }); } } else { if (item.key === key) { item.value = value; } } return item; }); optionchanged('api_keys', updatedKeys); }; const getCurrentKey = (key) => { let currentValue; if (!api_keys) return ''; api_keys.map((item) => { if (Array.isArray(authObject) && item.parentKey === authObject[0].key) { item.fields.map((field) => { if (field.key === key) { currentValue = field.value; return; } }); if (currentValue) return; } if (item.key === key) { currentValue = item.value; return; } }); return currentValue; }; const renderApiKeyField = (auth, index) => { if (auth) { const value = getCurrentKey(auth.key); return (