Sniberb
Sniberb14mo ago

snowberb – 11-51 Jun 14

What's preferable and why? This:
const filters: Record<GroupingTypeEnum, InstrumentTypeFilter[] | AssetClassFilter[] | undefined> = {
ASSET_TYPE: filterTypesAssets?.data,
INSTRUMENT_TYPE: filterTypesInstrument?.data,
};

const selectOptions = filters[groupingType]?.map((type) => {
if ('instrumentTypeId' in type) {
return {
value: type.instrumentTypeId,
label: type.name,
checked: type.isIncluded,
};
}

return {
value: type.assetClassId,
label: type.name,
checked: type.isIncluded,
};
});
const filters: Record<GroupingTypeEnum, InstrumentTypeFilter[] | AssetClassFilter[] | undefined> = {
ASSET_TYPE: filterTypesAssets?.data,
INSTRUMENT_TYPE: filterTypesInstrument?.data,
};

const selectOptions = filters[groupingType]?.map((type) => {
if ('instrumentTypeId' in type) {
return {
value: type.instrumentTypeId,
label: type.name,
checked: type.isIncluded,
};
}

return {
value: type.assetClassId,
label: type.name,
checked: type.isIncluded,
};
});
or this:
const options =
groupingType === 'INSTRUMENT_TYPE'
? filterTypesInstrument?.data?.map(({ isIncluded, instrumentTypeId, name }) => ({
value: instrumentTypeId,
label: name,
checked: isIncluded,
}))
: filterTypesAssets?.data?.map(({ isIncluded, assetClassId, name }) => ({
value: assetClassId,
label: name,
checked: isIncluded,
}));
const options =
groupingType === 'INSTRUMENT_TYPE'
? filterTypesInstrument?.data?.map(({ isIncluded, instrumentTypeId, name }) => ({
value: instrumentTypeId,
label: name,
checked: isIncluded,
}))
: filterTypesAssets?.data?.map(({ isIncluded, assetClassId, name }) => ({
value: assetClassId,
label: name,
checked: isIncluded,
}));
2 Replies
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
reactibot
reactibot14mo ago
This thread hasn’t had any activity in 36 hours, so it’s now locked. Threads are closed automatically after 36 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1118507922679398431