List cards need supplier→buyer and follow user to match the approved mobile demo. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
/**
|
|
* Mirrors formatPartyLine in src/utils/mp-pl-plan-card.ts — keep in sync.
|
|
* Usage: node web-admin/scripts/check-mp-pl-plan-card.mjs
|
|
*/
|
|
|
|
function formatPartyLine(supplier, buyer) {
|
|
const s = (supplier || '').trim() || '—'
|
|
const b = (buyer || '').trim() || '—'
|
|
return `${s} → ${b}`
|
|
}
|
|
|
|
function assert(cond, msg) {
|
|
if (!cond) {
|
|
console.error(msg)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
assert(formatPartyLine('安庆仓', '合肥某化') === '安庆仓 → 合肥某化', 'party')
|
|
assert(formatPartyLine('', null) === '— → —', 'empty')
|
|
assert(formatPartyLine(' ', undefined) === '— → —', 'whitespace')
|
|
|
|
// buildPlanCard supplier/buyer/partyLine defaults (mirrors TS || '—' + formatPartyLine)
|
|
function resolveBuyer(plan) {
|
|
return plan.customerName || plan.destinationName || '—'
|
|
}
|
|
assert(resolveBuyer({ customerName: 'A' }) === 'A', 'buyer customer')
|
|
assert(resolveBuyer({ destinationName: 'B' }) === 'B', 'buyer destination')
|
|
assert(resolveBuyer({}) === '—', 'buyer empty')
|
|
assert(formatPartyLine(undefined, undefined) === '— → —', 'partyLine empty')
|
|
|
|
console.log('check-mp-pl-plan-card: ok')
|