UNPKG

@mojito-inc/secondary-market

Version:

Mojito secondary market is the platform to purchase NFT.

2 lines (1 loc) 949 B
import{useState as l,useCallback as o,useEffect as e}from"react";import{useNFT as t}from"@mojito-inc/core-service";const i=({marketplaceID:i,orgID:a})=>{const{getRegistryCollections:c}=t(),[r,n]=l(!1),[s,v]=l(!1),[d,u]=l([{label:"All Collections",value:"all"}]),f=o((()=>{v(!0)}),[]),g=o((async()=>{var l,o;v(!1),n(!0);try{const e=await c({orgID:a,marketplaceID:i}),t=null===(o=null===(l=null==e?void 0:e.data)||void 0===l?void 0:l.getRegistriesV1)||void 0===o?void 0:o.data;if(!t||!Array.isArray(t))return void u([]);const r=t.length>1?[{label:"All Collections",value:"all"}]:[];t.forEach((l=>{(null==l?void 0:l.CollectionName)&&(null==l?void 0:l.ID)&&r.push({label:l.CollectionName,value:l.ID})})),u(r)}catch(l){console.error("Error fetching collections:",l)}finally{n(!1)}}),[c,i,a]);return e((()=>{s&&a&&i&&(v(!1),g())}),[g,s,i,a]),{collectionsListLoading:r,collectionsOptions:d,fetchCollections:g,fetchCollectionsList:f}};export{i as default};