Initial commit: Tapalka monorepo (bot, front, strapi)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
'use client';
|
||||
|
||||
import { PropsWithChildren, useEffect } from 'react';
|
||||
import { ConfigBotApi } from '@/api/config-bot.api';
|
||||
import { useTokenStore } from '@/store/token.state';
|
||||
|
||||
const configBotApi = ConfigBotApi.getInstance();
|
||||
|
||||
export const TokenProvider = ({ children }: PropsWithChildren) => {
|
||||
const { setToken } = useTokenStore();
|
||||
|
||||
useEffect(() => {
|
||||
configBotApi.getConfigBot().then(cfg => {
|
||||
console.log('[TokenProvider] got config:', cfg);
|
||||
setToken(cfg.token);
|
||||
}).catch(err => {
|
||||
console.error('[TokenProvider] error getting config:', err);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
Reference in New Issue
Block a user