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 ReadFolders = () => {
  /**
   * Initialize the SecureFolderSDK class object:
   */
  const secureFolder = new SecureFolderSDK();
  const connect = async () => {
    try {
      const connectRes = await secureFolder.connectIdentity({
        ethereum: window.ethereum,
      });
      try {
        const res = await secureFolder.readFolders(
          {
            getEthereum: () => window.ethereum,
            isExtension: true,
            did: connectRes.did,
          },
          true,
        );
        console.log(res);
        console.log(res);
      } catch (e) {
        console.log(e);
      }
    } catch (e) {}
  };

  return (
    <Button
      onClick={() => {
        connect();
      }}
      label={'readFolders'}
    />
  );
};
