From 71fdb7b5b668b3e67e03adb9f6a738883a31815b Mon Sep 17 00:00:00 2001 From: wbglaeser Date: Fri, 28 Jun 2024 14:29:10 +0200 Subject: [PATCH] read in data from existing profile --- .../components/ProfileSectionField.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/screens/profile-section/components/ProfileSectionField.js b/src/screens/profile-section/components/ProfileSectionField.js index 3094f41b..1624d315 100644 --- a/src/screens/profile-section/components/ProfileSectionField.js +++ b/src/screens/profile-section/components/ProfileSectionField.js @@ -7,7 +7,7 @@ import ProfileSectionInput from "./ProfileSectionInput"; import ProfileSectionClass from "./ProfileSectionClass"; import useAddProfileField from '../hooks/useAddProfileField'; import useInputValidation from "../hooks/useInputValidation"; - +import useFetchProfileField from "../hooks/useFetchProfileField"; const ProfileSectionField = ({ currentField, @@ -21,12 +21,20 @@ const ProfileSectionField = ({ const [localError, setLocalError] = useState(''); const validateValue = useInputValidation(currentField.datatype); const addProfileData = useAddProfileField(currentField, entityData, handleConfirm); - //const fetchProfileField = useFetchProfileField(currentField.datafield, entityData); + const fetchProfileField = useFetchProfileField(currentField.datafield, entityData); useEffect(() => { setValue(''); setLocalError(''); - }, [currentField]); + fetchProfileField().then(fieldData => { + if (fieldData) { + console.log('Field data', fieldData); + setValue(fieldData); + } + }).catch(error => { + console.log('Error fetching profile field', error); + }); + }, [currentField, fetchProfileField]); const handleAddClick = () => { validateValue(value)