Skip to content

Commit

Permalink
🛠️: refactor FormRadio to typeScript and import missing components
Browse files Browse the repository at this point in the history
  • Loading branch information
itisAliRH committed Apr 5, 2024
1 parent 67fd056 commit a543b04
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions client/src/components/Form/Elements/FormRadio.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<script setup>
<script setup lang="ts">
import { BAlert, BFormRadio, BFormRadioGroup } from "bootstrap-vue";
import { computed } from "vue";
const emit = defineEmits(["input"]);
const props = defineProps({
value: {
default: null,
},
interface Props {
value?: string | number;
options: {
type: Array,
required: true,
},
});
label: string;
value: string | number;
}[];
}
const props = defineProps<Props>();
const emit = defineEmits<{
(e: "input", value: string | number | undefined): void;
}>();
const currentValue = computed({
get: () => {
Expand All @@ -27,10 +31,10 @@ const hasOptions = computed(() => {
</script>

<template>
<b-form-radio-group v-if="hasOptions" v-model="currentValue" stacked>
<b-form-radio v-for="(option, index) in options" :key="index" :value="option.value">
<BFormRadioGroup v-if="hasOptions" v-model="currentValue" stacked>
<BFormRadio v-for="(option, index) in options" :key="index" :value="option.value">
{{ option.label }}
</b-form-radio>
</b-form-radio-group>
<b-alert v-else v-localize variant="warning" show> No options available. </b-alert>
</BFormRadio>
</BFormRadioGroup>
<BAlert v-else v-localize variant="warning" show> No options available. </BAlert>
</template>

0 comments on commit a543b04

Please sign in to comment.