Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 1x 1x 1x 1x 1x | import {AttachmentType, PmoStatus, TimelineStep} from '@logchain/types';
export function mapStepToStatus(step: TimelineStep): number {
switch (step) {
case TimelineStep.DROPPED:
return PmoStatus.NEW;
case TimelineStep.RECEIVED:
return PmoStatus.DROPPED;
case TimelineStep.PACKING:
return PmoStatus.RECEIVED;
case TimelineStep.PACKED:
return PmoStatus.PACKING;
case TimelineStep.PICKUP:
return PmoStatus.PACKED;
case TimelineStep.PICKED:
return PmoStatus.PICKUP;
case TimelineStep.COMPLETE:
return PmoStatus.COMPLETED;
case TimelineStep.REJECT:
return PmoStatus.REJECTED;
default:
return 0;
}
}
export function mapStatusToStep(status: number): TimelineStep {
switch (status) {
case PmoStatus.NEW:
return TimelineStep.DROPPED;
case PmoStatus.DROPPED:
return TimelineStep.RECEIVED;
case PmoStatus.RECEIVED:
return TimelineStep.PACKING;
case PmoStatus.PACKING:
return TimelineStep.PACKED;
case PmoStatus.PACKED:
return TimelineStep.PICKUP;
case PmoStatus.PICKUP:
return TimelineStep.PICKED;
case PmoStatus.COMPLETED:
return TimelineStep.COMPLETE;
case PmoStatus.REJECTED:
return TimelineStep.REJECT;
default:
throw new Error(`Unhandled status: ${status}`);
}
}
export function mapAttachmentType(step: TimelineStep): AttachmentType | null {
switch (step) {
case TimelineStep.DROPPED:
return AttachmentType.DROPPED;
case TimelineStep.RECEIVED:
return AttachmentType.RECEIVED;
case TimelineStep.PACKING:
return AttachmentType.PACKING;
case TimelineStep.PACKED:
return AttachmentType.PACKED;
case TimelineStep.PICKUP:
return AttachmentType.PICKUP;
case TimelineStep.PICKED:
return AttachmentType.PICKED;
default:
return null;
}
}
export function toUTCString(val: any): string | null {
if (!val) return null;
const d = val instanceof Date ? val : new Date(val);
return isNaN(d.getTime()) ? null : d.toISOString();
}
|