repo_description: Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿
repo_topics: blockchain crypto dapp graphql hacktoberfest lens-protocol nextjs react social-media tailwindcss turborepo typescript vitest wagmi web3
code: import type {
    RecipientPercent,
    SimpleCollectActionFragment
  } from "@/indexer/generated";
  
  interface CollectActionData {
    price?: number;
    assetAddress?: string;
    assetSymbol?: string;
    collectLimit?: number;
    endsAt?: string;
    recipients?: RecipientPercent[];
  }
  
  const getCollectActionData = (
    collectAction: SimpleCollectActionFragment
  ): CollectActionData | null => {
    if (collectAction.__typename !== "SimpleCollectAction") {
      return null;
    }
  
    const { payToCollect, collectLimit, endsAt } = collectAction;
  
    return {
      assetAddress: payToCollect?.price?.asset?.contract?.address,
      assetSymbol: payToCollect?.price?.asset?.symbol,
      collectLimit: Number(collectLimit),
      endsAt,
      price: Number.parseFloat(payToCollect?.price?.value ?? "0"),
      recipients: payToCollect?.recipients ?? []
    };
  };
  
  export default getCollectActionData;
  