* Add support for API Keys * Update * Fix import * Fix invalidation * Add a getting started flow * Fix * Fix everything * Remove console.log * Update * Logout if there's an address mismatch * Logout if there's an address mismatch * Add error messages * Add wallets * Escape apostrophe * Add link to documentation * Update copy * rename and added CW button demo * reorder wallets --------- Co-authored-by: Nacho Iacovino <[email protected]> Co-authored-by: Joaquim Verges <[email protected]>
35 lines
927 B
TypeScript
35 lines
927 B
TypeScript
import { useCreateApiKey } from "@3rdweb-sdk/react/hooks/useApi";
|
|
import { Icon } from "@chakra-ui/react";
|
|
import { useTxNotifications } from "hooks/useTxNotifications";
|
|
import { FiPlus } from "react-icons/fi";
|
|
import { Button } from "tw-components";
|
|
|
|
export const CreateApiKeyButton: React.FC = () => {
|
|
const createKeyMutation = useCreateApiKey();
|
|
const { onSuccess, onError } = useTxNotifications(
|
|
"API key created",
|
|
"Failed to create API key",
|
|
);
|
|
|
|
return (
|
|
<Button
|
|
onClick={() =>
|
|
createKeyMutation.mutate(undefined, {
|
|
onSuccess: () => {
|
|
onSuccess();
|
|
},
|
|
onError: (err) => {
|
|
onError(err);
|
|
},
|
|
})
|
|
}
|
|
colorScheme="blue"
|
|
leftIcon={<Icon as={FiPlus} boxSize={4} />}
|
|
isLoading={createKeyMutation.isLoading}
|
|
isDisabled={createKeyMutation.isLoading}
|
|
>
|
|
Create new key
|
|
</Button>
|
|
);
|
|
};
|