import { useState } from 'react';
/** Import SecureFolder SDK */
import { SecureFolderSDK } from '@dataverse/secure-folder-sdk';
import { Button } from '@/index';

export default {
  title: 'withDataverseSDK-components',
};

export const ConnectIdentity = () => {
  const [did, setDid] = useState<string>();
  /**
   * Initialize the SecureFolderSDK class object:
   */
  const secureFolder = new SecureFolderSDK();
  const connect = async () => {
    try {
      const res = await secureFolder.connectIdentity({
        ethereum: window.ethereum,
      });
      setDid(res.did);
      console.log(res);
    } catch (e) {}
  };

  return (
    <Button
      onClick={() => {
        connect();
      }}
      label={did ? did : 'connect'}
    />
  );
};
