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> | <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; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user