Avatar ·

How to convert TypeScript enum to array of objects for UI display?

Hello everyone! I'm new to TypeScript and encountered a problem working with enum. I have an order status enumeration: ```typescript enum OrderStatus { Pending = 'pending', Processing = 'processing', Shipped = 'shipped', Delivered = 'delivered', Cancelled = 'cancelled' } ``` I need to display these statuses in a dropdown (select) in a React component. For this I need an array of objects like: ```typescript [ { label: 'Pending', value: 'pending' }, { label: 'Processing', value: 'processing' }, // ... and so on ] ``` I tried using `Object.values(OrderStatus)`, but it only returns the values ('pending', 'processing', etc.). I need to get both the keys (as label) and the values. I tried this code: ```typescript const stat