feat(offers): add gated phase three public catalogue in QA
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
export type PublicOffer = {
|
||||
id: number;
|
||||
title: string;
|
||||
summary: string;
|
||||
category: string;
|
||||
location: { id: string; name: string; level: string }[];
|
||||
price: {
|
||||
mode: 'amount' | 'negotiable';
|
||||
amount: string | null;
|
||||
currency: string | null;
|
||||
};
|
||||
status: 'published';
|
||||
published_at: string;
|
||||
revision: number;
|
||||
url: string;
|
||||
};
|
||||
/** Display exact decimal text, including large amounts; never converts currency. */
|
||||
export function offerPrice(price: PublicOffer['price']): string {
|
||||
if (price.mode === 'negotiable') return 'A negociar';
|
||||
const [whole, fraction = ''] = (price.amount ?? '').split('.');
|
||||
return `${whole.replace(/\B(?=(\d{3})+(?!\d))/g, ' ')}${fraction ? `,${fraction.padEnd(2, '0')}` : ',00'} ${price.currency ?? ''}`;
|
||||
}
|
||||
Reference in New Issue
Block a user