forked from verdnatura/salix-front
29 lines
792 B
JavaScript
29 lines
792 B
JavaScript
import axios from 'axios';
|
|
import { useState } from './useState';
|
|
import useNotify from './useNotify';
|
|
|
|
export function useTokenConfig() {
|
|
const state = useState();
|
|
const { notify } = useNotify();
|
|
|
|
async function fetch() {
|
|
try {
|
|
const { data } = await axios.get('AccessTokenConfigs/findOne', {
|
|
filter: { fields: ['renewInterval', 'renewPeriod'] },
|
|
});
|
|
if (!data) return;
|
|
state.setTokenConfig(data);
|
|
sessionStorage.setItem('renewPeriod', data.renewPeriod);
|
|
return data;
|
|
} catch (error) {
|
|
notify('errors.tokenConfig', 'negative');
|
|
console.error('Error fetching token config:', error);
|
|
}
|
|
}
|
|
|
|
return {
|
|
fetch,
|
|
state,
|
|
};
|
|
}
|