refactor(components): add initialValue
prop to the find-user component
in case we want to change instead of create
This commit is contained in:
parent
74995f626b
commit
ba13c4a52f
@ -1,17 +1,24 @@
|
||||
<script lang="ts" setup>
|
||||
import { debounce } from "lodash-es";
|
||||
import { useField } from "vee-validate";
|
||||
const props = defineProps<{ fieldName: string; multi: boolean }>();
|
||||
const props = defineProps<{
|
||||
fieldName: string;
|
||||
multi: boolean;
|
||||
initialOption: {
|
||||
label: string;
|
||||
value: number;
|
||||
} | null;
|
||||
}>();
|
||||
const state = reactive<{
|
||||
data: { value: number; label: string }[];
|
||||
fetching: boolean;
|
||||
}>({
|
||||
data: [],
|
||||
data: props.initialOption ? [props.initialOption] : [],
|
||||
fetching: false,
|
||||
});
|
||||
let fieldo = useField<number | number[]>(props.fieldName, undefined, {
|
||||
// @ts-ignore
|
||||
initialValue: null,
|
||||
initialValue: props.initialOption?.value || null,
|
||||
});
|
||||
|
||||
const { value, errorMessage, name, setValue } = fieldo;
|
||||
|
Loading…
Reference in New Issue
Block a user