Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
40 lines
1.0 KiB
Plaintext
40 lines
1.0 KiB
Plaintext
'use client';
|
|
|
|
export const findOptionsByValue = ({
|
|
allowEdit,
|
|
options,
|
|
value
|
|
}) => {
|
|
if (value || typeof value === 'number') {
|
|
if (Array.isArray(value)) {
|
|
return value.map(val => {
|
|
let matchedOption;
|
|
options.forEach(optGroup => {
|
|
if (!matchedOption) {
|
|
matchedOption = optGroup.options.find(option => {
|
|
return option.value === val.value && option.relationTo === val.relationTo;
|
|
});
|
|
}
|
|
});
|
|
return matchedOption ? {
|
|
allowEdit,
|
|
...matchedOption
|
|
} : undefined;
|
|
});
|
|
}
|
|
let matchedOption;
|
|
options.forEach(optGroup => {
|
|
if (!matchedOption) {
|
|
matchedOption = optGroup.options.find(option => {
|
|
return option.value === value.value && option.relationTo === value.relationTo;
|
|
});
|
|
}
|
|
});
|
|
return matchedOption ? {
|
|
allowEdit,
|
|
...matchedOption
|
|
} : undefined;
|
|
}
|
|
return undefined;
|
|
};
|
|
//# sourceMappingURL=findOptionsByValue.js.map |