refactor(components): add initialValue prop to the find-user component

in case we want to change instead of create
This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2023-10-11 16:26:47 -04:00
parent 74995f626b
commit ba13c4a52f
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

View File

@ -1,17 +1,24 @@
<script lang="ts" setup> <script lang="ts" setup>
import { debounce } from "lodash-es"; import { debounce } from "lodash-es";
import { useField } from "vee-validate"; 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<{ const state = reactive<{
data: { value: number; label: string }[]; data: { value: number; label: string }[];
fetching: boolean; fetching: boolean;
}>({ }>({
data: [], data: props.initialOption ? [props.initialOption] : [],
fetching: false, fetching: false,
}); });
let fieldo = useField<number | number[]>(props.fieldName, undefined, { let fieldo = useField<number | number[]>(props.fieldName, undefined, {
// @ts-ignore // @ts-ignore
initialValue: null, initialValue: props.initialOption?.value || null,
}); });
const { value, errorMessage, name, setValue } = fieldo; const { value, errorMessage, name, setValue } = fieldo;