Spaces:
Paused
Paused
File size: 939 Bytes
1c72248 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
'use client';
import { useEffect, useState } from 'react';
import { apiClient } from '@/utils/api';
export interface Settings {
HF_TOKEN: string;
TRAINING_FOLDER: string;
DATASETS_FOLDER: string;
}
export default function useSettings() {
const [settings, setSettings] = useState({
HF_TOKEN: '',
TRAINING_FOLDER: '',
DATASETS_FOLDER: '',
});
const [isSettingsLoaded, setIsLoaded] = useState(false);
useEffect(() => {
apiClient
.get('/api/settings')
.then(res => res.data)
.then(data => {
console.log('Settings:', data);
setSettings({
HF_TOKEN: data.HF_TOKEN || '',
TRAINING_FOLDER: data.TRAINING_FOLDER || '',
DATASETS_FOLDER: data.DATASETS_FOLDER || '',
});
setIsLoaded(true);
})
.catch(error => console.error('Error fetching settings:', error));
}, []);
return { settings, setSettings, isSettingsLoaded };
}
|