24 lines
854 B
JavaScript
24 lines
854 B
JavaScript
function text(value) {
|
|
return value == null ? '' : String(value)
|
|
}
|
|
|
|
export function stableTaskIdentity(identity = {}) {
|
|
return {
|
|
operatorId: text(identity.operatorId ?? identity.accountId ?? identity.userId),
|
|
taskId: text(identity.taskId ?? identity.inboundId),
|
|
loadingPlanId: text(identity.loadingPlanId),
|
|
containerBookingId: text(identity.containerBookingId)
|
|
}
|
|
}
|
|
|
|
export function stableTaskIdentityKey(identity = {}) {
|
|
const value = stableTaskIdentity(identity)
|
|
if (!value.operatorId || !value.taskId || !value.loadingPlanId) return ''
|
|
return [value.operatorId, value.taskId, value.loadingPlanId].map(encodeURIComponent).join(':')
|
|
}
|
|
|
|
export function stableTaskOperationIdentity(identity = {}) {
|
|
const value = stableTaskIdentity(identity)
|
|
return `${value.operatorId}-${value.taskId}-${value.loadingPlanId}-${value.containerBookingId}`
|
|
}
|