Skip to content

feat: Add Warehouse#12

Open
jeninh wants to merge 143 commits intomainfrom
warehouse-dev
Open

feat: Add Warehouse#12
jeninh wants to merge 143 commits intomainfrom
warehouse-dev

Conversation

@jeninh
Copy link
Copy Markdown
Collaborator

@jeninh jeninh commented Feb 26, 2026

Summary
Adds a complete warehouse management system to Resolution, allowing ambassadors to place orders for physical inventory and admins to fulfill them with integrated multi-carrier shipping label generation.

Features
Warehouse Storefront (Ambassadors - /app/warehouse)
Browse inventory items grouped by category
Multi-step order wizard with address entry, item selection, and real-time shipping rate comparison
Order templates for quick reordering
Batch ordering via CSV upload with auto-field-mapping and a linked Google Sheets template
Tag input with chips and autocomplete for order filtering
Orders and batches scoped to the logged-in user

Warehouse Backend (Admins - /app/warehouse-backend)
Full CRUD for inventory categories and items (photo uploads via Hack Club CDN, dimensions, HS codes, sizing options)
Inventory tracking with automatic quantity subtraction on order placement (prevents negative stock)
Fulfillment panel with label generation, printing, and reprint support

Shipping Integration
Canada Post — contract and non-contract shipment support, state/province → 2-letter code resolution, country name → ISO code mapping, 8.5×11 → 4×6 label cropping
Chit Chats — rate quoting and shipment creation with HTS codes and manufacturer details; automatic fallback when Canada Post fails internationally
Theseus — lettermail label support
Zonos — landed cost integration for US-bound shipments
Cheapest-rate auto-selection across all carriers for batch shipping
Flat package type with envelope size snapping (4×6 / 6×9)

Printing
QZ Tray integration for direct thermal label printing (4×6)
Combined label + packing slip print button
Reprint support for previously generated labels

Billing
HCB (Hack Club Bank) billing integration for warehouse orders

Infrastructure
4 new Drizzle migrations (orders, templates/batches, label tracking, HS codes)
drizzle-kit push at container startup for auto-migrations
entrypoint.sh for container orchestration
removeAdmin.mjs CLI script
Staging mode to bypass OAuth for local/staging testing
Body size limit increased to 10MB for image uploads

UI
Phantom Sans font and clean white UI on warehouse, admin, and ambassador pages
Shipping cost estimate disclaimers on order and batch pages

Modified
Extended DB schema with warehouse orders, templates, batches, label/tracking fields
Updated admin page with warehouse backend link and inventory management
Updated validation schemas and tests for new order/item types
CI triggers on warehouse-dev branch

P.S. DO NOT MERGE YET, I NEED TO ADD ENV VARS.

This is to estimate prices for warehouse. Adds POST /api/shipping-rates endpoint that allows ambassadors to get Canada Post shipping rate quotes by providing destination address, package type (envelope/box), dimensions (inches), and weight (grams).
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
resolution Ready Ready Preview, Comment Feb 26, 2026 3:37pm

- Warehouse: stripped admin controls from items/orders pages, now read-only for ambassadors and admins
- Warehouse-Backend: new admin-only route with full CRUD for items, orders, categories, and tags
jeninh added 21 commits March 24, 2026 08:20
'Chit Chats U.S. Select' and similar service names were falling
through to DOM.RP (domestic), causing Canada Post to reject US
shipments. Now catches 'u.s.' and 'usa' → USA.TP, and
'international' → INT.TP before the domestic default.
…Post) at fulfillment time

Save estimatedServiceCode from the rate selection during order creation.
The get-label auto logic now detects CHITCHATS.* service codes and routes
to Chit Chats instead of always falling through to Canada Post.
Add stock validation before decrementing inventory in manual order
creation and batch processing. Returns a 400 error with a descriptive
message if insufficient quantity is available.
- Create /server/hcb.ts with OAuth token refresh and transfer API
- Charge ambassador's pathway org on order placement via HCB v4 transfers
- Map pathway enums to HCB org IDs (Python, General Coding, Game Dev, etc.)
- Auto-refresh access token every 30 min using OAuth refresh_token grant
- Add HCB_CLIENT_ID, HCB_CLIENT_SECRET, HCB_ACCESS_TOKEN, HCB_REFRESH_TOKEN env vars
- Strip non-digit chars from hsCode for Canada Post XML (9505.10.2500 -> 9505102500)
- Pass province/stateProvince through to fetchChitChatsRates to fix invalid province_code errors
9505.10.2500 -> 9505.10.25.00 (proper dotted format per Canada Post schema)
- address-line-1/2: 44 chars, with overflow from line-1 into line-2
- name: 44 chars, city: 40 chars, prov-state: 20 chars, phone: 25 chars
- sku: 15 chars, customs-description: 45 chars
…e versa)

INT.TP (Tracked Packet) isn't available for all countries (e.g. CZ).
Now automatically retries with Xpresspost International as fallback.
Adds resolveStateCode() for US states and CA provinces (e.g. California -> CA).
Applied when creating orders from CSV batches and calculating shipping rates.
- Resolve full state names (e.g. California -> CA) in createShipment XML
  so existing orders with full names in DB are handled
- Only fall back to INT.XP when CP_CONTRACT_ID is set (it requires a contract)
- Include error details in 502 response
…shipments

Countries like CZ and EG aren't supported by INT.TP. When Canada Post
fails for non-CA destinations, automatically try Chit Chats if configured.
- Add INT.SP.AIR, INT.IP, INT.IP.SURF as fallbacks for international shipments
- Stop forcing INT.SP.AIR/INT.SP.SURF to INT.TP when no contract
- Add International Parcel Air/Surface service code mappings
@jeninh
Copy link
Copy Markdown
Collaborator Author

jeninh commented Mar 25, 2026

P.S. DO NOT MERGE YET, I NEED TO ADD ENV VARS.

# Conflicts:
#	.github/workflows/ci.yml
#	resolution-frontend/Dockerfile
#	resolution-frontend/drizzle/meta/0002_snapshot.json
#	resolution-frontend/drizzle/meta/_journal.json
#	resolution-frontend/package-lock.json
#	resolution-frontend/package.json
#	resolution-frontend/src/lib/server/db/schema.ts
#	resolution-frontend/src/lib/server/validation/schemas.test.ts
#	resolution-frontend/src/lib/server/validation/schemas.ts
#	resolution-frontend/src/routes/app/+page.svelte
#	resolution-frontend/src/routes/app/admin/+page.svelte
@jeninh jeninh marked this pull request as ready for review March 25, 2026 12:55
- Add requireAuth() to /api/qz/sign and /api/qz/cert so only
  authenticated users can sign data or fetch the certificate.
- Add admin/ambassador role check to /api/fulfillment/get-label so
  arbitrary authenticated users cannot create shipments or generate
  shipping labels.
@jeninh jeninh requested a review from Charmunks March 26, 2026 12:44
@thesleepyniko thesleepyniko self-requested a review March 26, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

warehouse

1 participant