Repository navigation
[v35] feat(store): show running sales and flash sales in the store - #6267
Conversation
**Add approved & assigned issue number here:** Resolves #6233 Shows the player when a store sale is running, and adds flash sales. While a sale covers an item, the API serves the sale price in `priceHard`/`priceSoft`, so prices and charges were already right. This PR makes the sale visible. The server side is openfrontio/infra#1084. - **Sale banner:** a strip under the store header for each running sale: a `-30%` badge, the sale's name, "30% off selected items" (or "store-wide" when it covers everything), and an "Ends in 2d 5h" countdown. The countdown turns yellow in the sale's last 24 hours. - **"On sale" tab:** a first sub-tab listing everything discounted. It shows only while something is on sale. Discounted items are also sorted first on the other tabs. - **Sale ribbon:** a diagonal `-30%` band across the top-right corner of a discounted item's artwork, in the brand Aquarius blue (orange under the Halloween theme). - **Buy buttons:** the new price, with the old price struck through underneath it. Screen readers hear "Now 70, was 100". - **The "?" info button** moves to the card's top-left so it doesn't sit under the ribbon. A flash sale discounts one for-sale item at a time, at a deeper discount, and moves on to another item every slot (for example every 2 hours). It's the same item for every player. - **In the banner:** a slim "Flash sale" row under the regular sale strip, or a full strip if it's the only sale. Clicking it opens the On sale tab. - **At the top of the On sale tab:** the flash item with a title and a live `1:23:45` clock to the next item. - **On the card:** a pulsing glow with a spinning edge, and a "1:23:45 left" timer along the bottom of the artwork. Under reduced motion it's a static outline. - **Schemas** (`packages/shared/src/CosmeticSchemas.ts`): a `PromotionSchema` (with optional `kind: "flash"`); optional `listPriceHard`/`listPriceSoft`/`promotion` on cosmetics and packs; an optional top-level `promotions` list. All optional, so an older `cosmetics.json` still parses. - **`activeSale()`** (`Cosmetics.ts`) decides whether an item is on sale right now: its promotion hasn't ended and its list price is above its price. - **`<sale-countdown>`** (`components/SaleCountdown.ts`) ticks on its own (every 30s, or every second for the clock), so the store doesn't re-render to update a timer. - **Ended sales:** a sale whose end has passed is hidden straight away, items fall back to their list price, and the catalog is refetched. When the store opens, a catalog older than 60s is refetched. Every store fetch (opening, sign-in, a sale ending) goes through `loadCatalog`, which keeps only the newest request's answer, so an older response landing last can't replace a newer catalog. - **i18n:** new `store.*` keys in `en.json` for the banner, countdowns, the On sale tab and flash sales. `store.sale_banner` is removed. **On sale tab with a flash sale:** the banner, the flash item leading the tab with its countdown, and the glowing flash card. <img width="1538" height="784" alt="store-on-sale-flash" src="https://github.com/user-attachments/assets/b676e24e-b125-474d-b666-9daeb26c8d18" /> **Sale cards:** the corner ribbon and the struck-through list price on each buy button. <img width="1538" height="784" alt="store-sale-cards" src="https://github.com/user-attachments/assets/5b100f1f-83da-47b8-b51f-5e740796451f" /> **Halloween theme, Skins tab:** the same UI follows the theme (orange), and items on sale sort first, the flash item leading. <img width="1538" height="784" alt="store-halloween-skins" src="https://github.com/user-attachments/assets/3df857c1-6a38-496a-a502-c3f80b1a987c" /> - [x] I have added screenshots for all UI updates (above, from a local build against a fake catalog API). - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory: - `StoreModal`: the banner, store-wide vs selected items, the On sale tab and its ordering, the flash row and hero, ended sales hidden, the countdown text and clock; - `CosmeticCard`: the ribbon, the flash glow, ring and timer, "?" on the top-left; - `PurchaseButton`: the struck list price with its screen-reader labels, nothing when the list price isn't above the price; - `CosmeticsStaleRefresh`: a fresh catalog is kept and a stale one is refetched. `npm run typecheck` and `npm run lint` are clean, and the 139 store, card and purchase tests pass. regression is found: DISCORD_USERNAME 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: iamlewis <lewismmmm@gmail.com> (cherry picked from commit 74832f3) Conflicts resolved for v35 by Claude.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
Cherry-pick of #6234 onto
v35. It conflicted, and Claude resolved it.Conflicted files:
src/client/Store.tssrc/client/components/CosmeticCard.tsTypecheck, format and lint pass on the result.
Check the fix before merging.