Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | import React, { useState } from "react"; import CustomButton from "../../common/CustomButton/index.tsx"; import { useCreateConnectorMutation } from "../../../store/features/integrations/api/index.ts"; import { useSelector } from "react-redux"; import { connectorSelector } from "../../../store/features/integrations/integrationsSlice.ts"; import { useNavigate } from "react-router-dom"; import ConnectorUpdateOverlay from "../../Integration/connectors/ConnectorUpdateOverlay.tsx"; function UpdateConnectorButton({ id, connector }) { const navigate = useNavigate(); const [createConnector, { isLoading: saveLoading }] = useCreateConnectorMutation(); const currentConnector = useSelector(connectorSelector); const connectorActive = id !== undefined && id !== null; const [isUpdating, setIsUpdating] = useState(false); const keyOptions = connector?.keys ?? []; const handleClick = async () => { if (connectorActive) { setIsUpdating(true); } else { const formattedKeys: any = []; keyOptions?.forEach((e) => { formattedKeys.push({ key_type: e.key_type, key: (currentConnector[e.key_type] === "SSL_VERIFY" ? currentConnector[e.key_type] !== "" ? currentConnector[e.key_type] : false : currentConnector[e.key_type] )?.toString(), }); }); const res: any = await createConnector({ type: connector.type, keys: formattedKeys, name: currentConnector.name, }); Iif (res.data?.success) { navigate("/data-sources"); } } }; return ( <> <CustomButton onClick={handleClick}> {connectorActive ? "Update" : saveLoading ? "Loading..." : "Save"} </CustomButton> <ConnectorUpdateOverlay isOpen={isUpdating} connector={{ ...connector, id }} toggleOverlay={() => setIsUpdating(!isUpdating)} /> </> ); } export default UpdateConnectorButton; |