yslootahrobotics/prisma/update-prices.ts
Najjar\NajjarV02 52b910ed93 feat(pricing): switch base+EDU prices to AED and unify attire at 5000 AED
- `base` (Basic body) → 77,125 AED  (Unitree G1 retail $16k + $5k markup)
- new `edu` row     → 146,900 AED  ($40k flat)
- all persona attire (kandura, vest, suit, robot-doctor, security-guard) → 5,000 AED
- `custom-color` unchanged at 3,500 AED
- PricingEngine now swaps the base line when EDU body is selected
- localStorage key bumped to `lootah-pricing-v2` to invalidate stale client caches
- Robot Body buttons now describe the variants as `Standard consumer` vs `Open-source education / research` (same chassis GLB, differs in licensing)
- New `prisma/update-prices.ts` idempotent script applies the new prices to an existing DB; seed.ts updated for fresh installs
- Pricing tests updated to match new defaults

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 17:40:04 +04:00

41 lines
1.5 KiB
TypeScript

// One-off price refresh. Run with: npx tsx prisma/update-prices.ts
// Idempotent: upserts every row, safe to re-run.
import { PrismaClient } from '../src/generated/prisma/client.js';
import { PrismaLibSql } from '@prisma/adapter-libsql';
import path from 'path';
const dbPath = path.resolve(process.cwd(), 'prisma', 'lootah.db');
const adapter = new PrismaLibSql({ url: `file:${dbPath}` });
const prisma = new PrismaClient({ adapter } as ConstructorParameters<typeof PrismaClient>[0]);
const items = [
{ id: 'base', label: 'G1 Robot Basic', price: 77125, sortOrder: 0 },
{ id: 'edu', label: 'G1 Robot EDU', price: 146900, sortOrder: 1 },
{ id: 'emarati-kandura', label: 'Emarati Kandura', price: 5000, sortOrder: 2 },
{ id: 'industrial-vest', label: 'Industrial Vest', price: 5000, sortOrder: 3 },
{ id: 'business-suit', label: 'Business Suit', price: 5000, sortOrder: 4 },
{ id: 'custom-color', label: 'Custom Color', price: 3500, sortOrder: 5 },
{ id: 'robot-doctor', label: 'Robot Doctor', price: 5000, sortOrder: 6 },
{ id: 'security-guard', label: 'Security Guard', price: 5000, sortOrder: 7 },
];
async function main() {
for (const item of items) {
await prisma.pricingItem.upsert({
where: { id: item.id },
create: item,
update: { label: item.label, price: item.price, sortOrder: item.sortOrder },
});
console.log(`${item.id}${item.label} @ ${item.price} AED`);
}
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});