Skip to content

Commit 2dace85

Browse files
luizhf42gustavosbarreto
authored andcommitted
refactor(ui): migrate BillingIcon to script setup syntax
1 parent 5725f0d commit 2dace85

File tree

1 file changed

+24
-40
lines changed

1 file changed

+24
-40
lines changed

ui/src/components/Billing/BillingIcon.vue

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,37 @@
88

99
<v-icon
1010
v-else
11-
:icon="['fa:fab', icon()].join(' ')"
11+
:icon="['fa:fab', getIcon()].join(' ')"
1212
:style="{ fontSize: size }"
1313
data-test="type-icon"
1414
/>
1515

1616
</template>
1717

18-
<script lang="ts">
19-
/* eslint-disable */
20-
import { defineComponent, ref } from "vue";
18+
<script setup lang="ts">
19+
import { ref } from "vue";
2120
22-
export default defineComponent({
23-
props: {
24-
iconName: {
25-
type: String,
26-
required: true,
27-
},
28-
},
29-
setup(props) {
30-
const cardIcon = ref({
31-
amex: "fa-cc-amex",
32-
dinersClub: "fa-cc-diners-club",
33-
discover: "fa-cc-discover",
34-
jcb: "fa-cc-jcb",
35-
mastercard: "fa-cc-mastercard",
36-
visa: "fa-cc-visa",
37-
});
38-
39-
const size = ref("1.5rem");
40-
41-
const isDefaultIcon = () =>
42-
cardIcon.value[convertIconName()] === undefined;
43-
const icon = () =>
44-
cardIcon.value[convertIconName()] || "credit-card";
45-
const convertIconName = () => {
46-
props.iconName === "diners-club" ? "dinersClub" : props.iconName
47-
48-
return props.iconName;
49-
};
50-
51-
return {
52-
cardIcon,
53-
size,
54-
isDefaultIcon,
55-
icon,
56-
convertIconName,
57-
};
21+
const { iconName } = defineProps({
22+
iconName: {
23+
type: String,
24+
required: true,
5825
},
5926
});
27+
28+
const cardIcon = ref({
29+
amex: "fa-cc-amex",
30+
dinersClub: "fa-cc-diners-club",
31+
discover: "fa-cc-discover",
32+
jcb: "fa-cc-jcb",
33+
mastercard: "fa-cc-mastercard",
34+
visa: "fa-cc-visa",
35+
});
36+
37+
const size = ref("1.5rem");
38+
39+
const getFormattedIconName = () => iconName === "diners-club" ? "dinersClub" : iconName;
40+
41+
const isDefaultIcon = () => cardIcon.value[getFormattedIconName()] === undefined;
42+
43+
const getIcon = () => cardIcon.value[getFormattedIconName()] || "credit-card";
6044
</script>

0 commit comments

Comments
 (0)