Skip to content

Commit

Permalink
telefon-vergisi-hesaplayici: group presets by their brand in slug page
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgurg committed Jul 4, 2023
1 parent 2331fc9 commit 9a59d37
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
35 changes: 30 additions & 5 deletions pages/telefon-vergisi-hesaplayici/_slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,16 @@

<v-divider class="my-12" />

<PageSubtitle class="mb-4">
Diğer telefonlar
</PageSubtitle>

<CalculatorPresets :presets="ui.presets" />
<div class="d-flex flex-column gap-16">
<template v-for="_item in presetsGroupedByBrand">
<div :key="_item.title">
<PageSubtitle class="mb-2">
{{ _item.title }}
</PageSubtitle>
<CalculatorPresets :presets="_item.presets" />
</div>
</template>
</div>
</template>

<v-divider class="mb-2 mt-16" />
Expand Down Expand Up @@ -166,6 +171,26 @@ export default {
currency: vm.form.currency,
registrationTitle: vm.ui.registration.find(item => item.value === vm.form.registration).title
});
},
presetsGroupedByBrand() { // FIXME: Make it utility function and write unit test
const vm = this;
const output = {};
vm.ui.presets.forEach(preset => {
const { brand, ...rest } = preset;
if (!output[brand]) {
output[brand] = {
title: brand,
presets: []
};
}
output[brand].presets.push({
brand, ...rest
});
});
return Object.values(output);
}
},
watch: {
Expand Down
2 changes: 1 addition & 1 deletion pages/telefon-vergisi-hesaplayici/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default {
registrationTitle: vm.ui.registration.find(item => item.value === vm.form.registration).title
});
},
presetsGroupedByBrand() {
presetsGroupedByBrand() { // FIXME: Make it utility function and write unit test
const vm = this;
const output = {};
Expand Down

0 comments on commit 9a59d37

Please sign in to comment.