๐Ÿš€ My React Learning Journey โ€“ Distriator ๐Ÿ›  | Showing Monthly Cashback Claim History ๐Ÿ’ฐ

@sagarkothari88 ยท 2025-08-17 04:30 ยท HiveDevs

๐Ÿ‘‹ Hello Amazing Hive Community!

In our ReactJS adventure so far, weโ€™ve been on a wild dev ride โ€” from fixing rebellious NavBars to brewing delicious Toast notifications ๐Ÿž, and even sprinkling in some secure login sorcery โœจ.

So far, the app could load cashback details right after you log in โ€” but hey, why stop there?
We decided to also show a monthly cashback claim historyโ€ฆ because history matters (and so does money ๐Ÿ’ต).


๐Ÿ“œ Learning Journey Recap

Hereโ€™s the Netflix Series Recap of my React learning saga so far ๐ŸŽฌ๐Ÿ‘‡


๐Ÿ’ก The Big Idea

The cashback API already sends us:
- available cashback ๐Ÿ’ฐ
- AND your monthly claimed history ๐Ÿ“œ

But we weren't displaying the monthly list yet.

๐Ÿค” So the mission was clear:
Show users what theyโ€™ve claimed this month โ€” in style!


๐Ÿงช Attempt 1: The (Not-So-Mobile-Friendly) Table

DaisyUI Table

Result?
Horizontal scroll. My biggest enemy. โŒ
Nope. Deleted instantly ๐Ÿ’€


๐Ÿƒ Attempt 2: Cards

Also nope โŒ
Cards confused users because we already had one for available cashback.


๐Ÿ“œ Attempt 3: The Winning List ๐ŸŽฏ

An amazing component list

This DaisyUI list was love at first sight โค๏ธ.
But before beautyโ€ฆ came the brains ๐Ÿง .


๐Ÿ” Parsing the JSON Response

JSON Response of monthly history

API returns:
- memo
- invoice ๐Ÿงพ
- timestamp โณ
- cashback amount ๐Ÿ’ธ


๐Ÿช„ Extracting Business Name

Regex magic to the rescue:

  const regexBusinessName = (memo: string) => {
    const match = memo.match(
      /&(?:\s*adding?\s*review\s*of\s*)(.*?)\s*-\s*http/i
    );
    if (match) {
      const businessName = match[1];
      return businessName;
    } else {
      return "Cafe Coffee Jitters";
    }
  };

๐Ÿ–ผ Getting Business Image

   const getBusinessImage = (username: string) => {
    const filteredItems = businesses.filter(
      (b) => b.profile?.displayName === username
    );
    if (filteredItems.length > 0) {
      return (
        filteredItems[0].profile?.displayImage ||
        "https://img.daisyui.com/images/stock/photo-1606107557195-0e29a4b5b4aa.webp"
      );
    } else {
      return "https://img.daisyui.com/images/stock/photo-1606107557195-0e29a4b5b4aa.webp";
    }
  };

๐Ÿ”— Business Review Link

  const linkToPost = (memo: string) => {
    const match = memo.match(/-\s*(https?:\/\/\S+)/i);
    if (match) {
      const link = match[1];
      return link;
    } else {
      return "https://hive.blog/@shaktimaaan/ylgfiaqv";
    }
  };

๐Ÿงพ Invoice ID Shortcode

  const invoice = (memo: string) => {
    const match = memo.match(/\(([^)]+)\)/);
    if (match) {
      const invoiceId = match[1];
      return invoiceId;
    } else {
      return "HDC-XYMYX";
    }
  };

๐ŸŽจ Rendering the Monthly Cashback History List

  return (
    <div>
      <ul className="list bg-base-100 rounded-box shadow-md">
        <li className="p-4 pb-2 text-xs opacity-60 tracking-wide">
          Your claims from this month
        </li>
        {monthly?.map((claim, index) => (
          <li className="list-row" key={index} onClick={()=> window.open(linkToPost(claim.memo), "_blank")}>
            <div className="text-4xl font-thin opacity-30 tabular-nums">
              {index + 1}
            </div>
            <div>
              <img
                className="size-10 rounded-box"
                src={getBusinessImage(regexBusinessName(claim.memo))}
              />
            </div>
            <div>
              <div>{regexBusinessName(claim.memo)}</div>
              <div className="text-xs uppercase font-semibold opacity-60">{invoice(claim.memo)}</div>
            </div>
            <div>
            <div>{claim.amount}</div>
            <div>{dayjs(claim.timestamp).fromNow()}</div>
            </div>
          </li>
        ))}
      </ul>
    </div>
  );

๐Ÿ‘€ How Does it Look?

Cash back claim history from this month

Cash back claim history from this month

๐Ÿ“‚ Wanna See the Damn Code?

  • GitHub Repo: https://github.com/sag333ar/react-distriator
  • Direct Commit: https://github.com/sag333ar/react-distriator/commit/e0703d66f1c1cdec3b1d406b32973512ec5f6005
  • Snapshot View: https://github.com/sag333ar/react-distriator/tree/e0703d66f1c1cdec3b1d406b32973512ec5f6005

open source

๐Ÿ™ Thank You for Surviving My Tech Rant!

  • Hope you got a smile, a lesson, and maybe even a bit of cashback happiness ๐Ÿ’œ
  • ๐Ÿ”ฅ More Power to the Hive Community ๐Ÿš€
  • ๐ŸŒ• Hive to the moon and beyond! โœจ
  • ๐Ÿ‘‹ See you in the next post! ๐Ÿฅณ

๐Ÿ“ Final Note

  • I asked perplexity to help optimize this post to make it more readable and viewer-friendly.
  • Here is the link where you can find both original content & improvements made by AI
  • https://www.perplexity.ai/search/beeac6de-9d94-42e8-b12f-c6d8d1375838

๐Ÿš€ My Contributions to โ™ฆ๏ธ Hive Ecosystem

Contribution To Hive Ecosystem
Hive Witness Node Hive API Node (in progress) 3Speak Video Encoder Node Operator (highest number of nodes) 3Speak Mobile App Developer
3Speak Podcast App Developer 3Speak Shorts App Developer 3Speak Support & Maintenance Team Distriator Developer
CheckinWithXYZ Hive Inbox HiFind Hive Donate App
Contributed to HiveAuth Mobile App Ecency โ†” 3Speak Integration Ecency โ†” InLeo Integration Ecency โ†” Actifit Integration
Hive Stats App Vote for Witness App HiveFlutterKit New 3Speak App

๐Ÿ™Œ Support Back

โค๏ธ Appreciate my work? Consider supporting @threespeak & @sagarkothari88! โค๏ธ

Vote For Witness
sagarkothari88 @sagarkothari88
threespeak @threespeak

#hive #dev #india #waiv #neoxian #spendhbd #distriator #bro #reactjs #frontend
Payout: 30.139 HBD
Votes: 376
More interactions (upvote, reblog, reply) coming soon.