UNPKG

@mojito-inc/secondary-market

Version:

Mojito secondary market is the platform to purchase NFT.

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