shadcn.io is not affiliated with official shadcn/ui
Credit Expiry Billing Block for Svelte
Three credit batches for a transcription service with days left from a fixed date, a 30, 60 or 90 day extension that re-dates every expiring batch and prices it at 2% of the credits' value per 30 days, and a primary that names the total.
Installation
Overview
Let people keep credits that would otherwise lapse, with this credit expiry section for Svelte with Ark UI. A hairline frame with a plus mark on each corner lists three batches as ruled rows: promotional credits with 13 days left, referral credits with 30, and a purchased pack that does not expire. Each row shows its credits, its expiry date and a line saying what extending would do. A Toggle Group picks the extension (30, 60 or 90 days); the line under every expiring batch changes to its new date and its fee, which is 2% of the credits' value for every 30 days. The Shine Button at the foot names the total, such as "Extend 2 batches by 60 days, $3.19", and pressing it moves the dates. It's built from Toggle Group, Badge, Shine Button and Guides, with a CSS entrance only. For credits, vouchers and any balance that has a use-by date.
FAQ
How do I fill it with my batches?
Edit START with a name, a source line, the credits, and an ISO expires date, or an empty string for a batch that never expires. VALUE is what one credit is worth in cents and FEE the percentage charged for each 30 days; AS_OF is the date the days left are counted from. The fee for a batch is its credits times the value times the percentage times the days over 30, rounded to the cent, and the total is the sum of those rows.
What stays local, and how do I make it real?
Everything. Extending moves the dates in this page's state and says "Extended 2 batches by 60 days in this demo, nothing was charged." In your app compute the fee on the server, charge it, and move the expiry dates from the response; never trust a date or a price sent from the page.
What if I extend twice?
The second extension starts from the new date, so two 30-day extensions end 60 days later than the original date and the fees are charged on each. The preview line always shows the date the next press would give.