create account

🎯 ReactJS Adventures: Designing a Cashback ClaimBox for Distriator πŸ’΅ πŸš€ by sagarkothari88

View this thread on: hive.blogpeakd.comecency.com
· @sagarkothari88 ·
$7.11
🎯 ReactJS Adventures: Designing a Cashback ClaimBox for Distriator πŸ’΅ πŸš€
Hello Hive Community Members πŸ‘‹,  

The **Distriator** app is getting a ReactJS glow-up ✨ β€” and if things go right, we might finally say goodbye to that bloated Flutter build πŸͺ¦.  
As always, **everything is open source** (because sharing is caring ❀️), so if you missed the earlier drama, here’s your binge-worthy recap πŸ“ΊπŸ‘‡.

---

### πŸ“œ **Epic Learning Journey Recap**
Missed a day? Here’s the trail of my glorious *ReactJS misadventures*:
- [πŸ“š **Day 1**](https://peakd.com/hive-139531/@sagarkothari88/integrate-aioha-with-your-react-app-from-scratch-vite--tailwind--daisyui) – Fresh React app + AIOHA integration!
- [🧭 **Day 2**](https://peakd.com/hive-139531/@sagarkothari88/integrating-react-router-my-routing-adventures-with-react) – Routing drama & rebellious NavBar
- [πŸ› οΈ **Day 3**](https://peakd.com/hive-139531/@sagarkothari88/from-navbar-mess-to-react-router-success-fixing-layouts-routing-and-aioha-in-one-go) – Fixed layouts, Routing & AIOHA
- [🧠 **Day 4**](https://peakd.com/hive-139531/@sagarkothari88/day-4-reactjs-adventures--distriator-progress-usestate-useeffect-and-env-chaos) – useState, useEffect & .env headaches πŸ˜…
- [🧹 **Day 5**](https://peakd.com/hive-139531/@sagarkothari88/level-up-your-imports-using-path-aliases-for-cleaner-react--typescript-projects) – Path aliases to clean up path spaghetti 🍝
- [πŸ“‘ **Day 6**](https://peakd.com/hive-139531/@sagarkothari88/day-6-learning-reactjs-calling-apis-and-creating-context-providers-or-distriator-feature-update) – Create Context Provider & call API
- [🍞 **Day 7**](https://peakd.com/hive-139531/@sagarkothari88/learning-reactjs--vite--ts--aioha-day-7-show-a-toast-message) – Show a toast message
- [πŸ” **Day 8**](https://peakd.com/hive-139531/@sagarkothari88/day-8-secure-login-with-aioha-and-localstorage-magic) – Login magic with LocalStorage
- [πŸ˜‚ **Day 9**](https://peakd.com/hive-139531/@sagarkothari88/day-9-toasts-laughs-and-custom-magic) – Toasts, laughs & custom tricks
- [πŸ†• **Day 10**](#) – Handle user account switch + fresh JWT Token
- [πŸ†• **Day 11**](#) – Integrating API for cashback details

---

## πŸ’΅ **Day 12: Designing the Cashback ClaimBox**

This time, we’re showing users a beautiful, irresistible β€œClaim Cashback” card πŸ’Œ whenever their cashback is ready to be grabbed.

### πŸ’­ **Thought Process**
Originally: β€œLet’s just put a box in the center with a button.”  
Brain: ❌ β€œNope, don’t reinvent the wheel.”  
Solution: Scroll through [DaisyUI](https://daisyui.com/) like it’s Pinterest, and pick something gorgeous.

---

### πŸƒ **The Card That Stole My Heart**
After scrolling... BAM πŸ’˜ β€” this card component caught my eye.

![Beautiful card view](https://files.peakd.com/file/peakd-hive/sagarkothari88/EokWQVx9BZJApPEySbwH1qZfmWWgoFdBAWh3D7wZk4KJhWfSH6MXGka7sVHYL534Wc8.png)

JSX? Barely 10 lines 🀯. Copy. Paste. Let’s roll.

![JSX Code snippet for card view](https://files.peakd.com/file/peakd-hive/sagarkothari88/23t752JvVnU26LiSwBW2fwbn7ZWqyg8J9x3AegE4ybgX94QBDcfcYk8UZAKu8T7k6o8nb.png)

---

### πŸ“¦ **ClaimBox Component**
- Created `ClaimBox.tsx`
- Grabbed API attributes:  
  - Transaction timestamp πŸ•’  
  - Business name πŸͺ  
  - Claimable cashback amount πŸ’΅  
  - Transaction amount πŸ’³  

![API response data](https://files.peakd.com/file/peakd-hive/sagarkothari88/23tGXSy37QCRpp7EFnm9firGcz7fgk57P7otThaYmmhKYvG3giBvzsMcQnzvpQJqFcKok.png)

---

### ⏳ **Timer Logic**
Cashback = claimable for **2 hours** after transaction.  
We:
1. Grab timestamp  
2. Add 2 hrs  
3. Show countdown (HH:MM:SS)  
4. Update every 1 sec ⏱️  

```ts
function formatSecondsToHHMMSS(totalSeconds: number): string {
  if (totalSeconds < 0) return '';
  const hours = Math.floor(totalSeconds / 3600);
  const minutes = Math.floor((totalSeconds % 3600) / 60);
  const seconds = parseInt((totalSeconds % 60).toFixed(0));
  const pad = (num: number) => String(num).padStart(2, "0");
  return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
}
```

#### πŸͺ Getting Business Info

Using the Business Provider to get:
- Profile Image πŸ“·
- Display Name 🏷️


[In this post](https://peakd.com/hive-139531/@sagarkothari88/day-6-learning-reactjs-calling-apis-and-creating-context-providers-or-distriator-feature-update), we discussed about implementing business provider. From that provider, we'll access businesses. From list of businesses, we'll get business display name & business profile image.

Step 1. Import business provider

```
import { useBusinesses } from "@/context/BusinessesContext";
```

Step 2. Declare business provider variable

```
const { businesses } = useBusinesses();
```

Step 3. Get Business Profile Display Image

```
  const getBusinessImage = (username: string) => {
    const filteredItems = businesses.filter(
      (b) => b.distriator?.owner === 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";
    }
  };
```

Step 4. Get Business Profile Display Name

```
  const getBusinessName = (username: string) => {
    const filteredItems = businesses.filter(
      (b) => b.distriator?.owner === username
    );
    if (filteredItems.length > 0) {
      return filteredItems[0].profile?.displayName || "Business Name";
    } else {
      return "Business Name";
    }
  };
```

#### 🎨 Final ClaimBox UI

```
  return (
    <div className="card bg-base-100 w-96 shadow-sm">
      <figure>
        <img 
          src={getBusinessImage(claim.business)} 
          alt={`${getBusinessName(claim.business)}`} />
      </figure>
      <div className="card-body">
        <h2 className="card-title">{claim.claimValue} Cashback</h2>
        <p>
          Your recent spent of {claim.amount}, at {getBusinessName(claim.business)}, is eligible for claiming a cashback
        </p>
        <div className="card-actions justify-end items-center">
          <span className="text-lg font-bold text-red-600 animate-blink">
            Time Left {timeText}
          </span>
          <button className="btn btn-primary">Claim Now!</button>
        </div>
      </div>
    </div>
  );
```

#### πŸ“ Centering the Magic

Show loader if loading, β€œNo claim available” if empty, else ClaimBox πŸ’Ž.

![Loader - no claim - cashback](https://files.peakd.com/file/peakd-hive/sagarkothari88/23t76oPDYmjkX6kNeW331roWc7cQ6C5Q3YUghLgcGH1URAAkK6GLQqB2bKwy1RTj1LDbW.png)

#### πŸ₯ Drumroll... Tada!

`npm run dev` β†’ Profit.

![Wow wonderful](https://files.peakd.com/file/peakd-hive/sagarkothari88/EoiTmwnQ7RC3dzFW2vUAGcnsopQLty32ZHaDYwHaqYqLgK1qN3Syo8hXWvpfw9t3Ryf.png)

Looks wonderful, right? 😍

####  πŸ›  Open Source Goodness

- Github Repository Link: https://github.com/sag333ar/react-distriator
- Review Last commit changes: https://github.com/sag333ar/react-distriator/commit/33d842e2f0cb697d8b4d61c44c7c8a1d98be9a2e
- Snapshot: https://github.com/sag333ar/react-distriator/tree/33d842e2f0cb697d8b4d61c44c7c8a1d98be9a2e

#### πŸ€” Why Flutter? Why Me?

After this, I questioned my life choices… Flutter? Native apps? When ReactJS makes it this simple? πŸ™ƒ
But hey, lesson learned β€” and we now have ClaimBox integrated 🎯.


#### 🐝 Power to Hive

- πŸš€ Hive to the moon (and beyond!)
- ❀️ Power to Hive community
- πŸ’ͺ Power to Hive blockchain

Thanks for reading! Drop your feedback & see you in the next one ✌️.

---

### πŸ“ Final Note

- I asked ChatGPT/AI 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://chatgpt.com/share/689a853f-e634-8000-8a8a-7a1929030940

---

### πŸš€ 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](https://distriator.com/) |
| [CheckinWithXYZ](https://checkinwith.xyz/) | [Hive Inbox](https://hive-inbox.the-hive-mobile.app/) | [HiFind](https://hifind.the-hive-mobile.app/) | [Hive Donate App](https://donate.the-hive-mobile.app/) |
| Contributed to HiveAuth Mobile App | Ecency ↔ 3Speak Integration | Ecency ↔ InLeo Integration | Ecency ↔ Actifit Integration |
| [Hive Stats App](https://stats.the-hive-mobile.app/) | [Vote for Witness App](https://witness.the-hive-mobile.app/) | [HiveFlutterKit](https://hiveflutterkit.sagarkothari88.one/docs/intro) | [New 3Speak App](https://3speak.sagarkothari88.one/#/?tab=home) |

---



### πŸ™Œ Support Back

❀️ **Appreciate my work? Consider supporting @threespeak & @sagarkothari88!** ❀️

| Vote | For | Witness |
|------|-----|---------|
| [![](https://images.hive.blog/u/sagarkothari88/avatar)](https://witness.the-hive-mobile.app/#/witnesses/@sagarkothari88) | [sagarkothari88](https://witness.the-hive-mobile.app/#/witnesses/@sagarkothari88) | @sagarkothari88 |
| [![](https://images.hive.blog/u/threespeak/avatar)](https://witness.the-hive-mobile.app/#/witnesses/@threespeak) | [threespeak](https://witness.the-hive-mobile.app/#/witnesses/@threespeak) | @threespeak |

---
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 145 others
properties (23)
authorsagarkothari88
permlinkreactjs-adventures-designing-a-cashback-claimbox-for-distriator
categoryhive-139531
json_metadata"{"app":"peakd/2025.8.3","format":"markdown","description":"Building a fun, sleek Cashback ClaimBox in ReactJS with DaisyUI β€” code, design, and a pinch of humor for the Hive fam 😎","tags":["hive","india","waiv","neoxian","bro","pizza","distriator","spendhbd","reactjs","dev"],"users":["sagarkothari88","threespeak"],"image":["https://files.peakd.com/file/peakd-hive/sagarkothari88/EokWQVx9BZJApPEySbwH1qZfmWWgoFdBAWh3D7wZk4KJhWfSH6MXGka7sVHYL534Wc8.png","https://files.peakd.com/file/peakd-hive/sagarkothari88/23t752JvVnU26LiSwBW2fwbn7ZWqyg8J9x3AegE4ybgX94QBDcfcYk8UZAKu8T7k6o8nb.png","https://files.peakd.com/file/peakd-hive/sagarkothari88/23tGXSy37QCRpp7EFnm9firGcz7fgk57P7otThaYmmhKYvG3giBvzsMcQnzvpQJqFcKok.png","https://files.peakd.com/file/peakd-hive/sagarkothari88/23t76oPDYmjkX6kNeW331roWc7cQ6C5Q3YUghLgcGH1URAAkK6GLQqB2bKwy1RTj1LDbW.png","https://files.peakd.com/file/peakd-hive/sagarkothari88/EoiTmwnQ7RC3dzFW2vUAGcnsopQLty32ZHaDYwHaqYqLgK1qN3Syo8hXWvpfw9t3Ryf.png","https://images.hive.blog/u/sagarkothari88/avatar","https://images.hive.blog/u/threespeak/avatar"]}"
created2025-08-15 04:30:00
last_update2025-08-15 04:30:00
depth0
children1
last_payout2025-08-22 04:30:00
cashout_time1969-12-31 23:59:59
total_payout_value3.566 HBD
curator_payout_value3.546 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9,308
author_reputation598,298,887,573,363
root_title"🎯 ReactJS Adventures: Designing a Cashback ClaimBox for Distriator πŸ’΅ πŸš€"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id145,007,385
net_rshares24,305,541,157,147
author_curate_reward""
vote details (209)
@indiaunited ·
Indiaunited Curation 1755252322142
This post has been manually curated by @steemflow from Indiaunited community. Join us on our [Discord Server](https://discord.gg/bGmS2tE). 

Do you know that you can earn a passive income by delegating to @indiaunited. We share more than 100 % of the curation rewards with the delegators in the form of IUC tokens. HP delegators and IUC token holders also get upto 20% additional vote weight. 

Here are some handy links for delegations: [100HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=166175.10731001952%20VESTS), [250HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=415437.76827504876%20VESTS), [500HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=830875.5365500975%20VESTS), [1000HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=1661751.073100195%20VESTS). 

[![image.png](https://files.peakd.com/file/peakd-hive/bala41288/46eaz12N-image.png)](https://discord.gg/bGmS2tE) 

<sub>**100% of the rewards from this comment goes to the curator for their manual curation efforts. Please encourage the curator @steemflow by upvoting this comment and support the community by voting the posts made by @indiaunited.**</sub>. 

This post received an extra 7.51% vote for delegating HP / holding IUC tokens.
properties (22)
authorindiaunited
permlinkindiaunited-1755252322142
categoryhive-139531
json_metadata{"app":"hiveblog/0.1","format":"markdown","tags":["hive","india","waiv","neoxian","bro","pizza","distriator","spendhbd","reactjs","dev"]}
created2025-08-15 10:05:21
last_update2025-08-15 10:05:21
depth1
children0
last_payout2025-08-22 10:05:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,416
author_reputation104,205,117,900,926
root_title"🎯 ReactJS Adventures: Designing a Cashback ClaimBox for Distriator πŸ’΅ πŸš€"
beneficiaries
0.
accountsteemflow
weight10,000
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id145,017,371
net_rshares0