Advertisement
Guest User

Untitled

a guest
Feb 20th, 2023
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. export type InventoryGroup = {
  2. id: number;
  3. name: string;
  4. status: InventoryStatus;
  5. statusText?: string;
  6. };
  7.  
  8. export enum InventoryStatus {
  9. WAITING = 'Waiting',
  10. IN_PROGRESS = 'In progress',
  11. IMPORTED = 'Imported',
  12. FAILED = 'Failed',
  13. }
  14.  
  15. const statusColumnBuilder = useCallback((data: InventoryGroup) => {
  16. // data?.status === 'IMPORTED' (for example)
  17. // and I was trying to do something similar InventoryStatus[data?.status]; but it didn't work and I'm wondering why
  18. const status = InventoryStatus[data?.status?.toString() as keyof typeof InventoryStatus];
  19. return <span title={data.statusText && data.statusText}>{status}</span>;
  20. }, []);
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement