Initial commit: Tapalka monorepo (bot, front, strapi)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
'use client';
|
||||
|
||||
import { PropsWithChildren, useEffect } from 'react';
|
||||
import { useTokenStore } from '@/store/token.state';
|
||||
import { useTasksStore } from '@/store/tasks.state';
|
||||
import { TasksApi } from '@/api/tasks.api';
|
||||
|
||||
export const TasksProvider = ({ children }: PropsWithChildren) => {
|
||||
const { setTasks } = useTasksStore();
|
||||
const { token } = useTokenStore();
|
||||
|
||||
useEffect(() => {
|
||||
if (!token) {
|
||||
return;
|
||||
}
|
||||
const api = TasksApi.getInstance(token);
|
||||
api.getAllTasks().then(tasks => setTasks(tasks));
|
||||
}, [token]);
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
Reference in New Issue
Block a user