--- title: Software Purchase Card description: A card component for displaying and approving software purchase requests with details like start date, seats, pricing type, and price. featured: true component: true --- ## Installation CLI Manual ```bash npx shadcn@latest add software-purchase-card ``` Install the following dependencies: ```bash npm install lucide-react ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx showLineNumbers import { SoftwarePurchaseCard } from "@/components/cards/software-purchase" ``` ### Basic Usage ```tsx showLineNumbers console.log("Approved")} onDiscard={() => console.log("Discarded")} /> ``` ### Flat Rate Pricing ```tsx showLineNumbers ``` ### Usage-Based Pricing ```tsx showLineNumbers ``` ## API Reference ### SoftwarePurchaseCard The main card component for displaying software purchase details. #### Props | Prop | Type | Default | Description | | ------------ | -------------------------------------------- | -------------------------- | --------------------------------------------- | | softwareName | `string` | `"Enterprise Cloud Suite"` | Name of the software | | startDate | `string` | `"2025-01-15"` | Start date in ISO format (YYYY-MM-DD) | | seats | `number` | `50` | Number of user seats/licenses | | pricingType | `"per-seat" \| "flat-rate" \| "usage-based"` | `"per-seat"` | Type of pricing model | | price | `string` | `"$2,500"` | Price display string (can include formatting) | | onApprove | `() => void` | `undefined` | Callback function when approve button clicked | | onDiscard | `() => void` | `undefined` | Callback function when discard button clicked | ## Examples ### With State Management ```tsx showLineNumbers function PurchaseApproval() { const [status, setStatus] = useState<"pending" | "approved" | "discarded">( "pending" ) const handleApprove = () => { setStatus("approved") // API call to approve purchase approvePurchase(purchaseId) } const handleDiscard = () => { setStatus("discarded") // API call to discard purchase discardPurchase(purchaseId) } return ( ) } ``` ### With Loading State ```tsx showLineNumbers function PurchaseApprovalWithLoading() { const [loading, setLoading] = useState(false) const handleApprove = async () => { setLoading(true) try { await approvePurchaseRequest() toast.success("Purchase approved successfully") } catch (error) { toast.error("Failed to approve purchase") } finally { setLoading(false) } } return ( {}} /> ) } ``` ### Multiple Cards in a List ```tsx showLineNumbers function PurchaseRequestList() { const requests = [ { id: 1, softwareName: "CRM Software", startDate: "2025-01-15", seats: 50, pricingType: "per-seat" as const, price: "$2,500", }, { id: 2, softwareName: "Project Management Tool", startDate: "2025-02-01", seats: 30, pricingType: "flat-rate" as const, price: "$999", }, ] return (
{requests.map((request) => ( handleApprove(request.id)} onDiscard={() => handleDiscard(request.id)} /> ))}
) } ``` ## Block Example For a full-page implementation with detailed purchase information, check out the [software-purchase-01](/blocks/software-purchase-01) block. ## Notes - The date is automatically formatted using `toLocaleDateString` with US locale - The pricing type badge displays in a secondary variant for visual hierarchy - Icons from `lucide-react` are used for visual clarity (Calendar, Users, CreditCard, DollarSign) - The component uses the shadcn/ui Card, Button, and Badge components - The card is fully responsive with a max width of `md` (28rem)