Skip to content

Commit

Permalink
Vue demo: Refactoring foreach to reduce.
Browse files Browse the repository at this point in the history
  • Loading branch information
hieu-w committed Sep 2, 2024
1 parent 39b001d commit f0d65e5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions examples/vue-example/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,16 @@ const allMFAFactors = Object.values(MFA_FACTOR);
const mfaSettings = computed(() => {
if (!selectedMFAFactors.value?.length) return {};
const mfaSettings: Record<string, MFA_SETTINGS> = {};
allMFAFactors.forEach((factor) => {
mfaSettings[factor] = { enable: selectedMFAFactors.value.includes(factor), mandatory: selectedMandatoryMFAFactors.value.includes(factor) };
});
console.log("mfaSettings", mfaSettings);
return mfaSettings;
const newMfaSettings = allMFAFactors.reduce(
(acc, factor) => {
acc[factor] = { enable: selectedMFAFactors.value.includes(factor), mandatory: selectedMandatoryMFAFactors.value.includes(factor) };
return acc;
},
{} as Record<string, MFA_SETTINGS>
);
console.log("newMfaSettings", newMfaSettings);
return newMfaSettings;
});
const isValidForm = computed(() => {
Expand Down

0 comments on commit f0d65e5

Please sign in to comment.