leumas-private-shared
Version:
Private React JSX Package For Leumas Shared Components, Headers, Footers, Asides, Login Pages, API Key Manager and much more. Styles and everything reusable to avoid DRY code across all of our subdomains
30 lines (24 loc) • 1.1 kB
JSX
import { useState, useEffect } from 'react';
import { getAllItems } from '../../helpers/LMS-WildCard-Helpers/UniversalCrud/UniversalCrudHelpers'; // Adjust path accordingly
import AiTrainingForms from './exportTrainingForms';
import {useAuthUser} from "react-auth-kit"
function AiTrainingFormFetcher() {
const [fetchedForms, setFetchedForms] = useState({});
const auth = useAuthUser()
useEffect(() => {
const fetchData = async () => {
try {
const trainingForms = await getAllItems("AiForm", "LeumasAPI", auth()?.token);
setFetchedForms(trainingForms);
console.log("Training Forms ", trainingForms)
} catch (error) {
console.error('Error fetching training forms:', error);
}
};
fetchData();
}, []);
// Update AiTrainingForms with the fetched forms
Object.assign(AiTrainingForms, fetchedForms);
return null; // This component doesn't render anything, it's just for data fetching
}
export default AiTrainingFormFetcher;