Skip to content

Commit

Permalink
read in data from existing profile
Browse files Browse the repository at this point in the history
  • Loading branch information
wbglaeser committed Jun 28, 2024
1 parent 6e1626e commit 71fdb7b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/screens/profile-section/components/ProfileSectionField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 71fdb7b

Please sign in to comment.