Staaarter

Gift Card Balance Checker

A gift card balance lookup form: enter a card number and security code and get back either the card's balance and recent transaction history, or a not-found error, checked against a fixed local lookup table. A reload mini-form sits below the result for topping up the balance.

By Staaarter Team
Ecommerce
Docs
Live preview

Docs

Installation

A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/gift-card-balance-checker.json

Prefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/ecommerce/ecommerce20.tsx instead.

Usage

The file also exports ecommerce20Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.

import { Ecommerce20, ecommerce20Demo } from "@/components/blocks/ecommerce/ecommerce20";

export default function Page() {
  return <Ecommerce20 {...ecommerce20Demo} />;
}

Props

PropTypeDefaultDescription
headingstring"Check your gift card balance"Heading above the form.
descriptionstring"Enter your card number and security code..."Subheading under the heading.
cardsGiftCardRecord[]noneThe fixed lookup table checked against on submit.
classNamestringnoneExtra classes for the outer section element.

Types

type Transaction = {
  date: string;
  description: string;
  amount: string; // pre-formatted, e.g. "-$25.00" or "+$50.00"
};

type GiftCardRecord = {
  cardNumber: string;
  pin: string;
  balance: string;
  transactions: Transaction[];
};

Behavior notes

  • The balance check is genuinely validated client-side: on submit, the typed card number and security code are trimmed and matched exactly against the cards array, and the found record's balance and transaction history render, or a "Card not found" error renders if nothing matches. No network call happens; cards is a fixed prop, not a live database.
  • The reload mini-form (amount input + Reload button) below a found result is decorative only, submitting it does nothing. A real balance reload needs a backend to actually apply the charge and credit, which this block doesn't have.
  • The reload form and transaction history only appear after a successful lookup; a not-found result shows just the error message.